documentation.d.ts 3.4 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010
  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. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module BABYLON {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static get LogCache(): string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static set LogLevels(level: number);
  363. }
  364. }
  365. declare module BABYLON {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module BABYLON {
  377. /**
  378. * Helper to manipulate strings
  379. */
  380. export class StringTools {
  381. /**
  382. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  383. * @param str Source string
  384. * @param suffix Suffix to search for in the source string
  385. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  386. */
  387. static EndsWith(str: string, suffix: string): boolean;
  388. /**
  389. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  390. * @param str Source string
  391. * @param suffix Suffix to search for in the source string
  392. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  393. */
  394. static StartsWith(str: string, suffix: string): boolean;
  395. /**
  396. * Decodes a buffer into a string
  397. * @param buffer The buffer to decode
  398. * @returns The decoded string
  399. */
  400. static Decode(buffer: Uint8Array | Uint16Array): string;
  401. /**
  402. * Encode a buffer to a base64 string
  403. * @param buffer defines the buffer to encode
  404. * @returns the encoded string
  405. */
  406. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  407. /**
  408. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  409. * @param num the number to convert and pad
  410. * @param length the expected length of the string
  411. * @returns the padded string
  412. */
  413. static PadNumber(num: number, length: number): string;
  414. }
  415. }
  416. declare module BABYLON {
  417. /**
  418. * Class containing a set of static utilities functions for deep copy.
  419. */
  420. export class DeepCopier {
  421. /**
  422. * Tries to copy an object by duplicating every property
  423. * @param source defines the source object
  424. * @param destination defines the target object
  425. * @param doNotCopyList defines a list of properties to avoid
  426. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  427. */
  428. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  429. }
  430. }
  431. declare module BABYLON {
  432. /**
  433. * Class containing a set of static utilities functions for precision date
  434. */
  435. export class PrecisionDate {
  436. /**
  437. * Gets either window.performance.now() if supported or Date.now() else
  438. */
  439. static get Now(): number;
  440. }
  441. }
  442. declare module BABYLON {
  443. /** @hidden */
  444. export class _DevTools {
  445. static WarnImport(name: string): string;
  446. }
  447. }
  448. declare module BABYLON {
  449. /**
  450. * Interface used to define the mechanism to get data from the network
  451. */
  452. export interface IWebRequest {
  453. /**
  454. * Returns client's response url
  455. */
  456. responseURL: string;
  457. /**
  458. * Returns client's status
  459. */
  460. status: number;
  461. /**
  462. * Returns client's status as a text
  463. */
  464. statusText: string;
  465. }
  466. }
  467. declare module BABYLON {
  468. /**
  469. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  470. */
  471. export class WebRequest implements IWebRequest {
  472. private _xhr;
  473. /**
  474. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  475. * i.e. when loading files, where the server/service expects an Authorization header
  476. */
  477. static CustomRequestHeaders: {
  478. [key: string]: string;
  479. };
  480. /**
  481. * Add callback functions in this array to update all the requests before they get sent to the network
  482. */
  483. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  484. private _injectCustomRequestHeaders;
  485. /**
  486. * Gets or sets a function to be called when loading progress changes
  487. */
  488. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  489. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  490. /**
  491. * Returns client's state
  492. */
  493. get readyState(): number;
  494. /**
  495. * Returns client's status
  496. */
  497. get status(): number;
  498. /**
  499. * Returns client's status as a text
  500. */
  501. get statusText(): string;
  502. /**
  503. * Returns client's response
  504. */
  505. get response(): any;
  506. /**
  507. * Returns client's response url
  508. */
  509. get responseURL(): string;
  510. /**
  511. * Returns client's response as text
  512. */
  513. get responseText(): string;
  514. /**
  515. * Gets or sets the expected response type
  516. */
  517. get responseType(): XMLHttpRequestResponseType;
  518. set responseType(value: XMLHttpRequestResponseType);
  519. /** @hidden */
  520. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  521. /** @hidden */
  522. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  523. /**
  524. * Cancels any network activity
  525. */
  526. abort(): void;
  527. /**
  528. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  529. * @param body defines an optional request body
  530. */
  531. send(body?: Document | BodyInit | null): void;
  532. /**
  533. * Sets the request method, request URL
  534. * @param method defines the method to use (GET, POST, etc..)
  535. * @param url defines the url to connect with
  536. */
  537. open(method: string, url: string): void;
  538. /**
  539. * Sets the value of a request header.
  540. * @param name The name of the header whose value is to be set
  541. * @param value The value to set as the body of the header
  542. */
  543. setRequestHeader(name: string, value: string): void;
  544. /**
  545. * Get the string containing the text of a particular header's value.
  546. * @param name The name of the header
  547. * @returns The string containing the text of the given header name
  548. */
  549. getResponseHeader(name: string): Nullable<string>;
  550. }
  551. }
  552. declare module BABYLON {
  553. /**
  554. * File request interface
  555. */
  556. export interface IFileRequest {
  557. /**
  558. * Raised when the request is complete (success or error).
  559. */
  560. onCompleteObservable: Observable<IFileRequest>;
  561. /**
  562. * Aborts the request for a file.
  563. */
  564. abort: () => void;
  565. }
  566. }
  567. declare module BABYLON {
  568. /**
  569. * Define options used to create a render target texture
  570. */
  571. export class RenderTargetCreationOptions {
  572. /**
  573. * Specifies is mipmaps must be generated
  574. */
  575. generateMipMaps?: boolean;
  576. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  577. generateDepthBuffer?: boolean;
  578. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  579. generateStencilBuffer?: boolean;
  580. /** Defines texture type (int by default) */
  581. type?: number;
  582. /** Defines sampling mode (trilinear by default) */
  583. samplingMode?: number;
  584. /** Defines format (RGBA by default) */
  585. format?: number;
  586. }
  587. }
  588. declare module BABYLON {
  589. /** Defines the cross module used constants to avoid circular dependncies */
  590. export class Constants {
  591. /** Defines that alpha blending is disabled */
  592. static readonly ALPHA_DISABLE: number;
  593. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  594. static readonly ALPHA_ADD: number;
  595. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  596. static readonly ALPHA_COMBINE: number;
  597. /** Defines that alpha blending is DEST - SRC * DEST */
  598. static readonly ALPHA_SUBTRACT: number;
  599. /** Defines that alpha blending is SRC * DEST */
  600. static readonly ALPHA_MULTIPLY: number;
  601. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  602. static readonly ALPHA_MAXIMIZED: number;
  603. /** Defines that alpha blending is SRC + DEST */
  604. static readonly ALPHA_ONEONE: number;
  605. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  606. static readonly ALPHA_PREMULTIPLIED: number;
  607. /**
  608. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  609. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  610. */
  611. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  612. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  613. static readonly ALPHA_INTERPOLATE: number;
  614. /**
  615. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  616. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  617. */
  618. static readonly ALPHA_SCREENMODE: number;
  619. /**
  620. * Defines that alpha blending is SRC + DST
  621. * Alpha will be set to SRC ALPHA + DST ALPHA
  622. */
  623. static readonly ALPHA_ONEONE_ONEONE: number;
  624. /**
  625. * Defines that alpha blending is SRC * DST ALPHA + DST
  626. * Alpha will be set to 0
  627. */
  628. static readonly ALPHA_ALPHATOCOLOR: number;
  629. /**
  630. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  631. */
  632. static readonly ALPHA_REVERSEONEMINUS: number;
  633. /**
  634. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  635. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  636. */
  637. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST
  640. * Alpha will be set to SRC ALPHA
  641. */
  642. static readonly ALPHA_ONEONE_ONEZERO: number;
  643. /**
  644. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  645. * Alpha will be set to DST ALPHA
  646. */
  647. static readonly ALPHA_EXCLUSION: number;
  648. /** Defines that alpha blending equation a SUM */
  649. static readonly ALPHA_EQUATION_ADD: number;
  650. /** Defines that alpha blending equation a SUBSTRACTION */
  651. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  652. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  653. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  654. /** Defines that alpha blending equation a MAX operation */
  655. static readonly ALPHA_EQUATION_MAX: number;
  656. /** Defines that alpha blending equation a MIN operation */
  657. static readonly ALPHA_EQUATION_MIN: number;
  658. /**
  659. * Defines that alpha blending equation a DARKEN operation:
  660. * It takes the min of the src and sums the alpha channels.
  661. */
  662. static readonly ALPHA_EQUATION_DARKEN: number;
  663. /** Defines that the ressource is not delayed*/
  664. static readonly DELAYLOADSTATE_NONE: number;
  665. /** Defines that the ressource was successfully delay loaded */
  666. static readonly DELAYLOADSTATE_LOADED: number;
  667. /** Defines that the ressource is currently delay loading */
  668. static readonly DELAYLOADSTATE_LOADING: number;
  669. /** Defines that the ressource is delayed and has not started loading */
  670. static readonly DELAYLOADSTATE_NOTLOADED: number;
  671. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  672. static readonly NEVER: number;
  673. /** 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 */
  674. static readonly ALWAYS: number;
  675. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  676. static readonly LESS: number;
  677. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  678. static readonly EQUAL: number;
  679. /** 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 */
  680. static readonly LEQUAL: number;
  681. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  682. static readonly GREATER: number;
  683. /** 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 */
  684. static readonly GEQUAL: number;
  685. /** 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 */
  686. static readonly NOTEQUAL: number;
  687. /** Passed to stencilOperation to specify that stencil value must be kept */
  688. static readonly KEEP: number;
  689. /** Passed to stencilOperation to specify that stencil value must be replaced */
  690. static readonly REPLACE: number;
  691. /** Passed to stencilOperation to specify that stencil value must be incremented */
  692. static readonly INCR: number;
  693. /** Passed to stencilOperation to specify that stencil value must be decremented */
  694. static readonly DECR: number;
  695. /** Passed to stencilOperation to specify that stencil value must be inverted */
  696. static readonly INVERT: number;
  697. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  698. static readonly INCR_WRAP: number;
  699. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  700. static readonly DECR_WRAP: number;
  701. /** Texture is not repeating outside of 0..1 UVs */
  702. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  703. /** Texture is repeating outside of 0..1 UVs */
  704. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  705. /** Texture is repeating and mirrored */
  706. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  707. /** ALPHA */
  708. static readonly TEXTUREFORMAT_ALPHA: number;
  709. /** LUMINANCE */
  710. static readonly TEXTUREFORMAT_LUMINANCE: number;
  711. /** LUMINANCE_ALPHA */
  712. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  713. /** RGB */
  714. static readonly TEXTUREFORMAT_RGB: number;
  715. /** RGBA */
  716. static readonly TEXTUREFORMAT_RGBA: number;
  717. /** RED */
  718. static readonly TEXTUREFORMAT_RED: number;
  719. /** RED (2nd reference) */
  720. static readonly TEXTUREFORMAT_R: number;
  721. /** RG */
  722. static readonly TEXTUREFORMAT_RG: number;
  723. /** RED_INTEGER */
  724. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  725. /** RED_INTEGER (2nd reference) */
  726. static readonly TEXTUREFORMAT_R_INTEGER: number;
  727. /** RG_INTEGER */
  728. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  729. /** RGB_INTEGER */
  730. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  731. /** RGBA_INTEGER */
  732. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  733. /** UNSIGNED_BYTE */
  734. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  735. /** UNSIGNED_BYTE (2nd reference) */
  736. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  737. /** FLOAT */
  738. static readonly TEXTURETYPE_FLOAT: number;
  739. /** HALF_FLOAT */
  740. static readonly TEXTURETYPE_HALF_FLOAT: number;
  741. /** BYTE */
  742. static readonly TEXTURETYPE_BYTE: number;
  743. /** SHORT */
  744. static readonly TEXTURETYPE_SHORT: number;
  745. /** UNSIGNED_SHORT */
  746. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  747. /** INT */
  748. static readonly TEXTURETYPE_INT: number;
  749. /** UNSIGNED_INT */
  750. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  751. /** UNSIGNED_SHORT_4_4_4_4 */
  752. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  753. /** UNSIGNED_SHORT_5_5_5_1 */
  754. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  755. /** UNSIGNED_SHORT_5_6_5 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  757. /** UNSIGNED_INT_2_10_10_10_REV */
  758. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  759. /** UNSIGNED_INT_24_8 */
  760. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  761. /** UNSIGNED_INT_10F_11F_11F_REV */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  763. /** UNSIGNED_INT_5_9_9_9_REV */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  765. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  766. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  767. /** nearest is mag = nearest and min = nearest and no mip */
  768. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  769. /** mag = nearest and min = nearest and mip = none */
  770. static readonly TEXTURE_NEAREST_NEAREST: number;
  771. /** Bilinear is mag = linear and min = linear and no mip */
  772. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  773. /** mag = linear and min = linear and mip = none */
  774. static readonly TEXTURE_LINEAR_LINEAR: number;
  775. /** Trilinear is mag = linear and min = linear and mip = linear */
  776. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  777. /** Trilinear is mag = linear and min = linear and mip = linear */
  778. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  779. /** mag = nearest and min = nearest and mip = nearest */
  780. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  781. /** mag = nearest and min = linear and mip = nearest */
  782. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  783. /** mag = nearest and min = linear and mip = linear */
  784. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  785. /** mag = nearest and min = linear and mip = none */
  786. static readonly TEXTURE_NEAREST_LINEAR: number;
  787. /** nearest is mag = nearest and min = nearest and mip = linear */
  788. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  789. /** mag = linear and min = nearest and mip = nearest */
  790. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  791. /** mag = linear and min = nearest and mip = linear */
  792. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  793. /** Bilinear is mag = linear and min = linear and mip = nearest */
  794. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  795. /** mag = linear and min = nearest and mip = none */
  796. static readonly TEXTURE_LINEAR_NEAREST: number;
  797. /** Explicit coordinates mode */
  798. static readonly TEXTURE_EXPLICIT_MODE: number;
  799. /** Spherical coordinates mode */
  800. static readonly TEXTURE_SPHERICAL_MODE: number;
  801. /** Planar coordinates mode */
  802. static readonly TEXTURE_PLANAR_MODE: number;
  803. /** Cubic coordinates mode */
  804. static readonly TEXTURE_CUBIC_MODE: number;
  805. /** Projection coordinates mode */
  806. static readonly TEXTURE_PROJECTION_MODE: number;
  807. /** Skybox coordinates mode */
  808. static readonly TEXTURE_SKYBOX_MODE: number;
  809. /** Inverse Cubic coordinates mode */
  810. static readonly TEXTURE_INVCUBIC_MODE: number;
  811. /** Equirectangular coordinates mode */
  812. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  813. /** Equirectangular Fixed coordinates mode */
  814. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  815. /** Equirectangular Fixed Mirrored coordinates mode */
  816. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  817. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  818. static readonly SCALEMODE_FLOOR: number;
  819. /** Defines that texture rescaling will look for the nearest power of 2 size */
  820. static readonly SCALEMODE_NEAREST: number;
  821. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  822. static readonly SCALEMODE_CEILING: number;
  823. /**
  824. * The dirty texture flag value
  825. */
  826. static readonly MATERIAL_TextureDirtyFlag: number;
  827. /**
  828. * The dirty light flag value
  829. */
  830. static readonly MATERIAL_LightDirtyFlag: number;
  831. /**
  832. * The dirty fresnel flag value
  833. */
  834. static readonly MATERIAL_FresnelDirtyFlag: number;
  835. /**
  836. * The dirty attribute flag value
  837. */
  838. static readonly MATERIAL_AttributesDirtyFlag: number;
  839. /**
  840. * The dirty misc flag value
  841. */
  842. static readonly MATERIAL_MiscDirtyFlag: number;
  843. /**
  844. * The all dirty flag value
  845. */
  846. static readonly MATERIAL_AllDirtyFlag: number;
  847. /**
  848. * Returns the triangle fill mode
  849. */
  850. static readonly MATERIAL_TriangleFillMode: number;
  851. /**
  852. * Returns the wireframe mode
  853. */
  854. static readonly MATERIAL_WireFrameFillMode: number;
  855. /**
  856. * Returns the point fill mode
  857. */
  858. static readonly MATERIAL_PointFillMode: number;
  859. /**
  860. * Returns the point list draw mode
  861. */
  862. static readonly MATERIAL_PointListDrawMode: number;
  863. /**
  864. * Returns the line list draw mode
  865. */
  866. static readonly MATERIAL_LineListDrawMode: number;
  867. /**
  868. * Returns the line loop draw mode
  869. */
  870. static readonly MATERIAL_LineLoopDrawMode: number;
  871. /**
  872. * Returns the line strip draw mode
  873. */
  874. static readonly MATERIAL_LineStripDrawMode: number;
  875. /**
  876. * Returns the triangle strip draw mode
  877. */
  878. static readonly MATERIAL_TriangleStripDrawMode: number;
  879. /**
  880. * Returns the triangle fan draw mode
  881. */
  882. static readonly MATERIAL_TriangleFanDrawMode: number;
  883. /**
  884. * Stores the clock-wise side orientation
  885. */
  886. static readonly MATERIAL_ClockWiseSideOrientation: number;
  887. /**
  888. * Stores the counter clock-wise side orientation
  889. */
  890. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  891. /**
  892. * Nothing
  893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  894. */
  895. static readonly ACTION_NothingTrigger: number;
  896. /**
  897. * On pick
  898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  899. */
  900. static readonly ACTION_OnPickTrigger: number;
  901. /**
  902. * On left pick
  903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  904. */
  905. static readonly ACTION_OnLeftPickTrigger: number;
  906. /**
  907. * On right pick
  908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  909. */
  910. static readonly ACTION_OnRightPickTrigger: number;
  911. /**
  912. * On center pick
  913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  914. */
  915. static readonly ACTION_OnCenterPickTrigger: number;
  916. /**
  917. * On pick down
  918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  919. */
  920. static readonly ACTION_OnPickDownTrigger: number;
  921. /**
  922. * On double pick
  923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  924. */
  925. static readonly ACTION_OnDoublePickTrigger: number;
  926. /**
  927. * On pick up
  928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  929. */
  930. static readonly ACTION_OnPickUpTrigger: number;
  931. /**
  932. * On pick out.
  933. * This trigger will only be raised if you also declared a OnPickDown
  934. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  935. */
  936. static readonly ACTION_OnPickOutTrigger: number;
  937. /**
  938. * On long press
  939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  940. */
  941. static readonly ACTION_OnLongPressTrigger: number;
  942. /**
  943. * On pointer over
  944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  945. */
  946. static readonly ACTION_OnPointerOverTrigger: number;
  947. /**
  948. * On pointer out
  949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  950. */
  951. static readonly ACTION_OnPointerOutTrigger: number;
  952. /**
  953. * On every frame
  954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  955. */
  956. static readonly ACTION_OnEveryFrameTrigger: number;
  957. /**
  958. * On intersection enter
  959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  960. */
  961. static readonly ACTION_OnIntersectionEnterTrigger: number;
  962. /**
  963. * On intersection exit
  964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  965. */
  966. static readonly ACTION_OnIntersectionExitTrigger: number;
  967. /**
  968. * On key down
  969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  970. */
  971. static readonly ACTION_OnKeyDownTrigger: number;
  972. /**
  973. * On key up
  974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  975. */
  976. static readonly ACTION_OnKeyUpTrigger: number;
  977. /**
  978. * Billboard mode will only apply to Y axis
  979. */
  980. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  981. /**
  982. * Billboard mode will apply to all axes
  983. */
  984. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  985. /**
  986. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  987. */
  988. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  989. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  990. * Test order :
  991. * Is the bounding sphere outside the frustum ?
  992. * If not, are the bounding box vertices outside the frustum ?
  993. * It not, then the cullable object is in the frustum.
  994. */
  995. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  996. /** Culling strategy : Bounding Sphere Only.
  997. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  998. * It's also less accurate than the standard because some not visible objects can still be selected.
  999. * Test : is the bounding sphere outside the frustum ?
  1000. * If not, then the cullable object is in the frustum.
  1001. */
  1002. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1003. /** Culling strategy : Optimistic Inclusion.
  1004. * This in an inclusion test first, then the standard exclusion test.
  1005. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1006. * 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.
  1007. * Anyway, it's as accurate as the standard strategy.
  1008. * Test :
  1009. * Is the cullable object bounding sphere center in the frustum ?
  1010. * If not, apply the default culling strategy.
  1011. */
  1012. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1013. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1014. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1015. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1016. * 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.
  1017. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1018. * Test :
  1019. * Is the cullable object bounding sphere center in the frustum ?
  1020. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1021. */
  1022. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1023. /**
  1024. * No logging while loading
  1025. */
  1026. static readonly SCENELOADER_NO_LOGGING: number;
  1027. /**
  1028. * Minimal logging while loading
  1029. */
  1030. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1031. /**
  1032. * Summary logging while loading
  1033. */
  1034. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1035. /**
  1036. * Detailled logging while loading
  1037. */
  1038. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1039. }
  1040. }
  1041. declare module BABYLON {
  1042. /**
  1043. * This represents the required contract to create a new type of texture loader.
  1044. */
  1045. export interface IInternalTextureLoader {
  1046. /**
  1047. * Defines wether the loader supports cascade loading the different faces.
  1048. */
  1049. supportCascades: boolean;
  1050. /**
  1051. * This returns if the loader support the current file information.
  1052. * @param extension defines the file extension of the file being loaded
  1053. * @returns true if the loader can load the specified file
  1054. */
  1055. canLoad(extension: string): boolean;
  1056. /**
  1057. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1058. * @param data contains the texture data
  1059. * @param texture defines the BabylonJS internal texture
  1060. * @param createPolynomials will be true if polynomials have been requested
  1061. * @param onLoad defines the callback to trigger once the texture is ready
  1062. * @param onError defines the callback to trigger in case of error
  1063. */
  1064. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1065. /**
  1066. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1067. * @param data contains the texture data
  1068. * @param texture defines the BabylonJS internal texture
  1069. * @param callback defines the method to call once ready to upload
  1070. */
  1071. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1072. }
  1073. }
  1074. declare module BABYLON {
  1075. /**
  1076. * Class used to store and describe the pipeline context associated with an effect
  1077. */
  1078. export interface IPipelineContext {
  1079. /**
  1080. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1081. */
  1082. isAsync: boolean;
  1083. /**
  1084. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1085. */
  1086. isReady: boolean;
  1087. /** @hidden */
  1088. _getVertexShaderCode(): string | null;
  1089. /** @hidden */
  1090. _getFragmentShaderCode(): string | null;
  1091. /** @hidden */
  1092. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1093. }
  1094. }
  1095. declare module BABYLON {
  1096. /**
  1097. * Class used to store gfx data (like WebGLBuffer)
  1098. */
  1099. export class DataBuffer {
  1100. /**
  1101. * Gets or sets the number of objects referencing this buffer
  1102. */
  1103. references: number;
  1104. /** Gets or sets the size of the underlying buffer */
  1105. capacity: number;
  1106. /**
  1107. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1108. */
  1109. is32Bits: boolean;
  1110. /**
  1111. * Gets the underlying buffer
  1112. */
  1113. get underlyingResource(): any;
  1114. }
  1115. }
  1116. declare module BABYLON {
  1117. /** @hidden */
  1118. export interface IShaderProcessor {
  1119. attributeProcessor?: (attribute: string) => string;
  1120. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1121. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1122. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1123. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1124. lineProcessor?: (line: string, isFragment: boolean) => string;
  1125. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1126. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1127. }
  1128. }
  1129. declare module BABYLON {
  1130. /** @hidden */
  1131. export interface ProcessingOptions {
  1132. defines: string[];
  1133. indexParameters: any;
  1134. isFragment: boolean;
  1135. shouldUseHighPrecisionShader: boolean;
  1136. supportsUniformBuffers: boolean;
  1137. shadersRepository: string;
  1138. includesShadersStore: {
  1139. [key: string]: string;
  1140. };
  1141. processor?: IShaderProcessor;
  1142. version: string;
  1143. platformName: string;
  1144. lookForClosingBracketForUniformBuffer?: boolean;
  1145. }
  1146. }
  1147. declare module BABYLON {
  1148. /** @hidden */
  1149. export class ShaderCodeNode {
  1150. line: string;
  1151. children: ShaderCodeNode[];
  1152. additionalDefineKey?: string;
  1153. additionalDefineValue?: string;
  1154. isValid(preprocessors: {
  1155. [key: string]: string;
  1156. }): boolean;
  1157. process(preprocessors: {
  1158. [key: string]: string;
  1159. }, options: ProcessingOptions): string;
  1160. }
  1161. }
  1162. declare module BABYLON {
  1163. /** @hidden */
  1164. export class ShaderCodeCursor {
  1165. private _lines;
  1166. lineIndex: number;
  1167. get currentLine(): string;
  1168. get canRead(): boolean;
  1169. set lines(value: string[]);
  1170. }
  1171. }
  1172. declare module BABYLON {
  1173. /** @hidden */
  1174. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1175. process(preprocessors: {
  1176. [key: string]: string;
  1177. }, options: ProcessingOptions): string;
  1178. }
  1179. }
  1180. declare module BABYLON {
  1181. /** @hidden */
  1182. export class ShaderDefineExpression {
  1183. isTrue(preprocessors: {
  1184. [key: string]: string;
  1185. }): boolean;
  1186. }
  1187. }
  1188. declare module BABYLON {
  1189. /** @hidden */
  1190. export class ShaderCodeTestNode extends ShaderCodeNode {
  1191. testExpression: ShaderDefineExpression;
  1192. isValid(preprocessors: {
  1193. [key: string]: string;
  1194. }): boolean;
  1195. }
  1196. }
  1197. declare module BABYLON {
  1198. /** @hidden */
  1199. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1200. define: string;
  1201. not: boolean;
  1202. constructor(define: string, not?: boolean);
  1203. isTrue(preprocessors: {
  1204. [key: string]: string;
  1205. }): boolean;
  1206. }
  1207. }
  1208. declare module BABYLON {
  1209. /** @hidden */
  1210. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1211. leftOperand: ShaderDefineExpression;
  1212. rightOperand: ShaderDefineExpression;
  1213. isTrue(preprocessors: {
  1214. [key: string]: string;
  1215. }): boolean;
  1216. }
  1217. }
  1218. declare module BABYLON {
  1219. /** @hidden */
  1220. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1221. leftOperand: ShaderDefineExpression;
  1222. rightOperand: ShaderDefineExpression;
  1223. isTrue(preprocessors: {
  1224. [key: string]: string;
  1225. }): boolean;
  1226. }
  1227. }
  1228. declare module BABYLON {
  1229. /** @hidden */
  1230. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1231. define: string;
  1232. operand: string;
  1233. testValue: string;
  1234. constructor(define: string, operand: string, testValue: string);
  1235. isTrue(preprocessors: {
  1236. [key: string]: string;
  1237. }): boolean;
  1238. }
  1239. }
  1240. declare module BABYLON {
  1241. /**
  1242. * Class used to enable access to offline support
  1243. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1244. */
  1245. export interface IOfflineProvider {
  1246. /**
  1247. * Gets a boolean indicating if scene must be saved in the database
  1248. */
  1249. enableSceneOffline: boolean;
  1250. /**
  1251. * Gets a boolean indicating if textures must be saved in the database
  1252. */
  1253. enableTexturesOffline: boolean;
  1254. /**
  1255. * Open the offline support and make it available
  1256. * @param successCallback defines the callback to call on success
  1257. * @param errorCallback defines the callback to call on error
  1258. */
  1259. open(successCallback: () => void, errorCallback: () => void): void;
  1260. /**
  1261. * Loads an image from the offline support
  1262. * @param url defines the url to load from
  1263. * @param image defines the target DOM image
  1264. */
  1265. loadImage(url: string, image: HTMLImageElement): void;
  1266. /**
  1267. * Loads a file from offline support
  1268. * @param url defines the URL to load from
  1269. * @param sceneLoaded defines a callback to call on success
  1270. * @param progressCallBack defines a callback to call when progress changed
  1271. * @param errorCallback defines a callback to call on error
  1272. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1273. */
  1274. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1275. }
  1276. }
  1277. declare module BABYLON {
  1278. /**
  1279. * Class used to help managing file picking and drag'n'drop
  1280. * File Storage
  1281. */
  1282. export class FilesInputStore {
  1283. /**
  1284. * List of files ready to be loaded
  1285. */
  1286. static FilesToLoad: {
  1287. [key: string]: File;
  1288. };
  1289. }
  1290. }
  1291. declare module BABYLON {
  1292. /**
  1293. * Class used to define a retry strategy when error happens while loading assets
  1294. */
  1295. export class RetryStrategy {
  1296. /**
  1297. * Function used to defines an exponential back off strategy
  1298. * @param maxRetries defines the maximum number of retries (3 by default)
  1299. * @param baseInterval defines the interval between retries
  1300. * @returns the strategy function to use
  1301. */
  1302. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1303. }
  1304. }
  1305. declare module BABYLON {
  1306. /**
  1307. * @ignore
  1308. * Application error to support additional information when loading a file
  1309. */
  1310. export abstract class BaseError extends Error {
  1311. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1312. }
  1313. }
  1314. declare module BABYLON {
  1315. /** @ignore */
  1316. export class LoadFileError extends BaseError {
  1317. request?: WebRequest;
  1318. file?: File;
  1319. /**
  1320. * Creates a new LoadFileError
  1321. * @param message defines the message of the error
  1322. * @param request defines the optional web request
  1323. * @param file defines the optional file
  1324. */
  1325. constructor(message: string, object?: WebRequest | File);
  1326. }
  1327. /** @ignore */
  1328. export class RequestFileError extends BaseError {
  1329. request: WebRequest;
  1330. /**
  1331. * Creates a new LoadFileError
  1332. * @param message defines the message of the error
  1333. * @param request defines the optional web request
  1334. */
  1335. constructor(message: string, request: WebRequest);
  1336. }
  1337. /** @ignore */
  1338. export class ReadFileError extends BaseError {
  1339. file: File;
  1340. /**
  1341. * Creates a new ReadFileError
  1342. * @param message defines the message of the error
  1343. * @param file defines the optional file
  1344. */
  1345. constructor(message: string, file: File);
  1346. }
  1347. /**
  1348. * @hidden
  1349. */
  1350. export class FileTools {
  1351. /**
  1352. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1353. */
  1354. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1355. /**
  1356. * Gets or sets the base URL to use to load assets
  1357. */
  1358. static BaseUrl: string;
  1359. /**
  1360. * Default behaviour for cors in the application.
  1361. * It can be a string if the expected behavior is identical in the entire app.
  1362. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1363. */
  1364. static CorsBehavior: string | ((url: string | string[]) => string);
  1365. /**
  1366. * Gets or sets a function used to pre-process url before using them to load assets
  1367. */
  1368. static PreprocessUrl: (url: string) => string;
  1369. /**
  1370. * Removes unwanted characters from an url
  1371. * @param url defines the url to clean
  1372. * @returns the cleaned url
  1373. */
  1374. private static _CleanUrl;
  1375. /**
  1376. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1377. * @param url define the url we are trying
  1378. * @param element define the dom element where to configure the cors policy
  1379. */
  1380. static SetCorsBehavior(url: string | string[], element: {
  1381. crossOrigin: string | null;
  1382. }): void;
  1383. /**
  1384. * Loads an image as an HTMLImageElement.
  1385. * @param input url string, ArrayBuffer, or Blob to load
  1386. * @param onLoad callback called when the image successfully loads
  1387. * @param onError callback called when the image fails to load
  1388. * @param offlineProvider offline provider for caching
  1389. * @param mimeType optional mime type
  1390. * @returns the HTMLImageElement of the loaded image
  1391. */
  1392. 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>;
  1393. /**
  1394. * Reads a file from a File object
  1395. * @param file defines the file to load
  1396. * @param onSuccess defines the callback to call when data is loaded
  1397. * @param onProgress defines the callback to call during loading process
  1398. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1399. * @param onError defines the callback to call when an error occurs
  1400. * @returns a file request object
  1401. */
  1402. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1403. /**
  1404. * Loads a file from a url
  1405. * @param url url to load
  1406. * @param onSuccess callback called when the file successfully loads
  1407. * @param onProgress callback called while file is loading (if the server supports this mode)
  1408. * @param offlineProvider defines the offline provider for caching
  1409. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1410. * @param onError callback called when the file fails to load
  1411. * @returns a file request object
  1412. */
  1413. 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;
  1414. /**
  1415. * Loads a file
  1416. * @param url url to load
  1417. * @param onSuccess callback called when the file successfully loads
  1418. * @param onProgress callback called while file is loading (if the server supports this mode)
  1419. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1420. * @param onError callback called when the file fails to load
  1421. * @param onOpened callback called when the web request is opened
  1422. * @returns a file request object
  1423. */
  1424. 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;
  1425. /**
  1426. * Checks if the loaded document was accessed via `file:`-Protocol.
  1427. * @returns boolean
  1428. */
  1429. static IsFileURL(): boolean;
  1430. }
  1431. }
  1432. declare module BABYLON {
  1433. /** @hidden */
  1434. export class ShaderProcessor {
  1435. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1436. private static _ProcessPrecision;
  1437. private static _ExtractOperation;
  1438. private static _BuildSubExpression;
  1439. private static _BuildExpression;
  1440. private static _MoveCursorWithinIf;
  1441. private static _MoveCursor;
  1442. private static _EvaluatePreProcessors;
  1443. private static _PreparePreProcessors;
  1444. private static _ProcessShaderConversion;
  1445. private static _ProcessIncludes;
  1446. /**
  1447. * Loads a file from a url
  1448. * @param url url to load
  1449. * @param onSuccess callback called when the file successfully loads
  1450. * @param onProgress callback called while file is loading (if the server supports this mode)
  1451. * @param offlineProvider defines the offline provider for caching
  1452. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1453. * @param onError callback called when the file fails to load
  1454. * @returns a file request object
  1455. * @hidden
  1456. */
  1457. 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;
  1458. }
  1459. }
  1460. declare module BABYLON {
  1461. /**
  1462. * @hidden
  1463. */
  1464. export interface IColor4Like {
  1465. r: float;
  1466. g: float;
  1467. b: float;
  1468. a: float;
  1469. }
  1470. /**
  1471. * @hidden
  1472. */
  1473. export interface IColor3Like {
  1474. r: float;
  1475. g: float;
  1476. b: float;
  1477. }
  1478. /**
  1479. * @hidden
  1480. */
  1481. export interface IVector4Like {
  1482. x: float;
  1483. y: float;
  1484. z: float;
  1485. w: float;
  1486. }
  1487. /**
  1488. * @hidden
  1489. */
  1490. export interface IVector3Like {
  1491. x: float;
  1492. y: float;
  1493. z: float;
  1494. }
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IVector2Like {
  1499. x: float;
  1500. y: float;
  1501. }
  1502. /**
  1503. * @hidden
  1504. */
  1505. export interface IMatrixLike {
  1506. toArray(): DeepImmutable<Float32Array>;
  1507. updateFlag: int;
  1508. }
  1509. /**
  1510. * @hidden
  1511. */
  1512. export interface IViewportLike {
  1513. x: float;
  1514. y: float;
  1515. width: float;
  1516. height: float;
  1517. }
  1518. /**
  1519. * @hidden
  1520. */
  1521. export interface IPlaneLike {
  1522. normal: IVector3Like;
  1523. d: float;
  1524. normalize(): void;
  1525. }
  1526. }
  1527. declare module BABYLON {
  1528. /**
  1529. * Interface used to define common properties for effect fallbacks
  1530. */
  1531. export interface IEffectFallbacks {
  1532. /**
  1533. * Removes the defines that should be removed when falling back.
  1534. * @param currentDefines defines the current define statements for the shader.
  1535. * @param effect defines the current effect we try to compile
  1536. * @returns The resulting defines with defines of the current rank removed.
  1537. */
  1538. reduce(currentDefines: string, effect: Effect): string;
  1539. /**
  1540. * Removes the fallback from the bound mesh.
  1541. */
  1542. unBindMesh(): void;
  1543. /**
  1544. * Checks to see if more fallbacks are still availible.
  1545. */
  1546. hasMoreFallbacks: boolean;
  1547. }
  1548. }
  1549. declare module BABYLON {
  1550. /**
  1551. * Class used to evalaute queries containing `and` and `or` operators
  1552. */
  1553. export class AndOrNotEvaluator {
  1554. /**
  1555. * Evaluate a query
  1556. * @param query defines the query to evaluate
  1557. * @param evaluateCallback defines the callback used to filter result
  1558. * @returns true if the query matches
  1559. */
  1560. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1561. private static _HandleParenthesisContent;
  1562. private static _SimplifyNegation;
  1563. }
  1564. }
  1565. declare module BABYLON {
  1566. /**
  1567. * Class used to store custom tags
  1568. */
  1569. export class Tags {
  1570. /**
  1571. * Adds support for tags on the given object
  1572. * @param obj defines the object to use
  1573. */
  1574. static EnableFor(obj: any): void;
  1575. /**
  1576. * Removes tags support
  1577. * @param obj defines the object to use
  1578. */
  1579. static DisableFor(obj: any): void;
  1580. /**
  1581. * Gets a boolean indicating if the given object has tags
  1582. * @param obj defines the object to use
  1583. * @returns a boolean
  1584. */
  1585. static HasTags(obj: any): boolean;
  1586. /**
  1587. * Gets the tags available on a given object
  1588. * @param obj defines the object to use
  1589. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1590. * @returns the tags
  1591. */
  1592. static GetTags(obj: any, asString?: boolean): any;
  1593. /**
  1594. * Adds tags to an object
  1595. * @param obj defines the object to use
  1596. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1597. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1598. */
  1599. static AddTagsTo(obj: any, tagsString: string): void;
  1600. /**
  1601. * @hidden
  1602. */
  1603. static _AddTagTo(obj: any, tag: string): void;
  1604. /**
  1605. * Removes specific tags from a specific object
  1606. * @param obj defines the object to use
  1607. * @param tagsString defines the tags to remove
  1608. */
  1609. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1610. /**
  1611. * @hidden
  1612. */
  1613. static _RemoveTagFrom(obj: any, tag: string): void;
  1614. /**
  1615. * Defines if tags hosted on an object match a given query
  1616. * @param obj defines the object to use
  1617. * @param tagsQuery defines the tag query
  1618. * @returns a boolean
  1619. */
  1620. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1621. }
  1622. }
  1623. declare module BABYLON {
  1624. /**
  1625. * Scalar computation library
  1626. */
  1627. export class Scalar {
  1628. /**
  1629. * Two pi constants convenient for computation.
  1630. */
  1631. static TwoPi: number;
  1632. /**
  1633. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1634. * @param a number
  1635. * @param b number
  1636. * @param epsilon (default = 1.401298E-45)
  1637. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1638. */
  1639. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1640. /**
  1641. * Returns a string : the upper case translation of the number i to hexadecimal.
  1642. * @param i number
  1643. * @returns the upper case translation of the number i to hexadecimal.
  1644. */
  1645. static ToHex(i: number): string;
  1646. /**
  1647. * Returns -1 if value is negative and +1 is value is positive.
  1648. * @param value the value
  1649. * @returns the value itself if it's equal to zero.
  1650. */
  1651. static Sign(value: number): number;
  1652. /**
  1653. * Returns the value itself if it's between min and max.
  1654. * Returns min if the value is lower than min.
  1655. * Returns max if the value is greater than max.
  1656. * @param value the value to clmap
  1657. * @param min the min value to clamp to (default: 0)
  1658. * @param max the max value to clamp to (default: 1)
  1659. * @returns the clamped value
  1660. */
  1661. static Clamp(value: number, min?: number, max?: number): number;
  1662. /**
  1663. * the log2 of value.
  1664. * @param value the value to compute log2 of
  1665. * @returns the log2 of value.
  1666. */
  1667. static Log2(value: number): number;
  1668. /**
  1669. * Loops the value, so that it is never larger than length and never smaller than 0.
  1670. *
  1671. * This is similar to the modulo operator but it works with floating point numbers.
  1672. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1673. * With t = 5 and length = 2.5, the result would be 0.0.
  1674. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1675. * @param value the value
  1676. * @param length the length
  1677. * @returns the looped value
  1678. */
  1679. static Repeat(value: number, length: number): number;
  1680. /**
  1681. * Normalize the value between 0.0 and 1.0 using min and max values
  1682. * @param value value to normalize
  1683. * @param min max to normalize between
  1684. * @param max min to normalize between
  1685. * @returns the normalized value
  1686. */
  1687. static Normalize(value: number, min: number, max: number): number;
  1688. /**
  1689. * Denormalize the value from 0.0 and 1.0 using min and max values
  1690. * @param normalized value to denormalize
  1691. * @param min max to denormalize between
  1692. * @param max min to denormalize between
  1693. * @returns the denormalized value
  1694. */
  1695. static Denormalize(normalized: number, min: number, max: number): number;
  1696. /**
  1697. * Calculates the shortest difference between two given angles given in degrees.
  1698. * @param current current angle in degrees
  1699. * @param target target angle in degrees
  1700. * @returns the delta
  1701. */
  1702. static DeltaAngle(current: number, target: number): number;
  1703. /**
  1704. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1705. * @param tx value
  1706. * @param length length
  1707. * @returns The returned value will move back and forth between 0 and length
  1708. */
  1709. static PingPong(tx: number, length: number): number;
  1710. /**
  1711. * Interpolates between min and max with smoothing at the limits.
  1712. *
  1713. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1714. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1715. * @param from from
  1716. * @param to to
  1717. * @param tx value
  1718. * @returns the smooth stepped value
  1719. */
  1720. static SmoothStep(from: number, to: number, tx: number): number;
  1721. /**
  1722. * Moves a value current towards target.
  1723. *
  1724. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1725. * Negative values of maxDelta pushes the value away from target.
  1726. * @param current current value
  1727. * @param target target value
  1728. * @param maxDelta max distance to move
  1729. * @returns resulting value
  1730. */
  1731. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1732. /**
  1733. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1734. *
  1735. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1736. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1737. * @param current current value
  1738. * @param target target value
  1739. * @param maxDelta max distance to move
  1740. * @returns resulting angle
  1741. */
  1742. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1743. /**
  1744. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1745. * @param start start value
  1746. * @param end target value
  1747. * @param amount amount to lerp between
  1748. * @returns the lerped value
  1749. */
  1750. static Lerp(start: number, end: number, amount: number): number;
  1751. /**
  1752. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1753. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  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 LerpAngle(start: number, end: number, amount: number): number;
  1760. /**
  1761. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1762. * @param a start value
  1763. * @param b target value
  1764. * @param value value between a and b
  1765. * @returns the inverseLerp value
  1766. */
  1767. static InverseLerp(a: number, b: number, value: number): number;
  1768. /**
  1769. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1770. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1771. * @param value1 spline value
  1772. * @param tangent1 spline value
  1773. * @param value2 spline value
  1774. * @param tangent2 spline value
  1775. * @param amount input value
  1776. * @returns hermite result
  1777. */
  1778. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1779. /**
  1780. * Returns a random float number between and min and max values
  1781. * @param min min value of random
  1782. * @param max max value of random
  1783. * @returns random value
  1784. */
  1785. static RandomRange(min: number, max: number): number;
  1786. /**
  1787. * This function returns percentage of a number in a given range.
  1788. *
  1789. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1790. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1791. * @param number to convert to percentage
  1792. * @param min min range
  1793. * @param max max range
  1794. * @returns the percentage
  1795. */
  1796. static RangeToPercent(number: number, min: number, max: number): number;
  1797. /**
  1798. * This function returns number that corresponds to the percentage in a given range.
  1799. *
  1800. * PercentToRange(0.34,0,100) will return 34.
  1801. * @param percent to convert to number
  1802. * @param min min range
  1803. * @param max max range
  1804. * @returns the number
  1805. */
  1806. static PercentToRange(percent: number, min: number, max: number): number;
  1807. /**
  1808. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1809. * @param angle The angle to normalize in radian.
  1810. * @return The converted angle.
  1811. */
  1812. static NormalizeRadians(angle: number): number;
  1813. }
  1814. }
  1815. declare module BABYLON {
  1816. /**
  1817. * Constant used to convert a value to gamma space
  1818. * @ignorenaming
  1819. */
  1820. export const ToGammaSpace: number;
  1821. /**
  1822. * Constant used to convert a value to linear space
  1823. * @ignorenaming
  1824. */
  1825. export const ToLinearSpace = 2.2;
  1826. /**
  1827. * Constant used to define the minimal number value in Babylon.js
  1828. * @ignorenaming
  1829. */
  1830. let Epsilon: number;
  1831. }
  1832. declare module BABYLON {
  1833. /**
  1834. * Class used to represent a viewport on screen
  1835. */
  1836. export class Viewport {
  1837. /** viewport left coordinate */
  1838. x: number;
  1839. /** viewport top coordinate */
  1840. y: number;
  1841. /**viewport width */
  1842. width: number;
  1843. /** viewport height */
  1844. height: number;
  1845. /**
  1846. * Creates a Viewport object located at (x, y) and sized (width, height)
  1847. * @param x defines viewport left coordinate
  1848. * @param y defines viewport top coordinate
  1849. * @param width defines the viewport width
  1850. * @param height defines the viewport height
  1851. */
  1852. constructor(
  1853. /** viewport left coordinate */
  1854. x: number,
  1855. /** viewport top coordinate */
  1856. y: number,
  1857. /**viewport width */
  1858. width: number,
  1859. /** viewport height */
  1860. height: number);
  1861. /**
  1862. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1863. * @param renderWidth defines the rendering width
  1864. * @param renderHeight defines the rendering height
  1865. * @returns a new Viewport
  1866. */
  1867. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1868. /**
  1869. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1870. * @param renderWidth defines the rendering width
  1871. * @param renderHeight defines the rendering height
  1872. * @param ref defines the target viewport
  1873. * @returns the current viewport
  1874. */
  1875. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1876. /**
  1877. * Returns a new Viewport copied from the current one
  1878. * @returns a new Viewport
  1879. */
  1880. clone(): Viewport;
  1881. }
  1882. }
  1883. declare module BABYLON {
  1884. /**
  1885. * Class containing a set of static utilities functions for arrays.
  1886. */
  1887. export class ArrayTools {
  1888. /**
  1889. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1890. * @param size the number of element to construct and put in the array
  1891. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1892. * @returns a new array filled with new objects
  1893. */
  1894. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1895. }
  1896. }
  1897. declare module BABYLON {
  1898. /**
  1899. * Class representing a vector containing 2 coordinates
  1900. */
  1901. export class Vector2 {
  1902. /** defines the first coordinate */
  1903. x: number;
  1904. /** defines the second coordinate */
  1905. y: number;
  1906. /**
  1907. * Creates a new Vector2 from the given x and y coordinates
  1908. * @param x defines the first coordinate
  1909. * @param y defines the second coordinate
  1910. */
  1911. constructor(
  1912. /** defines the first coordinate */
  1913. x?: number,
  1914. /** defines the second coordinate */
  1915. y?: number);
  1916. /**
  1917. * Gets a string with the Vector2 coordinates
  1918. * @returns a string with the Vector2 coordinates
  1919. */
  1920. toString(): string;
  1921. /**
  1922. * Gets class name
  1923. * @returns the string "Vector2"
  1924. */
  1925. getClassName(): string;
  1926. /**
  1927. * Gets current vector hash code
  1928. * @returns the Vector2 hash code as a number
  1929. */
  1930. getHashCode(): number;
  1931. /**
  1932. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1933. * @param array defines the source array
  1934. * @param index defines the offset in source array
  1935. * @returns the current Vector2
  1936. */
  1937. toArray(array: FloatArray, index?: number): Vector2;
  1938. /**
  1939. * Copy the current vector to an array
  1940. * @returns a new array with 2 elements: the Vector2 coordinates.
  1941. */
  1942. asArray(): number[];
  1943. /**
  1944. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1945. * @param source defines the source Vector2
  1946. * @returns the current updated Vector2
  1947. */
  1948. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1949. /**
  1950. * Sets the Vector2 coordinates with the given floats
  1951. * @param x defines the first coordinate
  1952. * @param y defines the second coordinate
  1953. * @returns the current updated Vector2
  1954. */
  1955. copyFromFloats(x: number, y: number): Vector2;
  1956. /**
  1957. * Sets the Vector2 coordinates with the given floats
  1958. * @param x defines the first coordinate
  1959. * @param y defines the second coordinate
  1960. * @returns the current updated Vector2
  1961. */
  1962. set(x: number, y: number): Vector2;
  1963. /**
  1964. * Add another vector with the current one
  1965. * @param otherVector defines the other vector
  1966. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1967. */
  1968. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1969. /**
  1970. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1971. * @param otherVector defines the other vector
  1972. * @param result defines the target vector
  1973. * @returns the unmodified current Vector2
  1974. */
  1975. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1976. /**
  1977. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1978. * @param otherVector defines the other vector
  1979. * @returns the current updated Vector2
  1980. */
  1981. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1982. /**
  1983. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1984. * @param otherVector defines the other vector
  1985. * @returns a new Vector2
  1986. */
  1987. addVector3(otherVector: Vector3): Vector2;
  1988. /**
  1989. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1990. * @param otherVector defines the other vector
  1991. * @returns a new Vector2
  1992. */
  1993. subtract(otherVector: Vector2): Vector2;
  1994. /**
  1995. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1996. * @param otherVector defines the other vector
  1997. * @param result defines the target vector
  1998. * @returns the unmodified current Vector2
  1999. */
  2000. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2001. /**
  2002. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2003. * @param otherVector defines the other vector
  2004. * @returns the current updated Vector2
  2005. */
  2006. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2007. /**
  2008. * Multiplies in place the current Vector2 coordinates by the given ones
  2009. * @param otherVector defines the other vector
  2010. * @returns the current updated Vector2
  2011. */
  2012. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2013. /**
  2014. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2015. * @param otherVector defines the other vector
  2016. * @returns a new Vector2
  2017. */
  2018. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2019. /**
  2020. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2021. * @param otherVector defines the other vector
  2022. * @param result defines the target vector
  2023. * @returns the unmodified current Vector2
  2024. */
  2025. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2026. /**
  2027. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2028. * @param x defines the first coordinate
  2029. * @param y defines the second coordinate
  2030. * @returns a new Vector2
  2031. */
  2032. multiplyByFloats(x: number, y: number): Vector2;
  2033. /**
  2034. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2035. * @param otherVector defines the other vector
  2036. * @returns a new Vector2
  2037. */
  2038. divide(otherVector: Vector2): Vector2;
  2039. /**
  2040. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2041. * @param otherVector defines the other vector
  2042. * @param result defines the target vector
  2043. * @returns the unmodified current Vector2
  2044. */
  2045. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2046. /**
  2047. * Divides the current Vector2 coordinates by the given ones
  2048. * @param otherVector defines the other vector
  2049. * @returns the current updated Vector2
  2050. */
  2051. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2052. /**
  2053. * Gets a new Vector2 with current Vector2 negated coordinates
  2054. * @returns a new Vector2
  2055. */
  2056. negate(): Vector2;
  2057. /**
  2058. * Negate this vector in place
  2059. * @returns this
  2060. */
  2061. negateInPlace(): Vector2;
  2062. /**
  2063. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2064. * @param result defines the Vector3 object where to store the result
  2065. * @returns the current Vector2
  2066. */
  2067. negateToRef(result: Vector2): Vector2;
  2068. /**
  2069. * Multiply the Vector2 coordinates by scale
  2070. * @param scale defines the scaling factor
  2071. * @returns the current updated Vector2
  2072. */
  2073. scaleInPlace(scale: number): Vector2;
  2074. /**
  2075. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2076. * @param scale defines the scaling factor
  2077. * @returns a new Vector2
  2078. */
  2079. scale(scale: number): Vector2;
  2080. /**
  2081. * Scale the current Vector2 values by a factor to a given Vector2
  2082. * @param scale defines the scale factor
  2083. * @param result defines the Vector2 object where to store the result
  2084. * @returns the unmodified current Vector2
  2085. */
  2086. scaleToRef(scale: number, result: Vector2): Vector2;
  2087. /**
  2088. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2089. * @param scale defines the scale factor
  2090. * @param result defines the Vector2 object where to store the result
  2091. * @returns the unmodified current Vector2
  2092. */
  2093. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2094. /**
  2095. * Gets a boolean if two vectors are equals
  2096. * @param otherVector defines the other vector
  2097. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2098. */
  2099. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2100. /**
  2101. * Gets a boolean if two vectors are equals (using an epsilon value)
  2102. * @param otherVector defines the other vector
  2103. * @param epsilon defines the minimal distance to consider equality
  2104. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2105. */
  2106. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2107. /**
  2108. * Gets a new Vector2 from current Vector2 floored values
  2109. * @returns a new Vector2
  2110. */
  2111. floor(): Vector2;
  2112. /**
  2113. * Gets a new Vector2 from current Vector2 floored values
  2114. * @returns a new Vector2
  2115. */
  2116. fract(): Vector2;
  2117. /**
  2118. * Gets the length of the vector
  2119. * @returns the vector length (float)
  2120. */
  2121. length(): number;
  2122. /**
  2123. * Gets the vector squared length
  2124. * @returns the vector squared length (float)
  2125. */
  2126. lengthSquared(): number;
  2127. /**
  2128. * Normalize the vector
  2129. * @returns the current updated Vector2
  2130. */
  2131. normalize(): Vector2;
  2132. /**
  2133. * Gets a new Vector2 copied from the Vector2
  2134. * @returns a new Vector2
  2135. */
  2136. clone(): Vector2;
  2137. /**
  2138. * Gets a new Vector2(0, 0)
  2139. * @returns a new Vector2
  2140. */
  2141. static Zero(): Vector2;
  2142. /**
  2143. * Gets a new Vector2(1, 1)
  2144. * @returns a new Vector2
  2145. */
  2146. static One(): Vector2;
  2147. /**
  2148. * Gets a new Vector2 set from the given index element of the given array
  2149. * @param array defines the data source
  2150. * @param offset defines the offset in the data source
  2151. * @returns a new Vector2
  2152. */
  2153. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2154. /**
  2155. * Sets "result" from the given index element of the given array
  2156. * @param array defines the data source
  2157. * @param offset defines the offset in the data source
  2158. * @param result defines the target vector
  2159. */
  2160. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2161. /**
  2162. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2163. * @param value1 defines 1st point of control
  2164. * @param value2 defines 2nd point of control
  2165. * @param value3 defines 3rd point of control
  2166. * @param value4 defines 4th point of control
  2167. * @param amount defines the interpolation factor
  2168. * @returns a new Vector2
  2169. */
  2170. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2171. /**
  2172. * 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".
  2173. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2174. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2175. * @param value defines the value to clamp
  2176. * @param min defines the lower limit
  2177. * @param max defines the upper limit
  2178. * @returns a new Vector2
  2179. */
  2180. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2181. /**
  2182. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2183. * @param value1 defines the 1st control point
  2184. * @param tangent1 defines the outgoing tangent
  2185. * @param value2 defines the 2nd control point
  2186. * @param tangent2 defines the incoming tangent
  2187. * @param amount defines the interpolation factor
  2188. * @returns a new Vector2
  2189. */
  2190. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2191. /**
  2192. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2193. * @param start defines the start vector
  2194. * @param end defines the end vector
  2195. * @param amount defines the interpolation factor
  2196. * @returns a new Vector2
  2197. */
  2198. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2199. /**
  2200. * Gets the dot product of the vector "left" and the vector "right"
  2201. * @param left defines first vector
  2202. * @param right defines second vector
  2203. * @returns the dot product (float)
  2204. */
  2205. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2206. /**
  2207. * Returns a new Vector2 equal to the normalized given vector
  2208. * @param vector defines the vector to normalize
  2209. * @returns a new Vector2
  2210. */
  2211. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2212. /**
  2213. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2214. * @param left defines 1st vector
  2215. * @param right defines 2nd vector
  2216. * @returns a new Vector2
  2217. */
  2218. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2219. /**
  2220. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2221. * @param left defines 1st vector
  2222. * @param right defines 2nd vector
  2223. * @returns a new Vector2
  2224. */
  2225. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2226. /**
  2227. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2228. * @param vector defines the vector to transform
  2229. * @param transformation defines the matrix to apply
  2230. * @returns a new Vector2
  2231. */
  2232. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2233. /**
  2234. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2235. * @param vector defines the vector to transform
  2236. * @param transformation defines the matrix to apply
  2237. * @param result defines the target vector
  2238. */
  2239. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2240. /**
  2241. * Determines if a given vector is included in a triangle
  2242. * @param p defines the vector to test
  2243. * @param p0 defines 1st triangle point
  2244. * @param p1 defines 2nd triangle point
  2245. * @param p2 defines 3rd triangle point
  2246. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2247. */
  2248. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2249. /**
  2250. * Gets the distance between the vectors "value1" and "value2"
  2251. * @param value1 defines first vector
  2252. * @param value2 defines second vector
  2253. * @returns the distance between vectors
  2254. */
  2255. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2256. /**
  2257. * Returns the squared distance between the vectors "value1" and "value2"
  2258. * @param value1 defines first vector
  2259. * @param value2 defines second vector
  2260. * @returns the squared distance between vectors
  2261. */
  2262. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2263. /**
  2264. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2265. * @param value1 defines first vector
  2266. * @param value2 defines second vector
  2267. * @returns a new Vector2
  2268. */
  2269. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2270. /**
  2271. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2272. * @param p defines the middle point
  2273. * @param segA defines one point of the segment
  2274. * @param segB defines the other point of the segment
  2275. * @returns the shortest distance
  2276. */
  2277. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2278. }
  2279. /**
  2280. * Class used to store (x,y,z) vector representation
  2281. * A Vector3 is the main object used in 3D geometry
  2282. * It can represent etiher the coordinates of a point the space, either a direction
  2283. * Reminder: js uses a left handed forward facing system
  2284. */
  2285. export class Vector3 {
  2286. /**
  2287. * Defines the first coordinates (on X axis)
  2288. */
  2289. x: number;
  2290. /**
  2291. * Defines the second coordinates (on Y axis)
  2292. */
  2293. y: number;
  2294. /**
  2295. * Defines the third coordinates (on Z axis)
  2296. */
  2297. z: number;
  2298. private static _UpReadOnly;
  2299. private static _ZeroReadOnly;
  2300. /**
  2301. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2302. * @param x defines the first coordinates (on X axis)
  2303. * @param y defines the second coordinates (on Y axis)
  2304. * @param z defines the third coordinates (on Z axis)
  2305. */
  2306. constructor(
  2307. /**
  2308. * Defines the first coordinates (on X axis)
  2309. */
  2310. x?: number,
  2311. /**
  2312. * Defines the second coordinates (on Y axis)
  2313. */
  2314. y?: number,
  2315. /**
  2316. * Defines the third coordinates (on Z axis)
  2317. */
  2318. z?: number);
  2319. /**
  2320. * Creates a string representation of the Vector3
  2321. * @returns a string with the Vector3 coordinates.
  2322. */
  2323. toString(): string;
  2324. /**
  2325. * Gets the class name
  2326. * @returns the string "Vector3"
  2327. */
  2328. getClassName(): string;
  2329. /**
  2330. * Creates the Vector3 hash code
  2331. * @returns a number which tends to be unique between Vector3 instances
  2332. */
  2333. getHashCode(): number;
  2334. /**
  2335. * Creates an array containing three elements : the coordinates of the Vector3
  2336. * @returns a new array of numbers
  2337. */
  2338. asArray(): number[];
  2339. /**
  2340. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2341. * @param array defines the destination array
  2342. * @param index defines the offset in the destination array
  2343. * @returns the current Vector3
  2344. */
  2345. toArray(array: FloatArray, index?: number): Vector3;
  2346. /**
  2347. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2348. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2349. */
  2350. toQuaternion(): Quaternion;
  2351. /**
  2352. * Adds the given vector to the current Vector3
  2353. * @param otherVector defines the second operand
  2354. * @returns the current updated Vector3
  2355. */
  2356. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2357. /**
  2358. * Adds the given coordinates to the current Vector3
  2359. * @param x defines the x coordinate of the operand
  2360. * @param y defines the y coordinate of the operand
  2361. * @param z defines the z coordinate of the operand
  2362. * @returns the current updated Vector3
  2363. */
  2364. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2365. /**
  2366. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2367. * @param otherVector defines the second operand
  2368. * @returns the resulting Vector3
  2369. */
  2370. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2371. /**
  2372. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2373. * @param otherVector defines the second operand
  2374. * @param result defines the Vector3 object where to store the result
  2375. * @returns the current Vector3
  2376. */
  2377. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2378. /**
  2379. * Subtract the given vector from the current Vector3
  2380. * @param otherVector defines the second operand
  2381. * @returns the current updated Vector3
  2382. */
  2383. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2384. /**
  2385. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2386. * @param otherVector defines the second operand
  2387. * @returns the resulting Vector3
  2388. */
  2389. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2390. /**
  2391. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2392. * @param otherVector defines the second operand
  2393. * @param result defines the Vector3 object where to store the result
  2394. * @returns the current Vector3
  2395. */
  2396. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2397. /**
  2398. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2399. * @param x defines the x coordinate of the operand
  2400. * @param y defines the y coordinate of the operand
  2401. * @param z defines the z coordinate of the operand
  2402. * @returns the resulting Vector3
  2403. */
  2404. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2405. /**
  2406. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2407. * @param x defines the x coordinate of the operand
  2408. * @param y defines the y coordinate of the operand
  2409. * @param z defines the z coordinate of the operand
  2410. * @param result defines the Vector3 object where to store the result
  2411. * @returns the current Vector3
  2412. */
  2413. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2414. /**
  2415. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2416. * @returns a new Vector3
  2417. */
  2418. negate(): Vector3;
  2419. /**
  2420. * Negate this vector in place
  2421. * @returns this
  2422. */
  2423. negateInPlace(): Vector3;
  2424. /**
  2425. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2426. * @param result defines the Vector3 object where to store the result
  2427. * @returns the current Vector3
  2428. */
  2429. negateToRef(result: Vector3): Vector3;
  2430. /**
  2431. * Multiplies the Vector3 coordinates by the float "scale"
  2432. * @param scale defines the multiplier factor
  2433. * @returns the current updated Vector3
  2434. */
  2435. scaleInPlace(scale: number): Vector3;
  2436. /**
  2437. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2438. * @param scale defines the multiplier factor
  2439. * @returns a new Vector3
  2440. */
  2441. scale(scale: number): Vector3;
  2442. /**
  2443. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2444. * @param scale defines the multiplier factor
  2445. * @param result defines the Vector3 object where to store the result
  2446. * @returns the current Vector3
  2447. */
  2448. scaleToRef(scale: number, result: Vector3): Vector3;
  2449. /**
  2450. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2451. * @param scale defines the scale factor
  2452. * @param result defines the Vector3 object where to store the result
  2453. * @returns the unmodified current Vector3
  2454. */
  2455. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2456. /**
  2457. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2458. * @param otherVector defines the second operand
  2459. * @returns true if both vectors are equals
  2460. */
  2461. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2462. /**
  2463. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2464. * @param otherVector defines the second operand
  2465. * @param epsilon defines the minimal distance to define values as equals
  2466. * @returns true if both vectors are distant less than epsilon
  2467. */
  2468. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2469. /**
  2470. * Returns true if the current Vector3 coordinates equals the given floats
  2471. * @param x defines the x coordinate of the operand
  2472. * @param y defines the y coordinate of the operand
  2473. * @param z defines the z coordinate of the operand
  2474. * @returns true if both vectors are equals
  2475. */
  2476. equalsToFloats(x: number, y: number, z: number): boolean;
  2477. /**
  2478. * Multiplies the current Vector3 coordinates by the given ones
  2479. * @param otherVector defines the second operand
  2480. * @returns the current updated Vector3
  2481. */
  2482. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2483. /**
  2484. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2485. * @param otherVector defines the second operand
  2486. * @returns the new Vector3
  2487. */
  2488. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2489. /**
  2490. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2491. * @param otherVector defines the second operand
  2492. * @param result defines the Vector3 object where to store the result
  2493. * @returns the current Vector3
  2494. */
  2495. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2496. /**
  2497. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2498. * @param x defines the x coordinate of the operand
  2499. * @param y defines the y coordinate of the operand
  2500. * @param z defines the z coordinate of the operand
  2501. * @returns the new Vector3
  2502. */
  2503. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2504. /**
  2505. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2506. * @param otherVector defines the second operand
  2507. * @returns the new Vector3
  2508. */
  2509. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2510. /**
  2511. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2512. * @param otherVector defines the second operand
  2513. * @param result defines the Vector3 object where to store the result
  2514. * @returns the current Vector3
  2515. */
  2516. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2517. /**
  2518. * Divides the current Vector3 coordinates by the given ones.
  2519. * @param otherVector defines the second operand
  2520. * @returns the current updated Vector3
  2521. */
  2522. divideInPlace(otherVector: Vector3): Vector3;
  2523. /**
  2524. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2525. * @param other defines the second operand
  2526. * @returns the current updated Vector3
  2527. */
  2528. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2529. /**
  2530. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2531. * @param other defines the second operand
  2532. * @returns the current updated Vector3
  2533. */
  2534. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2535. /**
  2536. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2537. * @param x defines the x coordinate of the operand
  2538. * @param y defines the y coordinate of the operand
  2539. * @param z defines the z coordinate of the operand
  2540. * @returns the current updated Vector3
  2541. */
  2542. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2543. /**
  2544. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2545. * @param x defines the x coordinate of the operand
  2546. * @param y defines the y coordinate of the operand
  2547. * @param z defines the z coordinate of the operand
  2548. * @returns the current updated Vector3
  2549. */
  2550. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2551. /**
  2552. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2553. * Check if is non uniform within a certain amount of decimal places to account for this
  2554. * @param epsilon the amount the values can differ
  2555. * @returns if the the vector is non uniform to a certain number of decimal places
  2556. */
  2557. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2558. /**
  2559. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2560. */
  2561. get isNonUniform(): boolean;
  2562. /**
  2563. * Gets a new Vector3 from current Vector3 floored values
  2564. * @returns a new Vector3
  2565. */
  2566. floor(): Vector3;
  2567. /**
  2568. * Gets a new Vector3 from current Vector3 floored values
  2569. * @returns a new Vector3
  2570. */
  2571. fract(): Vector3;
  2572. /**
  2573. * Gets the length of the Vector3
  2574. * @returns the length of the Vector3
  2575. */
  2576. length(): number;
  2577. /**
  2578. * Gets the squared length of the Vector3
  2579. * @returns squared length of the Vector3
  2580. */
  2581. lengthSquared(): number;
  2582. /**
  2583. * Normalize the current Vector3.
  2584. * Please note that this is an in place operation.
  2585. * @returns the current updated Vector3
  2586. */
  2587. normalize(): Vector3;
  2588. /**
  2589. * Reorders the x y z properties of the vector in place
  2590. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2591. * @returns the current updated vector
  2592. */
  2593. reorderInPlace(order: string): this;
  2594. /**
  2595. * Rotates the vector around 0,0,0 by a quaternion
  2596. * @param quaternion the rotation quaternion
  2597. * @param result vector to store the result
  2598. * @returns the resulting vector
  2599. */
  2600. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2601. /**
  2602. * Rotates a vector around a given point
  2603. * @param quaternion the rotation quaternion
  2604. * @param point the point to rotate around
  2605. * @param result vector to store the result
  2606. * @returns the resulting vector
  2607. */
  2608. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2609. /**
  2610. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2611. * The cross product is then orthogonal to both current and "other"
  2612. * @param other defines the right operand
  2613. * @returns the cross product
  2614. */
  2615. cross(other: Vector3): Vector3;
  2616. /**
  2617. * Normalize the current Vector3 with the given input length.
  2618. * Please note that this is an in place operation.
  2619. * @param len the length of the vector
  2620. * @returns the current updated Vector3
  2621. */
  2622. normalizeFromLength(len: number): Vector3;
  2623. /**
  2624. * Normalize the current Vector3 to a new vector
  2625. * @returns the new Vector3
  2626. */
  2627. normalizeToNew(): Vector3;
  2628. /**
  2629. * Normalize the current Vector3 to the reference
  2630. * @param reference define the Vector3 to update
  2631. * @returns the updated Vector3
  2632. */
  2633. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2634. /**
  2635. * Creates a new Vector3 copied from the current Vector3
  2636. * @returns the new Vector3
  2637. */
  2638. clone(): Vector3;
  2639. /**
  2640. * Copies the given vector coordinates to the current Vector3 ones
  2641. * @param source defines the source Vector3
  2642. * @returns the current updated Vector3
  2643. */
  2644. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2645. /**
  2646. * Copies the given floats to the current Vector3 coordinates
  2647. * @param x defines the x coordinate of the operand
  2648. * @param y defines the y coordinate of the operand
  2649. * @param z defines the z coordinate of the operand
  2650. * @returns the current updated Vector3
  2651. */
  2652. copyFromFloats(x: number, y: number, z: number): Vector3;
  2653. /**
  2654. * Copies the given floats to the current Vector3 coordinates
  2655. * @param x defines the x coordinate of the operand
  2656. * @param y defines the y coordinate of the operand
  2657. * @param z defines the z coordinate of the operand
  2658. * @returns the current updated Vector3
  2659. */
  2660. set(x: number, y: number, z: number): Vector3;
  2661. /**
  2662. * Copies the given float to the current Vector3 coordinates
  2663. * @param v defines the x, y and z coordinates of the operand
  2664. * @returns the current updated Vector3
  2665. */
  2666. setAll(v: number): Vector3;
  2667. /**
  2668. * Get the clip factor between two vectors
  2669. * @param vector0 defines the first operand
  2670. * @param vector1 defines the second operand
  2671. * @param axis defines the axis to use
  2672. * @param size defines the size along the axis
  2673. * @returns the clip factor
  2674. */
  2675. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2676. /**
  2677. * Get angle between two vectors
  2678. * @param vector0 angle between vector0 and vector1
  2679. * @param vector1 angle between vector0 and vector1
  2680. * @param normal direction of the normal
  2681. * @return the angle between vector0 and vector1
  2682. */
  2683. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2684. /**
  2685. * Returns a new Vector3 set from the index "offset" of the given array
  2686. * @param array defines the source array
  2687. * @param offset defines the offset in the source array
  2688. * @returns the new Vector3
  2689. */
  2690. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2691. /**
  2692. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2693. * @param array defines the source array
  2694. * @param offset defines the offset in the source array
  2695. * @returns the new Vector3
  2696. * @deprecated Please use FromArray instead.
  2697. */
  2698. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2699. /**
  2700. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2701. * @param array defines the source array
  2702. * @param offset defines the offset in the source array
  2703. * @param result defines the Vector3 where to store the result
  2704. */
  2705. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2706. /**
  2707. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2708. * @param array defines the source array
  2709. * @param offset defines the offset in the source array
  2710. * @param result defines the Vector3 where to store the result
  2711. * @deprecated Please use FromArrayToRef instead.
  2712. */
  2713. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2714. /**
  2715. * Sets the given vector "result" with the given floats.
  2716. * @param x defines the x coordinate of the source
  2717. * @param y defines the y coordinate of the source
  2718. * @param z defines the z coordinate of the source
  2719. * @param result defines the Vector3 where to store the result
  2720. */
  2721. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2722. /**
  2723. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2724. * @returns a new empty Vector3
  2725. */
  2726. static Zero(): Vector3;
  2727. /**
  2728. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2729. * @returns a new unit Vector3
  2730. */
  2731. static One(): Vector3;
  2732. /**
  2733. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2734. * @returns a new up Vector3
  2735. */
  2736. static Up(): Vector3;
  2737. /**
  2738. * Gets a up Vector3 that must not be updated
  2739. */
  2740. static get UpReadOnly(): DeepImmutable<Vector3>;
  2741. /**
  2742. * Gets a zero Vector3 that must not be updated
  2743. */
  2744. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2745. /**
  2746. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2747. * @returns a new down Vector3
  2748. */
  2749. static Down(): Vector3;
  2750. /**
  2751. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2752. * @returns a new forward Vector3
  2753. */
  2754. static Forward(): Vector3;
  2755. /**
  2756. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2757. * @returns a new forward Vector3
  2758. */
  2759. static Backward(): Vector3;
  2760. /**
  2761. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2762. * @returns a new right Vector3
  2763. */
  2764. static Right(): Vector3;
  2765. /**
  2766. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2767. * @returns a new left Vector3
  2768. */
  2769. static Left(): Vector3;
  2770. /**
  2771. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2772. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2773. * @param vector defines the Vector3 to transform
  2774. * @param transformation defines the transformation matrix
  2775. * @returns the transformed Vector3
  2776. */
  2777. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2778. /**
  2779. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2780. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2781. * @param vector defines the Vector3 to transform
  2782. * @param transformation defines the transformation matrix
  2783. * @param result defines the Vector3 where to store the result
  2784. */
  2785. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2786. /**
  2787. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2788. * This method computes tranformed coordinates only, not transformed direction vectors
  2789. * @param x define the x coordinate of the source vector
  2790. * @param y define the y coordinate of the source vector
  2791. * @param z define the z coordinate of the source vector
  2792. * @param transformation defines the transformation matrix
  2793. * @param result defines the Vector3 where to store the result
  2794. */
  2795. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2796. /**
  2797. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2798. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2799. * @param vector defines the Vector3 to transform
  2800. * @param transformation defines the transformation matrix
  2801. * @returns the new Vector3
  2802. */
  2803. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2804. /**
  2805. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2806. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2807. * @param vector defines the Vector3 to transform
  2808. * @param transformation defines the transformation matrix
  2809. * @param result defines the Vector3 where to store the result
  2810. */
  2811. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2812. /**
  2813. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2814. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2815. * @param x define the x coordinate of the source vector
  2816. * @param y define the y coordinate of the source vector
  2817. * @param z define the z coordinate of the source vector
  2818. * @param transformation defines the transformation matrix
  2819. * @param result defines the Vector3 where to store the result
  2820. */
  2821. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2822. /**
  2823. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2824. * @param value1 defines the first control point
  2825. * @param value2 defines the second control point
  2826. * @param value3 defines the third control point
  2827. * @param value4 defines the fourth control point
  2828. * @param amount defines the amount on the spline to use
  2829. * @returns the new Vector3
  2830. */
  2831. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2832. /**
  2833. * 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"
  2834. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2835. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2836. * @param value defines the current value
  2837. * @param min defines the lower range value
  2838. * @param max defines the upper range value
  2839. * @returns the new Vector3
  2840. */
  2841. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2842. /**
  2843. * 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"
  2844. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2845. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2846. * @param value defines the current value
  2847. * @param min defines the lower range value
  2848. * @param max defines the upper range value
  2849. * @param result defines the Vector3 where to store the result
  2850. */
  2851. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2852. /**
  2853. * Checks if a given vector is inside a specific range
  2854. * @param v defines the vector to test
  2855. * @param min defines the minimum range
  2856. * @param max defines the maximum range
  2857. */
  2858. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2859. /**
  2860. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2861. * @param value1 defines the first control point
  2862. * @param tangent1 defines the first tangent vector
  2863. * @param value2 defines the second control point
  2864. * @param tangent2 defines the second tangent vector
  2865. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2866. * @returns the new Vector3
  2867. */
  2868. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2869. /**
  2870. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2871. * @param start defines the start value
  2872. * @param end defines the end value
  2873. * @param amount max defines amount between both (between 0 and 1)
  2874. * @returns the new Vector3
  2875. */
  2876. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2877. /**
  2878. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2879. * @param start defines the start value
  2880. * @param end defines the end value
  2881. * @param amount max defines amount between both (between 0 and 1)
  2882. * @param result defines the Vector3 where to store the result
  2883. */
  2884. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2885. /**
  2886. * Returns the dot product (float) between the vectors "left" and "right"
  2887. * @param left defines the left operand
  2888. * @param right defines the right operand
  2889. * @returns the dot product
  2890. */
  2891. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2892. /**
  2893. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2894. * The cross product is then orthogonal to both "left" and "right"
  2895. * @param left defines the left operand
  2896. * @param right defines the right operand
  2897. * @returns the cross product
  2898. */
  2899. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2900. /**
  2901. * Sets the given vector "result" with the cross product of "left" and "right"
  2902. * The cross product is then orthogonal to both "left" and "right"
  2903. * @param left defines the left operand
  2904. * @param right defines the right operand
  2905. * @param result defines the Vector3 where to store the result
  2906. */
  2907. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2908. /**
  2909. * Returns a new Vector3 as the normalization of the given vector
  2910. * @param vector defines the Vector3 to normalize
  2911. * @returns the new Vector3
  2912. */
  2913. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2914. /**
  2915. * Sets the given vector "result" with the normalization of the given first vector
  2916. * @param vector defines the Vector3 to normalize
  2917. * @param result defines the Vector3 where to store the result
  2918. */
  2919. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2920. /**
  2921. * Project a Vector3 onto screen space
  2922. * @param vector defines the Vector3 to project
  2923. * @param world defines the world matrix to use
  2924. * @param transform defines the transform (view x projection) matrix to use
  2925. * @param viewport defines the screen viewport to use
  2926. * @returns the new Vector3
  2927. */
  2928. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2929. /** @hidden */
  2930. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2931. /**
  2932. * Unproject from screen space to object space
  2933. * @param source defines the screen space Vector3 to use
  2934. * @param viewportWidth defines the current width of the viewport
  2935. * @param viewportHeight defines the current height of the viewport
  2936. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2937. * @param transform defines the transform (view x projection) matrix to use
  2938. * @returns the new Vector3
  2939. */
  2940. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2941. /**
  2942. * Unproject from screen space to object space
  2943. * @param source defines the screen space Vector3 to use
  2944. * @param viewportWidth defines the current width of the viewport
  2945. * @param viewportHeight defines the current height of the viewport
  2946. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2947. * @param view defines the view matrix to use
  2948. * @param projection defines the projection matrix to use
  2949. * @returns the new Vector3
  2950. */
  2951. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: 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. * @param result defines the Vector3 where to store the result
  2961. */
  2962. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2963. /**
  2964. * Unproject from screen space to object space
  2965. * @param sourceX defines the screen space x coordinate to use
  2966. * @param sourceY defines the screen space y coordinate to use
  2967. * @param sourceZ defines the screen space z coordinate to use
  2968. * @param viewportWidth defines the current width of the viewport
  2969. * @param viewportHeight defines the current height of the viewport
  2970. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2971. * @param view defines the view matrix to use
  2972. * @param projection defines the projection matrix to use
  2973. * @param result defines the Vector3 where to store the result
  2974. */
  2975. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2976. /**
  2977. * Gets the minimal coordinate values between two Vector3
  2978. * @param left defines the first operand
  2979. * @param right defines the second operand
  2980. * @returns the new Vector3
  2981. */
  2982. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2983. /**
  2984. * Gets the maximal coordinate values between two Vector3
  2985. * @param left defines the first operand
  2986. * @param right defines the second operand
  2987. * @returns the new Vector3
  2988. */
  2989. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2990. /**
  2991. * Returns the distance between the vectors "value1" and "value2"
  2992. * @param value1 defines the first operand
  2993. * @param value2 defines the second operand
  2994. * @returns the distance
  2995. */
  2996. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2997. /**
  2998. * Returns the squared distance between the vectors "value1" and "value2"
  2999. * @param value1 defines the first operand
  3000. * @param value2 defines the second operand
  3001. * @returns the squared distance
  3002. */
  3003. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3004. /**
  3005. * Returns a new Vector3 located at the center between "value1" and "value2"
  3006. * @param value1 defines the first operand
  3007. * @param value2 defines the second operand
  3008. * @returns the new Vector3
  3009. */
  3010. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3011. /**
  3012. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3013. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3014. * to something in order to rotate it from its local system to the given target system
  3015. * Note: axis1, axis2 and axis3 are normalized during this operation
  3016. * @param axis1 defines the first axis
  3017. * @param axis2 defines the second axis
  3018. * @param axis3 defines the third axis
  3019. * @returns a new Vector3
  3020. */
  3021. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3022. /**
  3023. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3024. * @param axis1 defines the first axis
  3025. * @param axis2 defines the second axis
  3026. * @param axis3 defines the third axis
  3027. * @param ref defines the Vector3 where to store the result
  3028. */
  3029. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3030. }
  3031. /**
  3032. * Vector4 class created for EulerAngle class conversion to Quaternion
  3033. */
  3034. export class Vector4 {
  3035. /** x value of the vector */
  3036. x: number;
  3037. /** y value of the vector */
  3038. y: number;
  3039. /** z value of the vector */
  3040. z: number;
  3041. /** w value of the vector */
  3042. w: number;
  3043. /**
  3044. * Creates a Vector4 object from the given floats.
  3045. * @param x x value of the vector
  3046. * @param y y value of the vector
  3047. * @param z z value of the vector
  3048. * @param w w value of the vector
  3049. */
  3050. constructor(
  3051. /** x value of the vector */
  3052. x: number,
  3053. /** y value of the vector */
  3054. y: number,
  3055. /** z value of the vector */
  3056. z: number,
  3057. /** w value of the vector */
  3058. w: number);
  3059. /**
  3060. * Returns the string with the Vector4 coordinates.
  3061. * @returns a string containing all the vector values
  3062. */
  3063. toString(): string;
  3064. /**
  3065. * Returns the string "Vector4".
  3066. * @returns "Vector4"
  3067. */
  3068. getClassName(): string;
  3069. /**
  3070. * Returns the Vector4 hash code.
  3071. * @returns a unique hash code
  3072. */
  3073. getHashCode(): number;
  3074. /**
  3075. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3076. * @returns the resulting array
  3077. */
  3078. asArray(): number[];
  3079. /**
  3080. * Populates the given array from the given index with the Vector4 coordinates.
  3081. * @param array array to populate
  3082. * @param index index of the array to start at (default: 0)
  3083. * @returns the Vector4.
  3084. */
  3085. toArray(array: FloatArray, index?: number): Vector4;
  3086. /**
  3087. * Adds the given vector to the current Vector4.
  3088. * @param otherVector the vector to add
  3089. * @returns the updated Vector4.
  3090. */
  3091. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3092. /**
  3093. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3094. * @param otherVector the vector to add
  3095. * @returns the resulting vector
  3096. */
  3097. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3098. /**
  3099. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3100. * @param otherVector the vector to add
  3101. * @param result the vector to store the result
  3102. * @returns the current Vector4.
  3103. */
  3104. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3105. /**
  3106. * Subtract in place the given vector from the current Vector4.
  3107. * @param otherVector the vector to subtract
  3108. * @returns the updated Vector4.
  3109. */
  3110. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3111. /**
  3112. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3113. * @param otherVector the vector to add
  3114. * @returns the new vector with the result
  3115. */
  3116. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3117. /**
  3118. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3119. * @param otherVector the vector to subtract
  3120. * @param result the vector to store the result
  3121. * @returns the current Vector4.
  3122. */
  3123. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3124. /**
  3125. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3126. */
  3127. /**
  3128. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3129. * @param x value to subtract
  3130. * @param y value to subtract
  3131. * @param z value to subtract
  3132. * @param w value to subtract
  3133. * @returns new vector containing the result
  3134. */
  3135. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3136. /**
  3137. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3138. * @param x value to subtract
  3139. * @param y value to subtract
  3140. * @param z value to subtract
  3141. * @param w value to subtract
  3142. * @param result the vector to store the result in
  3143. * @returns the current Vector4.
  3144. */
  3145. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3146. /**
  3147. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3148. * @returns a new vector with the negated values
  3149. */
  3150. negate(): Vector4;
  3151. /**
  3152. * Negate this vector in place
  3153. * @returns this
  3154. */
  3155. negateInPlace(): Vector4;
  3156. /**
  3157. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3158. * @param result defines the Vector3 object where to store the result
  3159. * @returns the current Vector4
  3160. */
  3161. negateToRef(result: Vector4): Vector4;
  3162. /**
  3163. * Multiplies the current Vector4 coordinates by scale (float).
  3164. * @param scale the number to scale with
  3165. * @returns the updated Vector4.
  3166. */
  3167. scaleInPlace(scale: number): Vector4;
  3168. /**
  3169. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3170. * @param scale the number to scale with
  3171. * @returns a new vector with the result
  3172. */
  3173. scale(scale: number): Vector4;
  3174. /**
  3175. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3176. * @param scale the number to scale with
  3177. * @param result a vector to store the result in
  3178. * @returns the current Vector4.
  3179. */
  3180. scaleToRef(scale: number, result: Vector4): Vector4;
  3181. /**
  3182. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3183. * @param scale defines the scale factor
  3184. * @param result defines the Vector4 object where to store the result
  3185. * @returns the unmodified current Vector4
  3186. */
  3187. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3188. /**
  3189. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3190. * @param otherVector the vector to compare against
  3191. * @returns true if they are equal
  3192. */
  3193. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3194. /**
  3195. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3196. * @param otherVector vector to compare against
  3197. * @param epsilon (Default: very small number)
  3198. * @returns true if they are equal
  3199. */
  3200. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3201. /**
  3202. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3203. * @param x x value to compare against
  3204. * @param y y value to compare against
  3205. * @param z z value to compare against
  3206. * @param w w value to compare against
  3207. * @returns true if equal
  3208. */
  3209. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3210. /**
  3211. * Multiplies in place the current Vector4 by the given one.
  3212. * @param otherVector vector to multiple with
  3213. * @returns the updated Vector4.
  3214. */
  3215. multiplyInPlace(otherVector: Vector4): Vector4;
  3216. /**
  3217. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3218. * @param otherVector vector to multiple with
  3219. * @returns resulting new vector
  3220. */
  3221. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3222. /**
  3223. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3224. * @param otherVector vector to multiple with
  3225. * @param result vector to store the result
  3226. * @returns the current Vector4.
  3227. */
  3228. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3229. /**
  3230. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3231. * @param x x value multiply with
  3232. * @param y y value multiply with
  3233. * @param z z value multiply with
  3234. * @param w w value multiply with
  3235. * @returns resulting new vector
  3236. */
  3237. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3238. /**
  3239. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3240. * @param otherVector vector to devide with
  3241. * @returns resulting new vector
  3242. */
  3243. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3244. /**
  3245. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3246. * @param otherVector vector to devide with
  3247. * @param result vector to store the result
  3248. * @returns the current Vector4.
  3249. */
  3250. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3251. /**
  3252. * Divides the current Vector3 coordinates by the given ones.
  3253. * @param otherVector vector to devide with
  3254. * @returns the updated Vector3.
  3255. */
  3256. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3257. /**
  3258. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3259. * @param other defines the second operand
  3260. * @returns the current updated Vector4
  3261. */
  3262. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3263. /**
  3264. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3265. * @param other defines the second operand
  3266. * @returns the current updated Vector4
  3267. */
  3268. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3269. /**
  3270. * Gets a new Vector4 from current Vector4 floored values
  3271. * @returns a new Vector4
  3272. */
  3273. floor(): Vector4;
  3274. /**
  3275. * Gets a new Vector4 from current Vector3 floored values
  3276. * @returns a new Vector4
  3277. */
  3278. fract(): Vector4;
  3279. /**
  3280. * Returns the Vector4 length (float).
  3281. * @returns the length
  3282. */
  3283. length(): number;
  3284. /**
  3285. * Returns the Vector4 squared length (float).
  3286. * @returns the length squared
  3287. */
  3288. lengthSquared(): number;
  3289. /**
  3290. * Normalizes in place the Vector4.
  3291. * @returns the updated Vector4.
  3292. */
  3293. normalize(): Vector4;
  3294. /**
  3295. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3296. * @returns this converted to a new vector3
  3297. */
  3298. toVector3(): Vector3;
  3299. /**
  3300. * Returns a new Vector4 copied from the current one.
  3301. * @returns the new cloned vector
  3302. */
  3303. clone(): Vector4;
  3304. /**
  3305. * Updates the current Vector4 with the given one coordinates.
  3306. * @param source the source vector to copy from
  3307. * @returns the updated Vector4.
  3308. */
  3309. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3310. /**
  3311. * Updates the current Vector4 coordinates with the given floats.
  3312. * @param x float to copy from
  3313. * @param y float to copy from
  3314. * @param z float to copy from
  3315. * @param w float to copy from
  3316. * @returns the updated Vector4.
  3317. */
  3318. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3319. /**
  3320. * Updates the current Vector4 coordinates with the given floats.
  3321. * @param x float to set from
  3322. * @param y float to set from
  3323. * @param z float to set from
  3324. * @param w float to set from
  3325. * @returns the updated Vector4.
  3326. */
  3327. set(x: number, y: number, z: number, w: number): Vector4;
  3328. /**
  3329. * Copies the given float to the current Vector3 coordinates
  3330. * @param v defines the x, y, z and w coordinates of the operand
  3331. * @returns the current updated Vector3
  3332. */
  3333. setAll(v: number): Vector4;
  3334. /**
  3335. * Returns a new Vector4 set from the starting index of the given array.
  3336. * @param array the array to pull values from
  3337. * @param offset the offset into the array to start at
  3338. * @returns the new vector
  3339. */
  3340. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3341. /**
  3342. * Updates the given vector "result" from the starting index of the given array.
  3343. * @param array the array to pull values from
  3344. * @param offset the offset into the array to start at
  3345. * @param result the vector to store the result in
  3346. */
  3347. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3348. /**
  3349. * Updates the given vector "result" from the starting index of the given Float32Array.
  3350. * @param array the array to pull values from
  3351. * @param offset the offset into the array to start at
  3352. * @param result the vector to store the result in
  3353. */
  3354. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3355. /**
  3356. * Updates the given vector "result" coordinates from the given floats.
  3357. * @param x float to set from
  3358. * @param y float to set from
  3359. * @param z float to set from
  3360. * @param w float to set from
  3361. * @param result the vector to the floats in
  3362. */
  3363. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3364. /**
  3365. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3366. * @returns the new vector
  3367. */
  3368. static Zero(): Vector4;
  3369. /**
  3370. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3371. * @returns the new vector
  3372. */
  3373. static One(): Vector4;
  3374. /**
  3375. * Returns a new normalized Vector4 from the given one.
  3376. * @param vector the vector to normalize
  3377. * @returns the vector
  3378. */
  3379. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3380. /**
  3381. * Updates the given vector "result" from the normalization of the given one.
  3382. * @param vector the vector to normalize
  3383. * @param result the vector to store the result in
  3384. */
  3385. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3386. /**
  3387. * Returns a vector with the minimum values from the left and right vectors
  3388. * @param left left vector to minimize
  3389. * @param right right vector to minimize
  3390. * @returns a new vector with the minimum of the left and right vector values
  3391. */
  3392. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3393. /**
  3394. * Returns a vector with the maximum values from the left and right vectors
  3395. * @param left left vector to maximize
  3396. * @param right right vector to maximize
  3397. * @returns a new vector with the maximum of the left and right vector values
  3398. */
  3399. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3400. /**
  3401. * Returns the distance (float) between the vectors "value1" and "value2".
  3402. * @param value1 value to calulate the distance between
  3403. * @param value2 value to calulate the distance between
  3404. * @return the distance between the two vectors
  3405. */
  3406. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3407. /**
  3408. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3409. * @param value1 value to calulate the distance between
  3410. * @param value2 value to calulate the distance between
  3411. * @return the distance between the two vectors squared
  3412. */
  3413. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3414. /**
  3415. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3416. * @param value1 value to calulate the center between
  3417. * @param value2 value to calulate the center between
  3418. * @return the center between the two vectors
  3419. */
  3420. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3421. /**
  3422. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3423. * This methods computes transformed normalized direction vectors only.
  3424. * @param vector the vector to transform
  3425. * @param transformation the transformation matrix to apply
  3426. * @returns the new vector
  3427. */
  3428. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3429. /**
  3430. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3431. * This methods computes transformed normalized direction vectors only.
  3432. * @param vector the vector to transform
  3433. * @param transformation the transformation matrix to apply
  3434. * @param result the vector to store the result in
  3435. */
  3436. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3437. /**
  3438. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3439. * This methods computes transformed normalized direction vectors only.
  3440. * @param x value to transform
  3441. * @param y value to transform
  3442. * @param z value to transform
  3443. * @param w value to transform
  3444. * @param transformation the transformation matrix to apply
  3445. * @param result the vector to store the results in
  3446. */
  3447. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3448. /**
  3449. * Creates a new Vector4 from a Vector3
  3450. * @param source defines the source data
  3451. * @param w defines the 4th component (default is 0)
  3452. * @returns a new Vector4
  3453. */
  3454. static FromVector3(source: Vector3, w?: number): Vector4;
  3455. }
  3456. /**
  3457. * Class used to store quaternion data
  3458. * @see https://en.wikipedia.org/wiki/Quaternion
  3459. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3460. */
  3461. export class Quaternion {
  3462. /** defines the first component (0 by default) */
  3463. x: number;
  3464. /** defines the second component (0 by default) */
  3465. y: number;
  3466. /** defines the third component (0 by default) */
  3467. z: number;
  3468. /** defines the fourth component (1.0 by default) */
  3469. w: number;
  3470. /**
  3471. * Creates a new Quaternion from the given floats
  3472. * @param x defines the first component (0 by default)
  3473. * @param y defines the second component (0 by default)
  3474. * @param z defines the third component (0 by default)
  3475. * @param w defines the fourth component (1.0 by default)
  3476. */
  3477. constructor(
  3478. /** defines the first component (0 by default) */
  3479. x?: number,
  3480. /** defines the second component (0 by default) */
  3481. y?: number,
  3482. /** defines the third component (0 by default) */
  3483. z?: number,
  3484. /** defines the fourth component (1.0 by default) */
  3485. w?: number);
  3486. /**
  3487. * Gets a string representation for the current quaternion
  3488. * @returns a string with the Quaternion coordinates
  3489. */
  3490. toString(): string;
  3491. /**
  3492. * Gets the class name of the quaternion
  3493. * @returns the string "Quaternion"
  3494. */
  3495. getClassName(): string;
  3496. /**
  3497. * Gets a hash code for this quaternion
  3498. * @returns the quaternion hash code
  3499. */
  3500. getHashCode(): number;
  3501. /**
  3502. * Copy the quaternion to an array
  3503. * @returns a new array populated with 4 elements from the quaternion coordinates
  3504. */
  3505. asArray(): number[];
  3506. /**
  3507. * Check if two quaternions are equals
  3508. * @param otherQuaternion defines the second operand
  3509. * @return true if the current quaternion and the given one coordinates are strictly equals
  3510. */
  3511. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3512. /**
  3513. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3514. * @param otherQuaternion defines the other quaternion
  3515. * @param epsilon defines the minimal distance to consider equality
  3516. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3517. */
  3518. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3519. /**
  3520. * Clone the current quaternion
  3521. * @returns a new quaternion copied from the current one
  3522. */
  3523. clone(): Quaternion;
  3524. /**
  3525. * Copy a quaternion to the current one
  3526. * @param other defines the other quaternion
  3527. * @returns the updated current quaternion
  3528. */
  3529. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3530. /**
  3531. * Updates the current quaternion with the given float coordinates
  3532. * @param x defines the x coordinate
  3533. * @param y defines the y coordinate
  3534. * @param z defines the z coordinate
  3535. * @param w defines the w coordinate
  3536. * @returns the updated current quaternion
  3537. */
  3538. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3539. /**
  3540. * Updates the current quaternion from the given float coordinates
  3541. * @param x defines the x coordinate
  3542. * @param y defines the y coordinate
  3543. * @param z defines the z coordinate
  3544. * @param w defines the w coordinate
  3545. * @returns the updated current quaternion
  3546. */
  3547. set(x: number, y: number, z: number, w: number): Quaternion;
  3548. /**
  3549. * Adds two quaternions
  3550. * @param other defines the second operand
  3551. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3552. */
  3553. add(other: DeepImmutable<Quaternion>): Quaternion;
  3554. /**
  3555. * Add a quaternion to the current one
  3556. * @param other defines the quaternion to add
  3557. * @returns the current quaternion
  3558. */
  3559. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3560. /**
  3561. * Subtract two quaternions
  3562. * @param other defines the second operand
  3563. * @returns a new quaternion as the subtraction result of the given one from the current one
  3564. */
  3565. subtract(other: Quaternion): Quaternion;
  3566. /**
  3567. * Multiplies the current quaternion by a scale factor
  3568. * @param value defines the scale factor
  3569. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3570. */
  3571. scale(value: number): Quaternion;
  3572. /**
  3573. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3574. * @param scale defines the scale factor
  3575. * @param result defines the Quaternion object where to store the result
  3576. * @returns the unmodified current quaternion
  3577. */
  3578. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3579. /**
  3580. * Multiplies in place the current quaternion by a scale factor
  3581. * @param value defines the scale factor
  3582. * @returns the current modified quaternion
  3583. */
  3584. scaleInPlace(value: number): Quaternion;
  3585. /**
  3586. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3587. * @param scale defines the scale factor
  3588. * @param result defines the Quaternion object where to store the result
  3589. * @returns the unmodified current quaternion
  3590. */
  3591. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3592. /**
  3593. * Multiplies two quaternions
  3594. * @param q1 defines the second operand
  3595. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3596. */
  3597. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3598. /**
  3599. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3600. * @param q1 defines the second operand
  3601. * @param result defines the target quaternion
  3602. * @returns the current quaternion
  3603. */
  3604. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3605. /**
  3606. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3607. * @param q1 defines the second operand
  3608. * @returns the currentupdated quaternion
  3609. */
  3610. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3611. /**
  3612. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3613. * @param ref defines the target quaternion
  3614. * @returns the current quaternion
  3615. */
  3616. conjugateToRef(ref: Quaternion): Quaternion;
  3617. /**
  3618. * Conjugates in place (1-q) the current quaternion
  3619. * @returns the current updated quaternion
  3620. */
  3621. conjugateInPlace(): Quaternion;
  3622. /**
  3623. * Conjugates in place (1-q) the current quaternion
  3624. * @returns a new quaternion
  3625. */
  3626. conjugate(): Quaternion;
  3627. /**
  3628. * Gets length of current quaternion
  3629. * @returns the quaternion length (float)
  3630. */
  3631. length(): number;
  3632. /**
  3633. * Normalize in place the current quaternion
  3634. * @returns the current updated quaternion
  3635. */
  3636. normalize(): Quaternion;
  3637. /**
  3638. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3639. * @param order is a reserved parameter and is ignore for now
  3640. * @returns a new Vector3 containing the Euler angles
  3641. */
  3642. toEulerAngles(order?: string): Vector3;
  3643. /**
  3644. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3645. * @param result defines the vector which will be filled with the Euler angles
  3646. * @param order is a reserved parameter and is ignore for now
  3647. * @returns the current unchanged quaternion
  3648. */
  3649. toEulerAnglesToRef(result: Vector3): Quaternion;
  3650. /**
  3651. * Updates the given rotation matrix with the current quaternion values
  3652. * @param result defines the target matrix
  3653. * @returns the current unchanged quaternion
  3654. */
  3655. toRotationMatrix(result: Matrix): Quaternion;
  3656. /**
  3657. * Updates the current quaternion from the given rotation matrix values
  3658. * @param matrix defines the source matrix
  3659. * @returns the current updated quaternion
  3660. */
  3661. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3662. /**
  3663. * Creates a new quaternion from a rotation matrix
  3664. * @param matrix defines the source matrix
  3665. * @returns a new quaternion created from the given rotation matrix values
  3666. */
  3667. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3668. /**
  3669. * Updates the given quaternion with the given rotation matrix values
  3670. * @param matrix defines the source matrix
  3671. * @param result defines the target quaternion
  3672. */
  3673. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3674. /**
  3675. * Returns the dot product (float) between the quaternions "left" and "right"
  3676. * @param left defines the left operand
  3677. * @param right defines the right operand
  3678. * @returns the dot product
  3679. */
  3680. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3681. /**
  3682. * Checks if the two quaternions are close to each other
  3683. * @param quat0 defines the first quaternion to check
  3684. * @param quat1 defines the second quaternion to check
  3685. * @returns true if the two quaternions are close to each other
  3686. */
  3687. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3688. /**
  3689. * Creates an empty quaternion
  3690. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3691. */
  3692. static Zero(): Quaternion;
  3693. /**
  3694. * Inverse a given quaternion
  3695. * @param q defines the source quaternion
  3696. * @returns a new quaternion as the inverted current quaternion
  3697. */
  3698. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3699. /**
  3700. * Inverse a given quaternion
  3701. * @param q defines the source quaternion
  3702. * @param result the quaternion the result will be stored in
  3703. * @returns the result quaternion
  3704. */
  3705. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3706. /**
  3707. * Creates an identity quaternion
  3708. * @returns the identity quaternion
  3709. */
  3710. static Identity(): Quaternion;
  3711. /**
  3712. * Gets a boolean indicating if the given quaternion is identity
  3713. * @param quaternion defines the quaternion to check
  3714. * @returns true if the quaternion is identity
  3715. */
  3716. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3717. /**
  3718. * Creates a quaternion from a rotation around an axis
  3719. * @param axis defines the axis to use
  3720. * @param angle defines the angle to use
  3721. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3722. */
  3723. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3724. /**
  3725. * Creates a rotation around an axis and stores it into the given quaternion
  3726. * @param axis defines the axis to use
  3727. * @param angle defines the angle to use
  3728. * @param result defines the target quaternion
  3729. * @returns the target quaternion
  3730. */
  3731. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3732. /**
  3733. * Creates a new quaternion from data stored into an array
  3734. * @param array defines the data source
  3735. * @param offset defines the offset in the source array where the data starts
  3736. * @returns a new quaternion
  3737. */
  3738. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3739. /**
  3740. * Updates the given quaternion "result" from the starting index of the given array.
  3741. * @param array the array to pull values from
  3742. * @param offset the offset into the array to start at
  3743. * @param result the quaternion to store the result in
  3744. */
  3745. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3746. /**
  3747. * Create a quaternion from Euler rotation angles
  3748. * @param x Pitch
  3749. * @param y Yaw
  3750. * @param z Roll
  3751. * @returns the new Quaternion
  3752. */
  3753. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3754. /**
  3755. * Updates a quaternion from Euler rotation angles
  3756. * @param x Pitch
  3757. * @param y Yaw
  3758. * @param z Roll
  3759. * @param result the quaternion to store the result
  3760. * @returns the updated quaternion
  3761. */
  3762. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3763. /**
  3764. * Create a quaternion from Euler rotation vector
  3765. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3766. * @returns the new Quaternion
  3767. */
  3768. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3769. /**
  3770. * Updates a quaternion from Euler rotation vector
  3771. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3772. * @param result the quaternion to store the result
  3773. * @returns the updated quaternion
  3774. */
  3775. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3776. /**
  3777. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3778. * @param yaw defines the rotation around Y axis
  3779. * @param pitch defines the rotation around X axis
  3780. * @param roll defines the rotation around Z axis
  3781. * @returns the new quaternion
  3782. */
  3783. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3784. /**
  3785. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3786. * @param yaw defines the rotation around Y axis
  3787. * @param pitch defines the rotation around X axis
  3788. * @param roll defines the rotation around Z axis
  3789. * @param result defines the target quaternion
  3790. */
  3791. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3792. /**
  3793. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3794. * @param alpha defines the rotation around first axis
  3795. * @param beta defines the rotation around second axis
  3796. * @param gamma defines the rotation around third axis
  3797. * @returns the new quaternion
  3798. */
  3799. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3800. /**
  3801. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3802. * @param alpha defines the rotation around first axis
  3803. * @param beta defines the rotation around second axis
  3804. * @param gamma defines the rotation around third axis
  3805. * @param result defines the target quaternion
  3806. */
  3807. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3808. /**
  3809. * 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)
  3810. * @param axis1 defines the first axis
  3811. * @param axis2 defines the second axis
  3812. * @param axis3 defines the third axis
  3813. * @returns the new quaternion
  3814. */
  3815. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3816. /**
  3817. * 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
  3818. * @param axis1 defines the first axis
  3819. * @param axis2 defines the second axis
  3820. * @param axis3 defines the third axis
  3821. * @param ref defines the target quaternion
  3822. */
  3823. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3824. /**
  3825. * Interpolates between two quaternions
  3826. * @param left defines first quaternion
  3827. * @param right defines second quaternion
  3828. * @param amount defines the gradient to use
  3829. * @returns the new interpolated quaternion
  3830. */
  3831. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3832. /**
  3833. * Interpolates between two quaternions and stores it into a target quaternion
  3834. * @param left defines first quaternion
  3835. * @param right defines second quaternion
  3836. * @param amount defines the gradient to use
  3837. * @param result defines the target quaternion
  3838. */
  3839. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3840. /**
  3841. * Interpolate between two quaternions using Hermite interpolation
  3842. * @param value1 defines first quaternion
  3843. * @param tangent1 defines the incoming tangent
  3844. * @param value2 defines second quaternion
  3845. * @param tangent2 defines the outgoing tangent
  3846. * @param amount defines the target quaternion
  3847. * @returns the new interpolated quaternion
  3848. */
  3849. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3850. }
  3851. /**
  3852. * Class used to store matrix data (4x4)
  3853. */
  3854. export class Matrix {
  3855. private static _updateFlagSeed;
  3856. private static _identityReadOnly;
  3857. private _isIdentity;
  3858. private _isIdentityDirty;
  3859. private _isIdentity3x2;
  3860. private _isIdentity3x2Dirty;
  3861. /**
  3862. * Gets the update flag of the matrix which is an unique number for the matrix.
  3863. * It will be incremented every time the matrix data change.
  3864. * You can use it to speed the comparison between two versions of the same matrix.
  3865. */
  3866. updateFlag: number;
  3867. private readonly _m;
  3868. /**
  3869. * Gets the internal data of the matrix
  3870. */
  3871. get m(): DeepImmutable<Float32Array>;
  3872. /** @hidden */
  3873. _markAsUpdated(): void;
  3874. /** @hidden */
  3875. private _updateIdentityStatus;
  3876. /**
  3877. * Creates an empty matrix (filled with zeros)
  3878. */
  3879. constructor();
  3880. /**
  3881. * Check if the current matrix is identity
  3882. * @returns true is the matrix is the identity matrix
  3883. */
  3884. isIdentity(): boolean;
  3885. /**
  3886. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3887. * @returns true is the matrix is the identity matrix
  3888. */
  3889. isIdentityAs3x2(): boolean;
  3890. /**
  3891. * Gets the determinant of the matrix
  3892. * @returns the matrix determinant
  3893. */
  3894. determinant(): number;
  3895. /**
  3896. * Returns the matrix as a Float32Array
  3897. * @returns the matrix underlying array
  3898. */
  3899. toArray(): DeepImmutable<Float32Array>;
  3900. /**
  3901. * Returns the matrix as a Float32Array
  3902. * @returns the matrix underlying array.
  3903. */
  3904. asArray(): DeepImmutable<Float32Array>;
  3905. /**
  3906. * Inverts the current matrix in place
  3907. * @returns the current inverted matrix
  3908. */
  3909. invert(): Matrix;
  3910. /**
  3911. * Sets all the matrix elements to zero
  3912. * @returns the current matrix
  3913. */
  3914. reset(): Matrix;
  3915. /**
  3916. * Adds the current matrix with a second one
  3917. * @param other defines the matrix to add
  3918. * @returns a new matrix as the addition of the current matrix and the given one
  3919. */
  3920. add(other: DeepImmutable<Matrix>): Matrix;
  3921. /**
  3922. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3923. * @param other defines the matrix to add
  3924. * @param result defines the target matrix
  3925. * @returns the current matrix
  3926. */
  3927. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3928. /**
  3929. * Adds in place the given matrix to the current matrix
  3930. * @param other defines the second operand
  3931. * @returns the current updated matrix
  3932. */
  3933. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3934. /**
  3935. * Sets the given matrix to the current inverted Matrix
  3936. * @param other defines the target matrix
  3937. * @returns the unmodified current matrix
  3938. */
  3939. invertToRef(other: Matrix): Matrix;
  3940. /**
  3941. * add a value at the specified position in the current Matrix
  3942. * @param index the index of the value within the matrix. between 0 and 15.
  3943. * @param value the value to be added
  3944. * @returns the current updated matrix
  3945. */
  3946. addAtIndex(index: number, value: number): Matrix;
  3947. /**
  3948. * mutiply the specified position in the current Matrix by a value
  3949. * @param index the index of the value within the matrix. between 0 and 15.
  3950. * @param value the value to be added
  3951. * @returns the current updated matrix
  3952. */
  3953. multiplyAtIndex(index: number, value: number): Matrix;
  3954. /**
  3955. * Inserts the translation vector (using 3 floats) in the current matrix
  3956. * @param x defines the 1st component of the translation
  3957. * @param y defines the 2nd component of the translation
  3958. * @param z defines the 3rd component of the translation
  3959. * @returns the current updated matrix
  3960. */
  3961. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3962. /**
  3963. * Adds the translation vector (using 3 floats) in the current matrix
  3964. * @param x defines the 1st component of the translation
  3965. * @param y defines the 2nd component of the translation
  3966. * @param z defines the 3rd component of the translation
  3967. * @returns the current updated matrix
  3968. */
  3969. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3970. /**
  3971. * Inserts the translation vector in the current matrix
  3972. * @param vector3 defines the translation to insert
  3973. * @returns the current updated matrix
  3974. */
  3975. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3976. /**
  3977. * Gets the translation value of the current matrix
  3978. * @returns a new Vector3 as the extracted translation from the matrix
  3979. */
  3980. getTranslation(): Vector3;
  3981. /**
  3982. * Fill a Vector3 with the extracted translation from the matrix
  3983. * @param result defines the Vector3 where to store the translation
  3984. * @returns the current matrix
  3985. */
  3986. getTranslationToRef(result: Vector3): Matrix;
  3987. /**
  3988. * Remove rotation and scaling part from the matrix
  3989. * @returns the updated matrix
  3990. */
  3991. removeRotationAndScaling(): Matrix;
  3992. /**
  3993. * Multiply two matrices
  3994. * @param other defines the second operand
  3995. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3996. */
  3997. multiply(other: DeepImmutable<Matrix>): Matrix;
  3998. /**
  3999. * Copy the current matrix from the given one
  4000. * @param other defines the source matrix
  4001. * @returns the current updated matrix
  4002. */
  4003. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4004. /**
  4005. * Populates the given array from the starting index with the current matrix values
  4006. * @param array defines the target array
  4007. * @param offset defines the offset in the target array where to start storing values
  4008. * @returns the current matrix
  4009. */
  4010. copyToArray(array: Float32Array, offset?: number): Matrix;
  4011. /**
  4012. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4013. * @param other defines the second operand
  4014. * @param result defines the matrix where to store the multiplication
  4015. * @returns the current matrix
  4016. */
  4017. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4018. /**
  4019. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4020. * @param other defines the second operand
  4021. * @param result defines the array where to store the multiplication
  4022. * @param offset defines the offset in the target array where to start storing values
  4023. * @returns the current matrix
  4024. */
  4025. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4026. /**
  4027. * Check equality between this matrix and a second one
  4028. * @param value defines the second matrix to compare
  4029. * @returns true is the current matrix and the given one values are strictly equal
  4030. */
  4031. equals(value: DeepImmutable<Matrix>): boolean;
  4032. /**
  4033. * Clone the current matrix
  4034. * @returns a new matrix from the current matrix
  4035. */
  4036. clone(): Matrix;
  4037. /**
  4038. * Returns the name of the current matrix class
  4039. * @returns the string "Matrix"
  4040. */
  4041. getClassName(): string;
  4042. /**
  4043. * Gets the hash code of the current matrix
  4044. * @returns the hash code
  4045. */
  4046. getHashCode(): number;
  4047. /**
  4048. * Decomposes the current Matrix into a translation, rotation and scaling components
  4049. * @param scale defines the scale vector3 given as a reference to update
  4050. * @param rotation defines the rotation quaternion given as a reference to update
  4051. * @param translation defines the translation vector3 given as a reference to update
  4052. * @returns true if operation was successful
  4053. */
  4054. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4055. /**
  4056. * Gets specific row of the matrix
  4057. * @param index defines the number of the row to get
  4058. * @returns the index-th row of the current matrix as a new Vector4
  4059. */
  4060. getRow(index: number): Nullable<Vector4>;
  4061. /**
  4062. * Sets the index-th row of the current matrix to the vector4 values
  4063. * @param index defines the number of the row to set
  4064. * @param row defines the target vector4
  4065. * @returns the updated current matrix
  4066. */
  4067. setRow(index: number, row: Vector4): Matrix;
  4068. /**
  4069. * Compute the transpose of the matrix
  4070. * @returns the new transposed matrix
  4071. */
  4072. transpose(): Matrix;
  4073. /**
  4074. * Compute the transpose of the matrix and store it in a given matrix
  4075. * @param result defines the target matrix
  4076. * @returns the current matrix
  4077. */
  4078. transposeToRef(result: Matrix): Matrix;
  4079. /**
  4080. * Sets the index-th row of the current matrix with the given 4 x float values
  4081. * @param index defines the row index
  4082. * @param x defines the x component to set
  4083. * @param y defines the y component to set
  4084. * @param z defines the z component to set
  4085. * @param w defines the w component to set
  4086. * @returns the updated current matrix
  4087. */
  4088. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4089. /**
  4090. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4091. * @param scale defines the scale factor
  4092. * @returns a new matrix
  4093. */
  4094. scale(scale: number): Matrix;
  4095. /**
  4096. * Scale the current matrix values by a factor to a given result matrix
  4097. * @param scale defines the scale factor
  4098. * @param result defines the matrix to store the result
  4099. * @returns the current matrix
  4100. */
  4101. scaleToRef(scale: number, result: Matrix): Matrix;
  4102. /**
  4103. * Scale the current matrix values by a factor and add the result to a given matrix
  4104. * @param scale defines the scale factor
  4105. * @param result defines the Matrix to store the result
  4106. * @returns the current matrix
  4107. */
  4108. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4109. /**
  4110. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4111. * @param ref matrix to store the result
  4112. */
  4113. toNormalMatrix(ref: Matrix): void;
  4114. /**
  4115. * Gets only rotation part of the current matrix
  4116. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4117. */
  4118. getRotationMatrix(): Matrix;
  4119. /**
  4120. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4121. * @param result defines the target matrix to store data to
  4122. * @returns the current matrix
  4123. */
  4124. getRotationMatrixToRef(result: Matrix): Matrix;
  4125. /**
  4126. * Toggles model matrix from being right handed to left handed in place and vice versa
  4127. */
  4128. toggleModelMatrixHandInPlace(): void;
  4129. /**
  4130. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4131. */
  4132. toggleProjectionMatrixHandInPlace(): void;
  4133. /**
  4134. * Creates a matrix from an array
  4135. * @param array defines the source array
  4136. * @param offset defines an offset in the source array
  4137. * @returns a new Matrix set from the starting index of the given array
  4138. */
  4139. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4140. /**
  4141. * Copy the content of an array into a given matrix
  4142. * @param array defines the source array
  4143. * @param offset defines an offset in the source array
  4144. * @param result defines the target matrix
  4145. */
  4146. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4147. /**
  4148. * Stores an array into a matrix after having multiplied each component by a given factor
  4149. * @param array defines the source array
  4150. * @param offset defines the offset in the source array
  4151. * @param scale defines the scaling factor
  4152. * @param result defines the target matrix
  4153. */
  4154. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4155. /**
  4156. * Gets an identity matrix that must not be updated
  4157. */
  4158. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4159. /**
  4160. * Stores a list of values (16) inside a given matrix
  4161. * @param initialM11 defines 1st value of 1st row
  4162. * @param initialM12 defines 2nd value of 1st row
  4163. * @param initialM13 defines 3rd value of 1st row
  4164. * @param initialM14 defines 4th value of 1st row
  4165. * @param initialM21 defines 1st value of 2nd row
  4166. * @param initialM22 defines 2nd value of 2nd row
  4167. * @param initialM23 defines 3rd value of 2nd row
  4168. * @param initialM24 defines 4th value of 2nd row
  4169. * @param initialM31 defines 1st value of 3rd row
  4170. * @param initialM32 defines 2nd value of 3rd row
  4171. * @param initialM33 defines 3rd value of 3rd row
  4172. * @param initialM34 defines 4th value of 3rd row
  4173. * @param initialM41 defines 1st value of 4th row
  4174. * @param initialM42 defines 2nd value of 4th row
  4175. * @param initialM43 defines 3rd value of 4th row
  4176. * @param initialM44 defines 4th value of 4th row
  4177. * @param result defines the target matrix
  4178. */
  4179. 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;
  4180. /**
  4181. * Creates new matrix from a list of values (16)
  4182. * @param initialM11 defines 1st value of 1st row
  4183. * @param initialM12 defines 2nd value of 1st row
  4184. * @param initialM13 defines 3rd value of 1st row
  4185. * @param initialM14 defines 4th value of 1st row
  4186. * @param initialM21 defines 1st value of 2nd row
  4187. * @param initialM22 defines 2nd value of 2nd row
  4188. * @param initialM23 defines 3rd value of 2nd row
  4189. * @param initialM24 defines 4th value of 2nd row
  4190. * @param initialM31 defines 1st value of 3rd row
  4191. * @param initialM32 defines 2nd value of 3rd row
  4192. * @param initialM33 defines 3rd value of 3rd row
  4193. * @param initialM34 defines 4th value of 3rd row
  4194. * @param initialM41 defines 1st value of 4th row
  4195. * @param initialM42 defines 2nd value of 4th row
  4196. * @param initialM43 defines 3rd value of 4th row
  4197. * @param initialM44 defines 4th value of 4th row
  4198. * @returns the new matrix
  4199. */
  4200. 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;
  4201. /**
  4202. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4203. * @param scale defines the scale vector3
  4204. * @param rotation defines the rotation quaternion
  4205. * @param translation defines the translation vector3
  4206. * @returns a new matrix
  4207. */
  4208. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4209. /**
  4210. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4211. * @param scale defines the scale vector3
  4212. * @param rotation defines the rotation quaternion
  4213. * @param translation defines the translation vector3
  4214. * @param result defines the target matrix
  4215. */
  4216. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4217. /**
  4218. * Creates a new identity matrix
  4219. * @returns a new identity matrix
  4220. */
  4221. static Identity(): Matrix;
  4222. /**
  4223. * Creates a new identity matrix and stores the result in a given matrix
  4224. * @param result defines the target matrix
  4225. */
  4226. static IdentityToRef(result: Matrix): void;
  4227. /**
  4228. * Creates a new zero matrix
  4229. * @returns a new zero matrix
  4230. */
  4231. static Zero(): Matrix;
  4232. /**
  4233. * Creates a new rotation matrix for "angle" radians around the X axis
  4234. * @param angle defines the angle (in radians) to use
  4235. * @return the new matrix
  4236. */
  4237. static RotationX(angle: number): Matrix;
  4238. /**
  4239. * Creates a new matrix as the invert of a given matrix
  4240. * @param source defines the source matrix
  4241. * @returns the new matrix
  4242. */
  4243. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4244. /**
  4245. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4246. * @param angle defines the angle (in radians) to use
  4247. * @param result defines the target matrix
  4248. */
  4249. static RotationXToRef(angle: number, result: Matrix): void;
  4250. /**
  4251. * Creates a new rotation matrix for "angle" radians around the Y axis
  4252. * @param angle defines the angle (in radians) to use
  4253. * @return the new matrix
  4254. */
  4255. static RotationY(angle: number): Matrix;
  4256. /**
  4257. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4258. * @param angle defines the angle (in radians) to use
  4259. * @param result defines the target matrix
  4260. */
  4261. static RotationYToRef(angle: number, result: Matrix): void;
  4262. /**
  4263. * Creates a new rotation matrix for "angle" radians around the Z axis
  4264. * @param angle defines the angle (in radians) to use
  4265. * @return the new matrix
  4266. */
  4267. static RotationZ(angle: number): Matrix;
  4268. /**
  4269. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4270. * @param angle defines the angle (in radians) to use
  4271. * @param result defines the target matrix
  4272. */
  4273. static RotationZToRef(angle: number, result: Matrix): void;
  4274. /**
  4275. * Creates a new rotation matrix for "angle" radians around the given axis
  4276. * @param axis defines the axis to use
  4277. * @param angle defines the angle (in radians) to use
  4278. * @return the new matrix
  4279. */
  4280. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4281. /**
  4282. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4283. * @param axis defines the axis to use
  4284. * @param angle defines the angle (in radians) to use
  4285. * @param result defines the target matrix
  4286. */
  4287. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4288. /**
  4289. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4290. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4291. * @param from defines the vector to align
  4292. * @param to defines the vector to align to
  4293. * @param result defines the target matrix
  4294. */
  4295. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4296. /**
  4297. * Creates a rotation matrix
  4298. * @param yaw defines the yaw angle in radians (Y axis)
  4299. * @param pitch defines the pitch angle in radians (X axis)
  4300. * @param roll defines the roll angle in radians (X axis)
  4301. * @returns the new rotation matrix
  4302. */
  4303. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4304. /**
  4305. * Creates a rotation matrix and stores it in a given matrix
  4306. * @param yaw defines the yaw angle in radians (Y axis)
  4307. * @param pitch defines the pitch angle in radians (X axis)
  4308. * @param roll defines the roll angle in radians (X axis)
  4309. * @param result defines the target matrix
  4310. */
  4311. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4312. /**
  4313. * Creates a scaling matrix
  4314. * @param x defines the scale factor on X axis
  4315. * @param y defines the scale factor on Y axis
  4316. * @param z defines the scale factor on Z axis
  4317. * @returns the new matrix
  4318. */
  4319. static Scaling(x: number, y: number, z: number): Matrix;
  4320. /**
  4321. * Creates a scaling matrix and stores it in a given matrix
  4322. * @param x defines the scale factor on X axis
  4323. * @param y defines the scale factor on Y axis
  4324. * @param z defines the scale factor on Z axis
  4325. * @param result defines the target matrix
  4326. */
  4327. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4328. /**
  4329. * Creates a translation matrix
  4330. * @param x defines the translation on X axis
  4331. * @param y defines the translation on Y axis
  4332. * @param z defines the translationon Z axis
  4333. * @returns the new matrix
  4334. */
  4335. static Translation(x: number, y: number, z: number): Matrix;
  4336. /**
  4337. * Creates a translation matrix and stores it in a given matrix
  4338. * @param x defines the translation on X axis
  4339. * @param y defines the translation on Y axis
  4340. * @param z defines the translationon Z axis
  4341. * @param result defines the target matrix
  4342. */
  4343. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4344. /**
  4345. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4346. * @param startValue defines the start value
  4347. * @param endValue defines the end value
  4348. * @param gradient defines the gradient factor
  4349. * @returns the new matrix
  4350. */
  4351. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4352. /**
  4353. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4354. * @param startValue defines the start value
  4355. * @param endValue defines the end value
  4356. * @param gradient defines the gradient factor
  4357. * @param result defines the Matrix object where to store data
  4358. */
  4359. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4360. /**
  4361. * Builds a new matrix whose values are computed by:
  4362. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4363. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4364. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4365. * @param startValue defines the first matrix
  4366. * @param endValue defines the second matrix
  4367. * @param gradient defines the gradient between the two matrices
  4368. * @returns the new matrix
  4369. */
  4370. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4371. /**
  4372. * Update a matrix to values which 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. * @param result defines the target matrix
  4380. */
  4381. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4382. /**
  4383. * 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"
  4384. * This function works in left handed mode
  4385. * @param eye defines the final position of the entity
  4386. * @param target defines where the entity should look at
  4387. * @param up defines the up vector for the entity
  4388. * @returns the new matrix
  4389. */
  4390. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4391. /**
  4392. * 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".
  4393. * This function works in left handed mode
  4394. * @param eye defines the final position of the entity
  4395. * @param target defines where the entity should look at
  4396. * @param up defines the up vector for the entity
  4397. * @param result defines the target matrix
  4398. */
  4399. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4400. /**
  4401. * 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"
  4402. * This function works in right handed mode
  4403. * @param eye defines the final position of the entity
  4404. * @param target defines where the entity should look at
  4405. * @param up defines the up vector for the entity
  4406. * @returns the new matrix
  4407. */
  4408. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4409. /**
  4410. * 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".
  4411. * This function works in right handed mode
  4412. * @param eye defines the final position of the entity
  4413. * @param target defines where the entity should look at
  4414. * @param up defines the up vector for the entity
  4415. * @param result defines the target matrix
  4416. */
  4417. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4418. /**
  4419. * Create a left-handed orthographic projection matrix
  4420. * @param width defines the viewport width
  4421. * @param height defines the viewport height
  4422. * @param znear defines the near clip plane
  4423. * @param zfar defines the far clip plane
  4424. * @returns a new matrix as a left-handed orthographic projection matrix
  4425. */
  4426. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4427. /**
  4428. * Store a left-handed orthographic projection to a given matrix
  4429. * @param width defines the viewport width
  4430. * @param height defines the viewport height
  4431. * @param znear defines the near clip plane
  4432. * @param zfar defines the far clip plane
  4433. * @param result defines the target matrix
  4434. */
  4435. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4436. /**
  4437. * Create a left-handed orthographic projection matrix
  4438. * @param left defines the viewport left coordinate
  4439. * @param right defines the viewport right coordinate
  4440. * @param bottom defines the viewport bottom coordinate
  4441. * @param top defines the viewport top coordinate
  4442. * @param znear defines the near clip plane
  4443. * @param zfar defines the far clip plane
  4444. * @returns a new matrix as a left-handed orthographic projection matrix
  4445. */
  4446. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4447. /**
  4448. * Stores a left-handed orthographic projection into a given 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. * @param result defines the target matrix
  4456. */
  4457. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4458. /**
  4459. * Creates a right-handed orthographic projection 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. * @returns a new matrix as a right-handed orthographic projection matrix
  4467. */
  4468. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4469. /**
  4470. * Stores a right-handed orthographic projection into a given 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. * @param result defines the target matrix
  4478. */
  4479. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4480. /**
  4481. * Creates a left-handed perspective projection matrix
  4482. * @param width defines the viewport width
  4483. * @param height defines the viewport height
  4484. * @param znear defines the near clip plane
  4485. * @param zfar defines the far clip plane
  4486. * @returns a new matrix as a left-handed perspective projection matrix
  4487. */
  4488. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4489. /**
  4490. * Creates a left-handed perspective projection matrix
  4491. * @param fov defines the horizontal field of view
  4492. * @param aspect defines the aspect ratio
  4493. * @param znear defines the near clip plane
  4494. * @param zfar defines the far clip plane
  4495. * @returns a new matrix as a left-handed perspective projection matrix
  4496. */
  4497. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4498. /**
  4499. * Stores a left-handed perspective projection into a given matrix
  4500. * @param fov defines the horizontal field of view
  4501. * @param aspect defines the aspect ratio
  4502. * @param znear defines the near clip plane
  4503. * @param zfar defines the far clip plane
  4504. * @param result defines the target matrix
  4505. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4506. */
  4507. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4508. /**
  4509. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4510. * @param fov defines the horizontal field of view
  4511. * @param aspect defines the aspect ratio
  4512. * @param znear defines the near clip plane
  4513. * @param zfar not used as infinity is used as far clip
  4514. * @param result defines the target matrix
  4515. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4516. */
  4517. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4518. /**
  4519. * Creates a right-handed perspective projection matrix
  4520. * @param fov defines the horizontal field of view
  4521. * @param aspect defines the aspect ratio
  4522. * @param znear defines the near clip plane
  4523. * @param zfar defines the far clip plane
  4524. * @returns a new matrix as a right-handed perspective projection matrix
  4525. */
  4526. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4527. /**
  4528. * Stores a right-handed perspective projection into a given matrix
  4529. * @param fov defines the horizontal field of view
  4530. * @param aspect defines the aspect ratio
  4531. * @param znear defines the near clip plane
  4532. * @param zfar defines the far clip plane
  4533. * @param result defines the target matrix
  4534. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4535. */
  4536. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4537. /**
  4538. * Stores a right-handed perspective projection into a given matrix
  4539. * @param fov defines the horizontal field of view
  4540. * @param aspect defines the aspect ratio
  4541. * @param znear defines the near clip plane
  4542. * @param zfar not used as infinity is used as far clip
  4543. * @param result defines the target matrix
  4544. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4545. */
  4546. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4547. /**
  4548. * Stores a perspective projection for WebVR info a given matrix
  4549. * @param fov defines the field of view
  4550. * @param znear defines the near clip plane
  4551. * @param zfar defines the far clip plane
  4552. * @param result defines the target matrix
  4553. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4554. */
  4555. static PerspectiveFovWebVRToRef(fov: {
  4556. upDegrees: number;
  4557. downDegrees: number;
  4558. leftDegrees: number;
  4559. rightDegrees: number;
  4560. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4561. /**
  4562. * Computes a complete transformation matrix
  4563. * @param viewport defines the viewport to use
  4564. * @param world defines the world matrix
  4565. * @param view defines the view matrix
  4566. * @param projection defines the projection matrix
  4567. * @param zmin defines the near clip plane
  4568. * @param zmax defines the far clip plane
  4569. * @returns the transformation matrix
  4570. */
  4571. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4572. /**
  4573. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4574. * @param matrix defines the matrix to use
  4575. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4576. */
  4577. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4578. /**
  4579. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4580. * @param matrix defines the matrix to use
  4581. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4582. */
  4583. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4584. /**
  4585. * Compute the transpose of a given matrix
  4586. * @param matrix defines the matrix to transpose
  4587. * @returns the new matrix
  4588. */
  4589. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4590. /**
  4591. * Compute the transpose of a matrix and store it in a target matrix
  4592. * @param matrix defines the matrix to transpose
  4593. * @param result defines the target matrix
  4594. */
  4595. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4596. /**
  4597. * Computes a reflection matrix from a plane
  4598. * @param plane defines the reflection plane
  4599. * @returns a new matrix
  4600. */
  4601. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4602. /**
  4603. * Computes a reflection matrix from a plane
  4604. * @param plane defines the reflection plane
  4605. * @param result defines the target matrix
  4606. */
  4607. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4608. /**
  4609. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4610. * @param xaxis defines the value of the 1st axis
  4611. * @param yaxis defines the value of the 2nd axis
  4612. * @param zaxis defines the value of the 3rd axis
  4613. * @param result defines the target matrix
  4614. */
  4615. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4616. /**
  4617. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4618. * @param quat defines the quaternion to use
  4619. * @param result defines the target matrix
  4620. */
  4621. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4622. }
  4623. /**
  4624. * @hidden
  4625. */
  4626. export class TmpVectors {
  4627. static Vector2: Vector2[];
  4628. static Vector3: Vector3[];
  4629. static Vector4: Vector4[];
  4630. static Quaternion: Quaternion[];
  4631. static Matrix: Matrix[];
  4632. }
  4633. }
  4634. declare module BABYLON {
  4635. /**
  4636. * Defines potential orientation for back face culling
  4637. */
  4638. export enum Orientation {
  4639. /**
  4640. * Clockwise
  4641. */
  4642. CW = 0,
  4643. /** Counter clockwise */
  4644. CCW = 1
  4645. }
  4646. /** Class used to represent a Bezier curve */
  4647. export class BezierCurve {
  4648. /**
  4649. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4650. * @param t defines the time
  4651. * @param x1 defines the left coordinate on X axis
  4652. * @param y1 defines the left coordinate on Y axis
  4653. * @param x2 defines the right coordinate on X axis
  4654. * @param y2 defines the right coordinate on Y axis
  4655. * @returns the interpolated value
  4656. */
  4657. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4658. }
  4659. /**
  4660. * Defines angle representation
  4661. */
  4662. export class Angle {
  4663. private _radians;
  4664. /**
  4665. * Creates an Angle object of "radians" radians (float).
  4666. * @param radians the angle in radians
  4667. */
  4668. constructor(radians: number);
  4669. /**
  4670. * Get value in degrees
  4671. * @returns the Angle value in degrees (float)
  4672. */
  4673. degrees(): number;
  4674. /**
  4675. * Get value in radians
  4676. * @returns the Angle value in radians (float)
  4677. */
  4678. radians(): number;
  4679. /**
  4680. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4681. * @param a defines first vector
  4682. * @param b defines second vector
  4683. * @returns a new Angle
  4684. */
  4685. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4686. /**
  4687. * Gets a new Angle object from the given float in radians
  4688. * @param radians defines the angle value in radians
  4689. * @returns a new Angle
  4690. */
  4691. static FromRadians(radians: number): Angle;
  4692. /**
  4693. * Gets a new Angle object from the given float in degrees
  4694. * @param degrees defines the angle value in degrees
  4695. * @returns a new Angle
  4696. */
  4697. static FromDegrees(degrees: number): Angle;
  4698. }
  4699. /**
  4700. * This represents an arc in a 2d space.
  4701. */
  4702. export class Arc2 {
  4703. /** Defines the start point of the arc */
  4704. startPoint: Vector2;
  4705. /** Defines the mid point of the arc */
  4706. midPoint: Vector2;
  4707. /** Defines the end point of the arc */
  4708. endPoint: Vector2;
  4709. /**
  4710. * Defines the center point of the arc.
  4711. */
  4712. centerPoint: Vector2;
  4713. /**
  4714. * Defines the radius of the arc.
  4715. */
  4716. radius: number;
  4717. /**
  4718. * Defines the angle of the arc (from mid point to end point).
  4719. */
  4720. angle: Angle;
  4721. /**
  4722. * Defines the start angle of the arc (from start point to middle point).
  4723. */
  4724. startAngle: Angle;
  4725. /**
  4726. * Defines the orientation of the arc (clock wise/counter clock wise).
  4727. */
  4728. orientation: Orientation;
  4729. /**
  4730. * Creates an Arc object from the three given points : start, middle and end.
  4731. * @param startPoint Defines the start point of the arc
  4732. * @param midPoint Defines the midlle point of the arc
  4733. * @param endPoint Defines the end point of the arc
  4734. */
  4735. constructor(
  4736. /** Defines the start point of the arc */
  4737. startPoint: Vector2,
  4738. /** Defines the mid point of the arc */
  4739. midPoint: Vector2,
  4740. /** Defines the end point of the arc */
  4741. endPoint: Vector2);
  4742. }
  4743. /**
  4744. * Represents a 2D path made up of multiple 2D points
  4745. */
  4746. export class Path2 {
  4747. private _points;
  4748. private _length;
  4749. /**
  4750. * If the path start and end point are the same
  4751. */
  4752. closed: boolean;
  4753. /**
  4754. * Creates a Path2 object from the starting 2D coordinates x and y.
  4755. * @param x the starting points x value
  4756. * @param y the starting points y value
  4757. */
  4758. constructor(x: number, y: number);
  4759. /**
  4760. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4761. * @param x the added points x value
  4762. * @param y the added points y value
  4763. * @returns the updated Path2.
  4764. */
  4765. addLineTo(x: number, y: number): Path2;
  4766. /**
  4767. * 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.
  4768. * @param midX middle point x value
  4769. * @param midY middle point y value
  4770. * @param endX end point x value
  4771. * @param endY end point y value
  4772. * @param numberOfSegments (default: 36)
  4773. * @returns the updated Path2.
  4774. */
  4775. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4776. /**
  4777. * Closes the Path2.
  4778. * @returns the Path2.
  4779. */
  4780. close(): Path2;
  4781. /**
  4782. * Gets the sum of the distance between each sequential point in the path
  4783. * @returns the Path2 total length (float).
  4784. */
  4785. length(): number;
  4786. /**
  4787. * Gets the points which construct the path
  4788. * @returns the Path2 internal array of points.
  4789. */
  4790. getPoints(): Vector2[];
  4791. /**
  4792. * Retreives the point at the distance aways from the starting point
  4793. * @param normalizedLengthPosition the length along the path to retreive the point from
  4794. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4795. */
  4796. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4797. /**
  4798. * Creates a new path starting from an x and y position
  4799. * @param x starting x value
  4800. * @param y starting y value
  4801. * @returns a new Path2 starting at the coordinates (x, y).
  4802. */
  4803. static StartingAt(x: number, y: number): Path2;
  4804. }
  4805. /**
  4806. * Represents a 3D path made up of multiple 3D points
  4807. */
  4808. export class Path3D {
  4809. /**
  4810. * an array of Vector3, the curve axis of the Path3D
  4811. */
  4812. path: Vector3[];
  4813. private _curve;
  4814. private _distances;
  4815. private _tangents;
  4816. private _normals;
  4817. private _binormals;
  4818. private _raw;
  4819. private _alignTangentsWithPath;
  4820. private readonly _pointAtData;
  4821. /**
  4822. * new Path3D(path, normal, raw)
  4823. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4824. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4825. * @param path an array of Vector3, the curve axis of the Path3D
  4826. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4827. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4828. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4829. */
  4830. constructor(
  4831. /**
  4832. * an array of Vector3, the curve axis of the Path3D
  4833. */
  4834. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4835. /**
  4836. * Returns the Path3D array of successive Vector3 designing its curve.
  4837. * @returns the Path3D array of successive Vector3 designing its curve.
  4838. */
  4839. getCurve(): Vector3[];
  4840. /**
  4841. * Returns the Path3D array of successive Vector3 designing its curve.
  4842. * @returns the Path3D array of successive Vector3 designing its curve.
  4843. */
  4844. getPoints(): Vector3[];
  4845. /**
  4846. * @returns the computed length (float) of the path.
  4847. */
  4848. length(): number;
  4849. /**
  4850. * Returns an array populated with tangent vectors on each Path3D curve point.
  4851. * @returns an array populated with tangent vectors on each Path3D curve point.
  4852. */
  4853. getTangents(): Vector3[];
  4854. /**
  4855. * Returns an array populated with normal vectors on each Path3D curve point.
  4856. * @returns an array populated with normal vectors on each Path3D curve point.
  4857. */
  4858. getNormals(): Vector3[];
  4859. /**
  4860. * Returns an array populated with binormal vectors on each Path3D curve point.
  4861. * @returns an array populated with binormal vectors on each Path3D curve point.
  4862. */
  4863. getBinormals(): Vector3[];
  4864. /**
  4865. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4866. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4867. */
  4868. getDistances(): number[];
  4869. /**
  4870. * Returns an interpolated point along this path
  4871. * @param position the position of the point along this path, from 0.0 to 1.0
  4872. * @returns a new Vector3 as the point
  4873. */
  4874. getPointAt(position: number): Vector3;
  4875. /**
  4876. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4877. * @param position the position of the point along this path, from 0.0 to 1.0
  4878. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4879. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4880. */
  4881. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4882. /**
  4883. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4884. * @param position the position of the point along this path, from 0.0 to 1.0
  4885. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4886. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4887. */
  4888. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4889. /**
  4890. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4891. * @param position the position of the point along this path, from 0.0 to 1.0
  4892. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4893. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4894. */
  4895. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4896. /**
  4897. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4898. * @param position the position of the point along this path, from 0.0 to 1.0
  4899. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4900. */
  4901. getDistanceAt(position: number): number;
  4902. /**
  4903. * Returns the array index of the previous point of an interpolated point along this path
  4904. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4905. * @returns the array index
  4906. */
  4907. getPreviousPointIndexAt(position: number): number;
  4908. /**
  4909. * 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)
  4910. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4911. * @returns the sub position
  4912. */
  4913. getSubPositionAt(position: number): number;
  4914. /**
  4915. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4916. * @param target the vector of which to get the closest position to
  4917. * @returns the position of the closest virtual point on this path to the target vector
  4918. */
  4919. getClosestPositionTo(target: Vector3): number;
  4920. /**
  4921. * Returns a sub path (slice) of this path
  4922. * @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
  4923. * @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
  4924. * @returns a sub path (slice) of this path
  4925. */
  4926. slice(start?: number, end?: number): Path3D;
  4927. /**
  4928. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4929. * @param path path which all values are copied into the curves points
  4930. * @param firstNormal which should be projected onto the curve
  4931. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4932. * @returns the same object updated.
  4933. */
  4934. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4935. private _compute;
  4936. private _getFirstNonNullVector;
  4937. private _getLastNonNullVector;
  4938. private _normalVector;
  4939. /**
  4940. * Updates the point at data for an interpolated point along this curve
  4941. * @param position the position of the point along this curve, from 0.0 to 1.0
  4942. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4943. * @returns the (updated) point at data
  4944. */
  4945. private _updatePointAtData;
  4946. /**
  4947. * Updates the point at data from the specified parameters
  4948. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4949. * @param point the interpolated point
  4950. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4951. */
  4952. private _setPointAtData;
  4953. /**
  4954. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4955. */
  4956. private _updateInterpolationMatrix;
  4957. }
  4958. /**
  4959. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4960. * A Curve3 is designed from a series of successive Vector3.
  4961. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4962. */
  4963. export class Curve3 {
  4964. private _points;
  4965. private _length;
  4966. /**
  4967. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4968. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4969. * @param v1 (Vector3) the control point
  4970. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4971. * @param nbPoints (integer) the wanted number of points in the curve
  4972. * @returns the created Curve3
  4973. */
  4974. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4975. /**
  4976. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4977. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4978. * @param v1 (Vector3) the first control point
  4979. * @param v2 (Vector3) the second control point
  4980. * @param v3 (Vector3) the end point of the Cubic Bezier
  4981. * @param nbPoints (integer) the wanted number of points in the curve
  4982. * @returns the created Curve3
  4983. */
  4984. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4985. /**
  4986. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4987. * @param p1 (Vector3) the origin point of the Hermite Spline
  4988. * @param t1 (Vector3) the tangent vector at the origin point
  4989. * @param p2 (Vector3) the end point of the Hermite Spline
  4990. * @param t2 (Vector3) the tangent vector at the end point
  4991. * @param nbPoints (integer) the wanted number of points in the curve
  4992. * @returns the created Curve3
  4993. */
  4994. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4995. /**
  4996. * Returns a Curve3 object along a CatmullRom Spline curve :
  4997. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4998. * @param nbPoints (integer) the wanted number of points between each curve control points
  4999. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5000. * @returns the created Curve3
  5001. */
  5002. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5003. /**
  5004. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5005. * A Curve3 is designed from a series of successive Vector3.
  5006. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5007. * @param points points which make up the curve
  5008. */
  5009. constructor(points: Vector3[]);
  5010. /**
  5011. * @returns the Curve3 stored array of successive Vector3
  5012. */
  5013. getPoints(): Vector3[];
  5014. /**
  5015. * @returns the computed length (float) of the curve.
  5016. */
  5017. length(): number;
  5018. /**
  5019. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5020. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5021. * curveA and curveB keep unchanged.
  5022. * @param curve the curve to continue from this curve
  5023. * @returns the newly constructed curve
  5024. */
  5025. continue(curve: DeepImmutable<Curve3>): Curve3;
  5026. private _computeLength;
  5027. }
  5028. }
  5029. declare module BABYLON {
  5030. /**
  5031. * This represents the main contract an easing function should follow.
  5032. * Easing functions are used throughout the animation system.
  5033. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5034. */
  5035. export interface IEasingFunction {
  5036. /**
  5037. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5038. * of the easing function.
  5039. * The link below provides some of the most common examples of easing functions.
  5040. * @see https://easings.net/
  5041. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5042. * @returns the corresponding value on the curve defined by the easing function
  5043. */
  5044. ease(gradient: number): number;
  5045. }
  5046. /**
  5047. * Base class used for every default easing function.
  5048. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5049. */
  5050. export class EasingFunction implements IEasingFunction {
  5051. /**
  5052. * Interpolation follows the mathematical formula associated with the easing function.
  5053. */
  5054. static readonly EASINGMODE_EASEIN: number;
  5055. /**
  5056. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5057. */
  5058. static readonly EASINGMODE_EASEOUT: number;
  5059. /**
  5060. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5061. */
  5062. static readonly EASINGMODE_EASEINOUT: number;
  5063. private _easingMode;
  5064. /**
  5065. * Sets the easing mode of the current function.
  5066. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5067. */
  5068. setEasingMode(easingMode: number): void;
  5069. /**
  5070. * Gets the current easing mode.
  5071. * @returns the easing mode
  5072. */
  5073. getEasingMode(): number;
  5074. /**
  5075. * @hidden
  5076. */
  5077. easeInCore(gradient: number): number;
  5078. /**
  5079. * Given an input gradient between 0 and 1, this returns the corresponding value
  5080. * of the easing function.
  5081. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5082. * @returns the corresponding value on the curve defined by the easing function
  5083. */
  5084. ease(gradient: number): number;
  5085. }
  5086. /**
  5087. * Easing function with a circle shape (see link below).
  5088. * @see https://easings.net/#easeInCirc
  5089. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5090. */
  5091. export class CircleEase extends EasingFunction implements IEasingFunction {
  5092. /** @hidden */
  5093. easeInCore(gradient: number): number;
  5094. }
  5095. /**
  5096. * Easing function with a ease back shape (see link below).
  5097. * @see https://easings.net/#easeInBack
  5098. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5099. */
  5100. export class BackEase extends EasingFunction implements IEasingFunction {
  5101. /** Defines the amplitude of the function */
  5102. amplitude: number;
  5103. /**
  5104. * Instantiates a back ease easing
  5105. * @see https://easings.net/#easeInBack
  5106. * @param amplitude Defines the amplitude of the function
  5107. */
  5108. constructor(
  5109. /** Defines the amplitude of the function */
  5110. amplitude?: number);
  5111. /** @hidden */
  5112. easeInCore(gradient: number): number;
  5113. }
  5114. /**
  5115. * Easing function with a bouncing shape (see link below).
  5116. * @see https://easings.net/#easeInBounce
  5117. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5118. */
  5119. export class BounceEase extends EasingFunction implements IEasingFunction {
  5120. /** Defines the number of bounces */
  5121. bounces: number;
  5122. /** Defines the amplitude of the bounce */
  5123. bounciness: number;
  5124. /**
  5125. * Instantiates a bounce easing
  5126. * @see https://easings.net/#easeInBounce
  5127. * @param bounces Defines the number of bounces
  5128. * @param bounciness Defines the amplitude of the bounce
  5129. */
  5130. constructor(
  5131. /** Defines the number of bounces */
  5132. bounces?: number,
  5133. /** Defines the amplitude of the bounce */
  5134. bounciness?: number);
  5135. /** @hidden */
  5136. easeInCore(gradient: number): number;
  5137. }
  5138. /**
  5139. * Easing function with a power of 3 shape (see link below).
  5140. * @see https://easings.net/#easeInCubic
  5141. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5142. */
  5143. export class CubicEase extends EasingFunction implements IEasingFunction {
  5144. /** @hidden */
  5145. easeInCore(gradient: number): number;
  5146. }
  5147. /**
  5148. * Easing function with an elastic shape (see link below).
  5149. * @see https://easings.net/#easeInElastic
  5150. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5151. */
  5152. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5153. /** Defines the number of oscillations*/
  5154. oscillations: number;
  5155. /** Defines the amplitude of the oscillations*/
  5156. springiness: number;
  5157. /**
  5158. * Instantiates an elastic easing function
  5159. * @see https://easings.net/#easeInElastic
  5160. * @param oscillations Defines the number of oscillations
  5161. * @param springiness Defines the amplitude of the oscillations
  5162. */
  5163. constructor(
  5164. /** Defines the number of oscillations*/
  5165. oscillations?: number,
  5166. /** Defines the amplitude of the oscillations*/
  5167. springiness?: number);
  5168. /** @hidden */
  5169. easeInCore(gradient: number): number;
  5170. }
  5171. /**
  5172. * Easing function with an exponential shape (see link below).
  5173. * @see https://easings.net/#easeInExpo
  5174. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5175. */
  5176. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5177. /** Defines the exponent of the function */
  5178. exponent: number;
  5179. /**
  5180. * Instantiates an exponential easing function
  5181. * @see https://easings.net/#easeInExpo
  5182. * @param exponent Defines the exponent of the function
  5183. */
  5184. constructor(
  5185. /** Defines the exponent of the function */
  5186. exponent?: number);
  5187. /** @hidden */
  5188. easeInCore(gradient: number): number;
  5189. }
  5190. /**
  5191. * Easing function with a power shape (see link below).
  5192. * @see https://easings.net/#easeInQuad
  5193. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5194. */
  5195. export class PowerEase extends EasingFunction implements IEasingFunction {
  5196. /** Defines the power of the function */
  5197. power: number;
  5198. /**
  5199. * Instantiates an power base easing function
  5200. * @see https://easings.net/#easeInQuad
  5201. * @param power Defines the power of the function
  5202. */
  5203. constructor(
  5204. /** Defines the power of the function */
  5205. power?: number);
  5206. /** @hidden */
  5207. easeInCore(gradient: number): number;
  5208. }
  5209. /**
  5210. * Easing function with a power of 2 shape (see link below).
  5211. * @see https://easings.net/#easeInQuad
  5212. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5213. */
  5214. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5215. /** @hidden */
  5216. easeInCore(gradient: number): number;
  5217. }
  5218. /**
  5219. * Easing function with a power of 4 shape (see link below).
  5220. * @see https://easings.net/#easeInQuart
  5221. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5222. */
  5223. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5224. /** @hidden */
  5225. easeInCore(gradient: number): number;
  5226. }
  5227. /**
  5228. * Easing function with a power of 5 shape (see link below).
  5229. * @see https://easings.net/#easeInQuint
  5230. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5233. /** @hidden */
  5234. easeInCore(gradient: number): number;
  5235. }
  5236. /**
  5237. * Easing function with a sin shape (see link below).
  5238. * @see https://easings.net/#easeInSine
  5239. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5240. */
  5241. export class SineEase extends EasingFunction implements IEasingFunction {
  5242. /** @hidden */
  5243. easeInCore(gradient: number): number;
  5244. }
  5245. /**
  5246. * Easing function with a bezier shape (see link below).
  5247. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5248. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5249. */
  5250. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5251. /** Defines the x component of the start tangent in the bezier curve */
  5252. x1: number;
  5253. /** Defines the y component of the start tangent in the bezier curve */
  5254. y1: number;
  5255. /** Defines the x component of the end tangent in the bezier curve */
  5256. x2: number;
  5257. /** Defines the y component of the end tangent in the bezier curve */
  5258. y2: number;
  5259. /**
  5260. * Instantiates a bezier function
  5261. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5262. * @param x1 Defines the x component of the start tangent in the bezier curve
  5263. * @param y1 Defines the y component of the start tangent in the bezier curve
  5264. * @param x2 Defines the x component of the end tangent in the bezier curve
  5265. * @param y2 Defines the y component of the end tangent in the bezier curve
  5266. */
  5267. constructor(
  5268. /** Defines the x component of the start tangent in the bezier curve */
  5269. x1?: number,
  5270. /** Defines the y component of the start tangent in the bezier curve */
  5271. y1?: number,
  5272. /** Defines the x component of the end tangent in the bezier curve */
  5273. x2?: number,
  5274. /** Defines the y component of the end tangent in the bezier curve */
  5275. y2?: number);
  5276. /** @hidden */
  5277. easeInCore(gradient: number): number;
  5278. }
  5279. }
  5280. declare module BABYLON {
  5281. /**
  5282. * Class used to hold a RBG color
  5283. */
  5284. export class Color3 {
  5285. /**
  5286. * Defines the red component (between 0 and 1, default is 0)
  5287. */
  5288. r: number;
  5289. /**
  5290. * Defines the green component (between 0 and 1, default is 0)
  5291. */
  5292. g: number;
  5293. /**
  5294. * Defines the blue component (between 0 and 1, default is 0)
  5295. */
  5296. b: number;
  5297. /**
  5298. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5299. * @param r defines the red component (between 0 and 1, default is 0)
  5300. * @param g defines the green component (between 0 and 1, default is 0)
  5301. * @param b defines the blue component (between 0 and 1, default is 0)
  5302. */
  5303. constructor(
  5304. /**
  5305. * Defines the red component (between 0 and 1, default is 0)
  5306. */
  5307. r?: number,
  5308. /**
  5309. * Defines the green component (between 0 and 1, default is 0)
  5310. */
  5311. g?: number,
  5312. /**
  5313. * Defines the blue component (between 0 and 1, default is 0)
  5314. */
  5315. b?: number);
  5316. /**
  5317. * Creates a string with the Color3 current values
  5318. * @returns the string representation of the Color3 object
  5319. */
  5320. toString(): string;
  5321. /**
  5322. * Returns the string "Color3"
  5323. * @returns "Color3"
  5324. */
  5325. getClassName(): string;
  5326. /**
  5327. * Compute the Color3 hash code
  5328. * @returns an unique number that can be used to hash Color3 objects
  5329. */
  5330. getHashCode(): number;
  5331. /**
  5332. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5333. * @param array defines the array where to store the r,g,b components
  5334. * @param index defines an optional index in the target array to define where to start storing values
  5335. * @returns the current Color3 object
  5336. */
  5337. toArray(array: FloatArray, index?: number): Color3;
  5338. /**
  5339. * Returns a new Color4 object from the current Color3 and the given alpha
  5340. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5341. * @returns a new Color4 object
  5342. */
  5343. toColor4(alpha?: number): Color4;
  5344. /**
  5345. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5346. * @returns the new array
  5347. */
  5348. asArray(): number[];
  5349. /**
  5350. * Returns the luminance value
  5351. * @returns a float value
  5352. */
  5353. toLuminance(): number;
  5354. /**
  5355. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5356. * @param otherColor defines the second operand
  5357. * @returns the new Color3 object
  5358. */
  5359. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5360. /**
  5361. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5362. * @param otherColor defines the second operand
  5363. * @param result defines the Color3 object where to store the result
  5364. * @returns the current Color3
  5365. */
  5366. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5367. /**
  5368. * Determines equality between Color3 objects
  5369. * @param otherColor defines the second operand
  5370. * @returns true if the rgb values are equal to the given ones
  5371. */
  5372. equals(otherColor: DeepImmutable<Color3>): boolean;
  5373. /**
  5374. * Determines equality between the current Color3 object and a set of r,b,g values
  5375. * @param r defines the red component to check
  5376. * @param g defines the green component to check
  5377. * @param b defines the blue component to check
  5378. * @returns true if the rgb values are equal to the given ones
  5379. */
  5380. equalsFloats(r: number, g: number, b: number): boolean;
  5381. /**
  5382. * Multiplies in place each rgb value by scale
  5383. * @param scale defines the scaling factor
  5384. * @returns the updated Color3
  5385. */
  5386. scale(scale: number): Color3;
  5387. /**
  5388. * Multiplies the rgb values by scale and stores the result into "result"
  5389. * @param scale defines the scaling factor
  5390. * @param result defines the Color3 object where to store the result
  5391. * @returns the unmodified current Color3
  5392. */
  5393. scaleToRef(scale: number, result: Color3): Color3;
  5394. /**
  5395. * Scale the current Color3 values by a factor and add the result to a given Color3
  5396. * @param scale defines the scale factor
  5397. * @param result defines color to store the result into
  5398. * @returns the unmodified current Color3
  5399. */
  5400. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5401. /**
  5402. * Clamps the rgb values by the min and max values and stores the result into "result"
  5403. * @param min defines minimum clamping value (default is 0)
  5404. * @param max defines maximum clamping value (default is 1)
  5405. * @param result defines color to store the result into
  5406. * @returns the original Color3
  5407. */
  5408. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5409. /**
  5410. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5411. * @param otherColor defines the second operand
  5412. * @returns the new Color3
  5413. */
  5414. add(otherColor: DeepImmutable<Color3>): Color3;
  5415. /**
  5416. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5417. * @param otherColor defines the second operand
  5418. * @param result defines Color3 object to store the result into
  5419. * @returns the unmodified current Color3
  5420. */
  5421. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5422. /**
  5423. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5424. * @param otherColor defines the second operand
  5425. * @returns the new Color3
  5426. */
  5427. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5428. /**
  5429. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5430. * @param otherColor defines the second operand
  5431. * @param result defines Color3 object to store the result into
  5432. * @returns the unmodified current Color3
  5433. */
  5434. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5435. /**
  5436. * Copy the current object
  5437. * @returns a new Color3 copied the current one
  5438. */
  5439. clone(): Color3;
  5440. /**
  5441. * Copies the rgb values from the source in the current Color3
  5442. * @param source defines the source Color3 object
  5443. * @returns the updated Color3 object
  5444. */
  5445. copyFrom(source: DeepImmutable<Color3>): Color3;
  5446. /**
  5447. * Updates the Color3 rgb values from the given floats
  5448. * @param r defines the red component to read from
  5449. * @param g defines the green component to read from
  5450. * @param b defines the blue component to read from
  5451. * @returns the current Color3 object
  5452. */
  5453. copyFromFloats(r: number, g: number, b: number): Color3;
  5454. /**
  5455. * Updates the Color3 rgb values from the given floats
  5456. * @param r defines the red component to read from
  5457. * @param g defines the green component to read from
  5458. * @param b defines the blue component to read from
  5459. * @returns the current Color3 object
  5460. */
  5461. set(r: number, g: number, b: number): Color3;
  5462. /**
  5463. * Compute the Color3 hexadecimal code as a string
  5464. * @returns a string containing the hexadecimal representation of the Color3 object
  5465. */
  5466. toHexString(): string;
  5467. /**
  5468. * Computes a new Color3 converted from the current one to linear space
  5469. * @returns a new Color3 object
  5470. */
  5471. toLinearSpace(): Color3;
  5472. /**
  5473. * Converts current color in rgb space to HSV values
  5474. * @returns a new color3 representing the HSV values
  5475. */
  5476. toHSV(): Color3;
  5477. /**
  5478. * Converts current color in rgb space to HSV values
  5479. * @param result defines the Color3 where to store the HSV values
  5480. */
  5481. toHSVToRef(result: Color3): void;
  5482. /**
  5483. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5484. * @param convertedColor defines the Color3 object where to store the linear space version
  5485. * @returns the unmodified Color3
  5486. */
  5487. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5488. /**
  5489. * Computes a new Color3 converted from the current one to gamma space
  5490. * @returns a new Color3 object
  5491. */
  5492. toGammaSpace(): Color3;
  5493. /**
  5494. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5495. * @param convertedColor defines the Color3 object where to store the gamma space version
  5496. * @returns the unmodified Color3
  5497. */
  5498. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5499. private static _BlackReadOnly;
  5500. /**
  5501. * Convert Hue, saturation and value to a Color3 (RGB)
  5502. * @param hue defines the hue
  5503. * @param saturation defines the saturation
  5504. * @param value defines the value
  5505. * @param result defines the Color3 where to store the RGB values
  5506. */
  5507. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5508. /**
  5509. * Creates a new Color3 from the string containing valid hexadecimal values
  5510. * @param hex defines a string containing valid hexadecimal values
  5511. * @returns a new Color3 object
  5512. */
  5513. static FromHexString(hex: string): Color3;
  5514. /**
  5515. * Creates a new Color3 from the starting index of the given array
  5516. * @param array defines the source array
  5517. * @param offset defines an offset in the source array
  5518. * @returns a new Color3 object
  5519. */
  5520. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5521. /**
  5522. * Creates a new Color3 from integer values (< 256)
  5523. * @param r defines the red component to read from (value between 0 and 255)
  5524. * @param g defines the green component to read from (value between 0 and 255)
  5525. * @param b defines the blue component to read from (value between 0 and 255)
  5526. * @returns a new Color3 object
  5527. */
  5528. static FromInts(r: number, g: number, b: number): Color3;
  5529. /**
  5530. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5531. * @param start defines the start Color3 value
  5532. * @param end defines the end Color3 value
  5533. * @param amount defines the gradient value between start and end
  5534. * @returns a new Color3 object
  5535. */
  5536. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5537. /**
  5538. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5539. * @param left defines the start value
  5540. * @param right defines the end value
  5541. * @param amount defines the gradient factor
  5542. * @param result defines the Color3 object where to store the result
  5543. */
  5544. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5545. /**
  5546. * Returns a Color3 value containing a red color
  5547. * @returns a new Color3 object
  5548. */
  5549. static Red(): Color3;
  5550. /**
  5551. * Returns a Color3 value containing a green color
  5552. * @returns a new Color3 object
  5553. */
  5554. static Green(): Color3;
  5555. /**
  5556. * Returns a Color3 value containing a blue color
  5557. * @returns a new Color3 object
  5558. */
  5559. static Blue(): Color3;
  5560. /**
  5561. * Returns a Color3 value containing a black color
  5562. * @returns a new Color3 object
  5563. */
  5564. static Black(): Color3;
  5565. /**
  5566. * Gets a Color3 value containing a black color that must not be updated
  5567. */
  5568. static get BlackReadOnly(): DeepImmutable<Color3>;
  5569. /**
  5570. * Returns a Color3 value containing a white color
  5571. * @returns a new Color3 object
  5572. */
  5573. static White(): Color3;
  5574. /**
  5575. * Returns a Color3 value containing a purple color
  5576. * @returns a new Color3 object
  5577. */
  5578. static Purple(): Color3;
  5579. /**
  5580. * Returns a Color3 value containing a magenta color
  5581. * @returns a new Color3 object
  5582. */
  5583. static Magenta(): Color3;
  5584. /**
  5585. * Returns a Color3 value containing a yellow color
  5586. * @returns a new Color3 object
  5587. */
  5588. static Yellow(): Color3;
  5589. /**
  5590. * Returns a Color3 value containing a gray color
  5591. * @returns a new Color3 object
  5592. */
  5593. static Gray(): Color3;
  5594. /**
  5595. * Returns a Color3 value containing a teal color
  5596. * @returns a new Color3 object
  5597. */
  5598. static Teal(): Color3;
  5599. /**
  5600. * Returns a Color3 value containing a random color
  5601. * @returns a new Color3 object
  5602. */
  5603. static Random(): Color3;
  5604. }
  5605. /**
  5606. * Class used to hold a RBGA color
  5607. */
  5608. export class Color4 {
  5609. /**
  5610. * Defines the red component (between 0 and 1, default is 0)
  5611. */
  5612. r: number;
  5613. /**
  5614. * Defines the green component (between 0 and 1, default is 0)
  5615. */
  5616. g: number;
  5617. /**
  5618. * Defines the blue component (between 0 and 1, default is 0)
  5619. */
  5620. b: number;
  5621. /**
  5622. * Defines the alpha component (between 0 and 1, default is 1)
  5623. */
  5624. a: number;
  5625. /**
  5626. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5627. * @param r defines the red component (between 0 and 1, default is 0)
  5628. * @param g defines the green component (between 0 and 1, default is 0)
  5629. * @param b defines the blue component (between 0 and 1, default is 0)
  5630. * @param a defines the alpha component (between 0 and 1, default is 1)
  5631. */
  5632. constructor(
  5633. /**
  5634. * Defines the red component (between 0 and 1, default is 0)
  5635. */
  5636. r?: number,
  5637. /**
  5638. * Defines the green component (between 0 and 1, default is 0)
  5639. */
  5640. g?: number,
  5641. /**
  5642. * Defines the blue component (between 0 and 1, default is 0)
  5643. */
  5644. b?: number,
  5645. /**
  5646. * Defines the alpha component (between 0 and 1, default is 1)
  5647. */
  5648. a?: number);
  5649. /**
  5650. * Adds in place the given Color4 values to the current Color4 object
  5651. * @param right defines the second operand
  5652. * @returns the current updated Color4 object
  5653. */
  5654. addInPlace(right: DeepImmutable<Color4>): Color4;
  5655. /**
  5656. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5657. * @returns the new array
  5658. */
  5659. asArray(): number[];
  5660. /**
  5661. * Stores from the starting index in the given array the Color4 successive values
  5662. * @param array defines the array where to store the r,g,b components
  5663. * @param index defines an optional index in the target array to define where to start storing values
  5664. * @returns the current Color4 object
  5665. */
  5666. toArray(array: number[], index?: number): Color4;
  5667. /**
  5668. * Determines equality between Color4 objects
  5669. * @param otherColor defines the second operand
  5670. * @returns true if the rgba values are equal to the given ones
  5671. */
  5672. equals(otherColor: DeepImmutable<Color4>): boolean;
  5673. /**
  5674. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5675. * @param right defines the second operand
  5676. * @returns a new Color4 object
  5677. */
  5678. add(right: DeepImmutable<Color4>): Color4;
  5679. /**
  5680. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5681. * @param right defines the second operand
  5682. * @returns a new Color4 object
  5683. */
  5684. subtract(right: DeepImmutable<Color4>): Color4;
  5685. /**
  5686. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5687. * @param right defines the second operand
  5688. * @param result defines the Color4 object where to store the result
  5689. * @returns the current Color4 object
  5690. */
  5691. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5692. /**
  5693. * Creates a new Color4 with the current Color4 values multiplied by scale
  5694. * @param scale defines the scaling factor to apply
  5695. * @returns a new Color4 object
  5696. */
  5697. scale(scale: number): Color4;
  5698. /**
  5699. * Multiplies the current Color4 values by scale and stores the result in "result"
  5700. * @param scale defines the scaling factor to apply
  5701. * @param result defines the Color4 object where to store the result
  5702. * @returns the current unmodified Color4
  5703. */
  5704. scaleToRef(scale: number, result: Color4): Color4;
  5705. /**
  5706. * Scale the current Color4 values by a factor and add the result to a given Color4
  5707. * @param scale defines the scale factor
  5708. * @param result defines the Color4 object where to store the result
  5709. * @returns the unmodified current Color4
  5710. */
  5711. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5712. /**
  5713. * Clamps the rgb values by the min and max values and stores the result into "result"
  5714. * @param min defines minimum clamping value (default is 0)
  5715. * @param max defines maximum clamping value (default is 1)
  5716. * @param result defines color to store the result into.
  5717. * @returns the cuurent Color4
  5718. */
  5719. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5720. /**
  5721. * Multipy an Color4 value by another and return a new Color4 object
  5722. * @param color defines the Color4 value to multiply by
  5723. * @returns a new Color4 object
  5724. */
  5725. multiply(color: Color4): Color4;
  5726. /**
  5727. * Multipy a Color4 value by another and push the result in a reference value
  5728. * @param color defines the Color4 value to multiply by
  5729. * @param result defines the Color4 to fill the result in
  5730. * @returns the result Color4
  5731. */
  5732. multiplyToRef(color: Color4, result: Color4): Color4;
  5733. /**
  5734. * Creates a string with the Color4 current values
  5735. * @returns the string representation of the Color4 object
  5736. */
  5737. toString(): string;
  5738. /**
  5739. * Returns the string "Color4"
  5740. * @returns "Color4"
  5741. */
  5742. getClassName(): string;
  5743. /**
  5744. * Compute the Color4 hash code
  5745. * @returns an unique number that can be used to hash Color4 objects
  5746. */
  5747. getHashCode(): number;
  5748. /**
  5749. * Creates a new Color4 copied from the current one
  5750. * @returns a new Color4 object
  5751. */
  5752. clone(): Color4;
  5753. /**
  5754. * Copies the given Color4 values into the current one
  5755. * @param source defines the source Color4 object
  5756. * @returns the current updated Color4 object
  5757. */
  5758. copyFrom(source: Color4): Color4;
  5759. /**
  5760. * Copies the given float values into the current one
  5761. * @param r defines the red component to read from
  5762. * @param g defines the green component to read from
  5763. * @param b defines the blue component to read from
  5764. * @param a defines the alpha component to read from
  5765. * @returns the current updated Color4 object
  5766. */
  5767. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5768. /**
  5769. * Copies the given float values into the current one
  5770. * @param r defines the red component to read from
  5771. * @param g defines the green component to read from
  5772. * @param b defines the blue component to read from
  5773. * @param a defines the alpha component to read from
  5774. * @returns the current updated Color4 object
  5775. */
  5776. set(r: number, g: number, b: number, a: number): Color4;
  5777. /**
  5778. * Compute the Color4 hexadecimal code as a string
  5779. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5780. * @returns a string containing the hexadecimal representation of the Color4 object
  5781. */
  5782. toHexString(returnAsColor3?: boolean): string;
  5783. /**
  5784. * Computes a new Color4 converted from the current one to linear space
  5785. * @returns a new Color4 object
  5786. */
  5787. toLinearSpace(): Color4;
  5788. /**
  5789. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5790. * @param convertedColor defines the Color4 object where to store the linear space version
  5791. * @returns the unmodified Color4
  5792. */
  5793. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5794. /**
  5795. * Computes a new Color4 converted from the current one to gamma space
  5796. * @returns a new Color4 object
  5797. */
  5798. toGammaSpace(): Color4;
  5799. /**
  5800. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5801. * @param convertedColor defines the Color4 object where to store the gamma space version
  5802. * @returns the unmodified Color4
  5803. */
  5804. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5805. /**
  5806. * Creates a new Color4 from the string containing valid hexadecimal values
  5807. * @param hex defines a string containing valid hexadecimal values
  5808. * @returns a new Color4 object
  5809. */
  5810. static FromHexString(hex: string): Color4;
  5811. /**
  5812. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5813. * @param left defines the start value
  5814. * @param right defines the end value
  5815. * @param amount defines the gradient factor
  5816. * @returns a new Color4 object
  5817. */
  5818. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5819. /**
  5820. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5821. * @param left defines the start value
  5822. * @param right defines the end value
  5823. * @param amount defines the gradient factor
  5824. * @param result defines the Color4 object where to store data
  5825. */
  5826. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5827. /**
  5828. * Creates a new Color4 from a Color3 and an alpha value
  5829. * @param color3 defines the source Color3 to read from
  5830. * @param alpha defines the alpha component (1.0 by default)
  5831. * @returns a new Color4 object
  5832. */
  5833. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5834. /**
  5835. * Creates a new Color4 from the starting index element of the given array
  5836. * @param array defines the source array to read from
  5837. * @param offset defines the offset in the source array
  5838. * @returns a new Color4 object
  5839. */
  5840. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5841. /**
  5842. * Creates a new Color3 from integer values (< 256)
  5843. * @param r defines the red component to read from (value between 0 and 255)
  5844. * @param g defines the green component to read from (value between 0 and 255)
  5845. * @param b defines the blue component to read from (value between 0 and 255)
  5846. * @param a defines the alpha component to read from (value between 0 and 255)
  5847. * @returns a new Color3 object
  5848. */
  5849. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5850. /**
  5851. * Check the content of a given array and convert it to an array containing RGBA data
  5852. * If the original array was already containing count * 4 values then it is returned directly
  5853. * @param colors defines the array to check
  5854. * @param count defines the number of RGBA data to expect
  5855. * @returns an array containing count * 4 values (RGBA)
  5856. */
  5857. static CheckColors4(colors: number[], count: number): number[];
  5858. }
  5859. /**
  5860. * @hidden
  5861. */
  5862. export class TmpColors {
  5863. static Color3: Color3[];
  5864. static Color4: Color4[];
  5865. }
  5866. }
  5867. declare module BABYLON {
  5868. /**
  5869. * Defines an interface which represents an animation key frame
  5870. */
  5871. export interface IAnimationKey {
  5872. /**
  5873. * Frame of the key frame
  5874. */
  5875. frame: number;
  5876. /**
  5877. * Value at the specifies key frame
  5878. */
  5879. value: any;
  5880. /**
  5881. * The input tangent for the cubic hermite spline
  5882. */
  5883. inTangent?: any;
  5884. /**
  5885. * The output tangent for the cubic hermite spline
  5886. */
  5887. outTangent?: any;
  5888. /**
  5889. * The animation interpolation type
  5890. */
  5891. interpolation?: AnimationKeyInterpolation;
  5892. }
  5893. /**
  5894. * Enum for the animation key frame interpolation type
  5895. */
  5896. export enum AnimationKeyInterpolation {
  5897. /**
  5898. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5899. */
  5900. STEP = 1
  5901. }
  5902. }
  5903. declare module BABYLON {
  5904. /**
  5905. * Represents the range of an animation
  5906. */
  5907. export class AnimationRange {
  5908. /**The name of the animation range**/
  5909. name: string;
  5910. /**The starting frame of the animation */
  5911. from: number;
  5912. /**The ending frame of the animation*/
  5913. to: number;
  5914. /**
  5915. * Initializes the range of an animation
  5916. * @param name The name of the animation range
  5917. * @param from The starting frame of the animation
  5918. * @param to The ending frame of the animation
  5919. */
  5920. constructor(
  5921. /**The name of the animation range**/
  5922. name: string,
  5923. /**The starting frame of the animation */
  5924. from: number,
  5925. /**The ending frame of the animation*/
  5926. to: number);
  5927. /**
  5928. * Makes a copy of the animation range
  5929. * @returns A copy of the animation range
  5930. */
  5931. clone(): AnimationRange;
  5932. }
  5933. }
  5934. declare module BABYLON {
  5935. /**
  5936. * Composed of a frame, and an action function
  5937. */
  5938. export class AnimationEvent {
  5939. /** The frame for which the event is triggered **/
  5940. frame: number;
  5941. /** The event to perform when triggered **/
  5942. action: (currentFrame: number) => void;
  5943. /** Specifies if the event should be triggered only once**/
  5944. onlyOnce?: boolean | undefined;
  5945. /**
  5946. * Specifies if the animation event is done
  5947. */
  5948. isDone: boolean;
  5949. /**
  5950. * Initializes the animation event
  5951. * @param frame The frame for which the event is triggered
  5952. * @param action The event to perform when triggered
  5953. * @param onlyOnce Specifies if the event should be triggered only once
  5954. */
  5955. constructor(
  5956. /** The frame for which the event is triggered **/
  5957. frame: number,
  5958. /** The event to perform when triggered **/
  5959. action: (currentFrame: number) => void,
  5960. /** Specifies if the event should be triggered only once**/
  5961. onlyOnce?: boolean | undefined);
  5962. /** @hidden */
  5963. _clone(): AnimationEvent;
  5964. }
  5965. }
  5966. declare module BABYLON {
  5967. /**
  5968. * Interface used to define a behavior
  5969. */
  5970. export interface Behavior<T> {
  5971. /** gets or sets behavior's name */
  5972. name: string;
  5973. /**
  5974. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5975. */
  5976. init(): void;
  5977. /**
  5978. * Called when the behavior is attached to a target
  5979. * @param target defines the target where the behavior is attached to
  5980. */
  5981. attach(target: T): void;
  5982. /**
  5983. * Called when the behavior is detached from its target
  5984. */
  5985. detach(): void;
  5986. }
  5987. /**
  5988. * Interface implemented by classes supporting behaviors
  5989. */
  5990. export interface IBehaviorAware<T> {
  5991. /**
  5992. * Attach a behavior
  5993. * @param behavior defines the behavior to attach
  5994. * @returns the current host
  5995. */
  5996. addBehavior(behavior: Behavior<T>): T;
  5997. /**
  5998. * Remove a behavior from the current object
  5999. * @param behavior defines the behavior to detach
  6000. * @returns the current host
  6001. */
  6002. removeBehavior(behavior: Behavior<T>): T;
  6003. /**
  6004. * Gets a behavior using its name to search
  6005. * @param name defines the name to search
  6006. * @returns the behavior or null if not found
  6007. */
  6008. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6009. }
  6010. }
  6011. declare module BABYLON {
  6012. /**
  6013. * Defines an array and its length.
  6014. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6015. */
  6016. export interface ISmartArrayLike<T> {
  6017. /**
  6018. * The data of the array.
  6019. */
  6020. data: Array<T>;
  6021. /**
  6022. * The active length of the array.
  6023. */
  6024. length: number;
  6025. }
  6026. /**
  6027. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6028. */
  6029. export class SmartArray<T> implements ISmartArrayLike<T> {
  6030. /**
  6031. * The full set of data from the array.
  6032. */
  6033. data: Array<T>;
  6034. /**
  6035. * The active length of the array.
  6036. */
  6037. length: number;
  6038. protected _id: number;
  6039. /**
  6040. * Instantiates a Smart Array.
  6041. * @param capacity defines the default capacity of the array.
  6042. */
  6043. constructor(capacity: number);
  6044. /**
  6045. * Pushes a value at the end of the active data.
  6046. * @param value defines the object to push in the array.
  6047. */
  6048. push(value: T): void;
  6049. /**
  6050. * Iterates over the active data and apply the lambda to them.
  6051. * @param func defines the action to apply on each value.
  6052. */
  6053. forEach(func: (content: T) => void): void;
  6054. /**
  6055. * Sorts the full sets of data.
  6056. * @param compareFn defines the comparison function to apply.
  6057. */
  6058. sort(compareFn: (a: T, b: T) => number): void;
  6059. /**
  6060. * Resets the active data to an empty array.
  6061. */
  6062. reset(): void;
  6063. /**
  6064. * Releases all the data from the array as well as the array.
  6065. */
  6066. dispose(): void;
  6067. /**
  6068. * Concats the active data with a given array.
  6069. * @param array defines the data to concatenate with.
  6070. */
  6071. concat(array: any): void;
  6072. /**
  6073. * Returns the position of a value in the active data.
  6074. * @param value defines the value to find the index for
  6075. * @returns the index if found in the active data otherwise -1
  6076. */
  6077. indexOf(value: T): number;
  6078. /**
  6079. * Returns whether an element is part of the active data.
  6080. * @param value defines the value to look for
  6081. * @returns true if found in the active data otherwise false
  6082. */
  6083. contains(value: T): boolean;
  6084. private static _GlobalId;
  6085. }
  6086. /**
  6087. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6088. * The data in this array can only be present once
  6089. */
  6090. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6091. private _duplicateId;
  6092. /**
  6093. * Pushes a value at the end of the active data.
  6094. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6095. * @param value defines the object to push in the array.
  6096. */
  6097. push(value: T): void;
  6098. /**
  6099. * Pushes a value at the end of the active data.
  6100. * If the data is already present, it won t be added again
  6101. * @param value defines the object to push in the array.
  6102. * @returns true if added false if it was already present
  6103. */
  6104. pushNoDuplicate(value: T): boolean;
  6105. /**
  6106. * Resets the active data to an empty array.
  6107. */
  6108. reset(): void;
  6109. /**
  6110. * Concats the active data with a given array.
  6111. * This ensures no dupplicate will be present in the result.
  6112. * @param array defines the data to concatenate with.
  6113. */
  6114. concatWithNoDuplicate(array: any): void;
  6115. }
  6116. }
  6117. declare module BABYLON {
  6118. /**
  6119. * @ignore
  6120. * This is a list of all the different input types that are available in the application.
  6121. * Fo instance: ArcRotateCameraGamepadInput...
  6122. */
  6123. export var CameraInputTypes: {};
  6124. /**
  6125. * This is the contract to implement in order to create a new input class.
  6126. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6127. */
  6128. export interface ICameraInput<TCamera extends Camera> {
  6129. /**
  6130. * Defines the camera the input is attached to.
  6131. */
  6132. camera: Nullable<TCamera>;
  6133. /**
  6134. * Gets the class name of the current intput.
  6135. * @returns the class name
  6136. */
  6137. getClassName(): string;
  6138. /**
  6139. * Get the friendly name associated with the input class.
  6140. * @returns the input friendly name
  6141. */
  6142. getSimpleName(): string;
  6143. /**
  6144. * Attach the input controls to a specific dom element to get the input from.
  6145. * @param element Defines the element the controls should be listened from
  6146. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6147. */
  6148. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6149. /**
  6150. * Detach the current controls from the specified dom element.
  6151. * @param element Defines the element to stop listening the inputs from
  6152. */
  6153. detachControl(element: Nullable<HTMLElement>): void;
  6154. /**
  6155. * Update the current camera state depending on the inputs that have been used this frame.
  6156. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6157. */
  6158. checkInputs?: () => void;
  6159. }
  6160. /**
  6161. * Represents a map of input types to input instance or input index to input instance.
  6162. */
  6163. export interface CameraInputsMap<TCamera extends Camera> {
  6164. /**
  6165. * Accessor to the input by input type.
  6166. */
  6167. [name: string]: ICameraInput<TCamera>;
  6168. /**
  6169. * Accessor to the input by input index.
  6170. */
  6171. [idx: number]: ICameraInput<TCamera>;
  6172. }
  6173. /**
  6174. * This represents the input manager used within a camera.
  6175. * It helps dealing with all the different kind of input attached to a camera.
  6176. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6177. */
  6178. export class CameraInputsManager<TCamera extends Camera> {
  6179. /**
  6180. * Defines the list of inputs attahed to the camera.
  6181. */
  6182. attached: CameraInputsMap<TCamera>;
  6183. /**
  6184. * Defines the dom element the camera is collecting inputs from.
  6185. * This is null if the controls have not been attached.
  6186. */
  6187. attachedElement: Nullable<HTMLElement>;
  6188. /**
  6189. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6190. */
  6191. noPreventDefault: boolean;
  6192. /**
  6193. * Defined the camera the input manager belongs to.
  6194. */
  6195. camera: TCamera;
  6196. /**
  6197. * Update the current camera state depending on the inputs that have been used this frame.
  6198. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6199. */
  6200. checkInputs: () => void;
  6201. /**
  6202. * Instantiate a new Camera Input Manager.
  6203. * @param camera Defines the camera the input manager blongs to
  6204. */
  6205. constructor(camera: TCamera);
  6206. /**
  6207. * Add an input method to a camera
  6208. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6209. * @param input camera input method
  6210. */
  6211. add(input: ICameraInput<TCamera>): void;
  6212. /**
  6213. * Remove a specific input method from a camera
  6214. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6215. * @param inputToRemove camera input method
  6216. */
  6217. remove(inputToRemove: ICameraInput<TCamera>): void;
  6218. /**
  6219. * Remove a specific input type from a camera
  6220. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6221. * @param inputType the type of the input to remove
  6222. */
  6223. removeByType(inputType: string): void;
  6224. private _addCheckInputs;
  6225. /**
  6226. * Attach the input controls to the currently attached dom element to listen the events from.
  6227. * @param input Defines the input to attach
  6228. */
  6229. attachInput(input: ICameraInput<TCamera>): void;
  6230. /**
  6231. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6232. * @param element Defines the dom element to collect the events from
  6233. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6234. */
  6235. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6236. /**
  6237. * Detach the current manager inputs controls from a specific dom element.
  6238. * @param element Defines the dom element to collect the events from
  6239. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6240. */
  6241. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6242. /**
  6243. * Rebuild the dynamic inputCheck function from the current list of
  6244. * defined inputs in the manager.
  6245. */
  6246. rebuildInputCheck(): void;
  6247. /**
  6248. * Remove all attached input methods from a camera
  6249. */
  6250. clear(): void;
  6251. /**
  6252. * Serialize the current input manager attached to a camera.
  6253. * This ensures than once parsed,
  6254. * the input associated to the camera will be identical to the current ones
  6255. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6256. */
  6257. serialize(serializedCamera: any): void;
  6258. /**
  6259. * Parses an input manager serialized JSON to restore the previous list of inputs
  6260. * and states associated to a camera.
  6261. * @param parsedCamera Defines the JSON to parse
  6262. */
  6263. parse(parsedCamera: any): void;
  6264. }
  6265. }
  6266. declare module BABYLON {
  6267. /**
  6268. * Class used to store data that will be store in GPU memory
  6269. */
  6270. export class Buffer {
  6271. private _engine;
  6272. private _buffer;
  6273. /** @hidden */
  6274. _data: Nullable<DataArray>;
  6275. private _updatable;
  6276. private _instanced;
  6277. private _divisor;
  6278. /**
  6279. * Gets the byte stride.
  6280. */
  6281. readonly byteStride: number;
  6282. /**
  6283. * Constructor
  6284. * @param engine the engine
  6285. * @param data the data to use for this buffer
  6286. * @param updatable whether the data is updatable
  6287. * @param stride the stride (optional)
  6288. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6289. * @param instanced whether the buffer is instanced (optional)
  6290. * @param useBytes set to true if the stride in in bytes (optional)
  6291. * @param divisor sets an optional divisor for instances (1 by default)
  6292. */
  6293. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6294. /**
  6295. * Create a new VertexBuffer based on the current buffer
  6296. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6297. * @param offset defines offset in the buffer (0 by default)
  6298. * @param size defines the size in floats of attributes (position is 3 for instance)
  6299. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6300. * @param instanced defines if the vertex buffer contains indexed data
  6301. * @param useBytes defines if the offset and stride are in bytes *
  6302. * @param divisor sets an optional divisor for instances (1 by default)
  6303. * @returns the new vertex buffer
  6304. */
  6305. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6306. /**
  6307. * Gets a boolean indicating if the Buffer is updatable?
  6308. * @returns true if the buffer is updatable
  6309. */
  6310. isUpdatable(): boolean;
  6311. /**
  6312. * Gets current buffer's data
  6313. * @returns a DataArray or null
  6314. */
  6315. getData(): Nullable<DataArray>;
  6316. /**
  6317. * Gets underlying native buffer
  6318. * @returns underlying native buffer
  6319. */
  6320. getBuffer(): Nullable<DataBuffer>;
  6321. /**
  6322. * Gets the stride in float32 units (i.e. byte stride / 4).
  6323. * May not be an integer if the byte stride is not divisible by 4.
  6324. * @returns the stride in float32 units
  6325. * @deprecated Please use byteStride instead.
  6326. */
  6327. getStrideSize(): number;
  6328. /**
  6329. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6330. * @param data defines the data to store
  6331. */
  6332. create(data?: Nullable<DataArray>): void;
  6333. /** @hidden */
  6334. _rebuild(): void;
  6335. /**
  6336. * Update current buffer data
  6337. * @param data defines the data to store
  6338. */
  6339. update(data: DataArray): void;
  6340. /**
  6341. * Updates the data directly.
  6342. * @param data the new data
  6343. * @param offset the new offset
  6344. * @param vertexCount the vertex count (optional)
  6345. * @param useBytes set to true if the offset is in bytes
  6346. */
  6347. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6348. /**
  6349. * Release all resources
  6350. */
  6351. dispose(): void;
  6352. }
  6353. /**
  6354. * Specialized buffer used to store vertex data
  6355. */
  6356. export class VertexBuffer {
  6357. /** @hidden */
  6358. _buffer: Buffer;
  6359. private _kind;
  6360. private _size;
  6361. private _ownsBuffer;
  6362. private _instanced;
  6363. private _instanceDivisor;
  6364. /**
  6365. * The byte type.
  6366. */
  6367. static readonly BYTE: number;
  6368. /**
  6369. * The unsigned byte type.
  6370. */
  6371. static readonly UNSIGNED_BYTE: number;
  6372. /**
  6373. * The short type.
  6374. */
  6375. static readonly SHORT: number;
  6376. /**
  6377. * The unsigned short type.
  6378. */
  6379. static readonly UNSIGNED_SHORT: number;
  6380. /**
  6381. * The integer type.
  6382. */
  6383. static readonly INT: number;
  6384. /**
  6385. * The unsigned integer type.
  6386. */
  6387. static readonly UNSIGNED_INT: number;
  6388. /**
  6389. * The float type.
  6390. */
  6391. static readonly FLOAT: number;
  6392. /**
  6393. * Gets or sets the instance divisor when in instanced mode
  6394. */
  6395. get instanceDivisor(): number;
  6396. set instanceDivisor(value: number);
  6397. /**
  6398. * Gets the byte stride.
  6399. */
  6400. readonly byteStride: number;
  6401. /**
  6402. * Gets the byte offset.
  6403. */
  6404. readonly byteOffset: number;
  6405. /**
  6406. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6407. */
  6408. readonly normalized: boolean;
  6409. /**
  6410. * Gets the data type of each component in the array.
  6411. */
  6412. readonly type: number;
  6413. /**
  6414. * Constructor
  6415. * @param engine the engine
  6416. * @param data the data to use for this vertex buffer
  6417. * @param kind the vertex buffer kind
  6418. * @param updatable whether the data is updatable
  6419. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6420. * @param stride the stride (optional)
  6421. * @param instanced whether the buffer is instanced (optional)
  6422. * @param offset the offset of the data (optional)
  6423. * @param size the number of components (optional)
  6424. * @param type the type of the component (optional)
  6425. * @param normalized whether the data contains normalized data (optional)
  6426. * @param useBytes set to true if stride and offset are in bytes (optional)
  6427. * @param divisor defines the instance divisor to use (1 by default)
  6428. */
  6429. 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);
  6430. /** @hidden */
  6431. _rebuild(): void;
  6432. /**
  6433. * Returns the kind of the VertexBuffer (string)
  6434. * @returns a string
  6435. */
  6436. getKind(): string;
  6437. /**
  6438. * Gets a boolean indicating if the VertexBuffer is updatable?
  6439. * @returns true if the buffer is updatable
  6440. */
  6441. isUpdatable(): boolean;
  6442. /**
  6443. * Gets current buffer's data
  6444. * @returns a DataArray or null
  6445. */
  6446. getData(): Nullable<DataArray>;
  6447. /**
  6448. * Gets underlying native buffer
  6449. * @returns underlying native buffer
  6450. */
  6451. getBuffer(): Nullable<DataBuffer>;
  6452. /**
  6453. * Gets the stride in float32 units (i.e. byte stride / 4).
  6454. * May not be an integer if the byte stride is not divisible by 4.
  6455. * @returns the stride in float32 units
  6456. * @deprecated Please use byteStride instead.
  6457. */
  6458. getStrideSize(): number;
  6459. /**
  6460. * Returns the offset as a multiple of the type byte length.
  6461. * @returns the offset in bytes
  6462. * @deprecated Please use byteOffset instead.
  6463. */
  6464. getOffset(): number;
  6465. /**
  6466. * Returns the number of components per vertex attribute (integer)
  6467. * @returns the size in float
  6468. */
  6469. getSize(): number;
  6470. /**
  6471. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6472. * @returns true if this buffer is instanced
  6473. */
  6474. getIsInstanced(): boolean;
  6475. /**
  6476. * Returns the instancing divisor, zero for non-instanced (integer).
  6477. * @returns a number
  6478. */
  6479. getInstanceDivisor(): number;
  6480. /**
  6481. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6482. * @param data defines the data to store
  6483. */
  6484. create(data?: DataArray): void;
  6485. /**
  6486. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6487. * This function will create a new buffer if the current one is not updatable
  6488. * @param data defines the data to store
  6489. */
  6490. update(data: DataArray): void;
  6491. /**
  6492. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6493. * Returns the directly updated WebGLBuffer.
  6494. * @param data the new data
  6495. * @param offset the new offset
  6496. * @param useBytes set to true if the offset is in bytes
  6497. */
  6498. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6499. /**
  6500. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6501. */
  6502. dispose(): void;
  6503. /**
  6504. * Enumerates each value of this vertex buffer as numbers.
  6505. * @param count the number of values to enumerate
  6506. * @param callback the callback function called for each value
  6507. */
  6508. forEach(count: number, callback: (value: number, index: number) => void): void;
  6509. /**
  6510. * Positions
  6511. */
  6512. static readonly PositionKind: string;
  6513. /**
  6514. * Normals
  6515. */
  6516. static readonly NormalKind: string;
  6517. /**
  6518. * Tangents
  6519. */
  6520. static readonly TangentKind: string;
  6521. /**
  6522. * Texture coordinates
  6523. */
  6524. static readonly UVKind: string;
  6525. /**
  6526. * Texture coordinates 2
  6527. */
  6528. static readonly UV2Kind: string;
  6529. /**
  6530. * Texture coordinates 3
  6531. */
  6532. static readonly UV3Kind: string;
  6533. /**
  6534. * Texture coordinates 4
  6535. */
  6536. static readonly UV4Kind: string;
  6537. /**
  6538. * Texture coordinates 5
  6539. */
  6540. static readonly UV5Kind: string;
  6541. /**
  6542. * Texture coordinates 6
  6543. */
  6544. static readonly UV6Kind: string;
  6545. /**
  6546. * Colors
  6547. */
  6548. static readonly ColorKind: string;
  6549. /**
  6550. * Matrix indices (for bones)
  6551. */
  6552. static readonly MatricesIndicesKind: string;
  6553. /**
  6554. * Matrix weights (for bones)
  6555. */
  6556. static readonly MatricesWeightsKind: string;
  6557. /**
  6558. * Additional matrix indices (for bones)
  6559. */
  6560. static readonly MatricesIndicesExtraKind: string;
  6561. /**
  6562. * Additional matrix weights (for bones)
  6563. */
  6564. static readonly MatricesWeightsExtraKind: string;
  6565. /**
  6566. * Deduces the stride given a kind.
  6567. * @param kind The kind string to deduce
  6568. * @returns The deduced stride
  6569. */
  6570. static DeduceStride(kind: string): number;
  6571. /**
  6572. * Gets the byte length of the given type.
  6573. * @param type the type
  6574. * @returns the number of bytes
  6575. */
  6576. static GetTypeByteLength(type: number): number;
  6577. /**
  6578. * Enumerates each value of the given parameters as numbers.
  6579. * @param data the data to enumerate
  6580. * @param byteOffset the byte offset of the data
  6581. * @param byteStride the byte stride of the data
  6582. * @param componentCount the number of components per element
  6583. * @param componentType the type of the component
  6584. * @param count the number of values to enumerate
  6585. * @param normalized whether the data is normalized
  6586. * @param callback the callback function called for each value
  6587. */
  6588. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6589. private static _GetFloatValue;
  6590. }
  6591. }
  6592. declare module BABYLON {
  6593. /**
  6594. * @hidden
  6595. */
  6596. export class IntersectionInfo {
  6597. bu: Nullable<number>;
  6598. bv: Nullable<number>;
  6599. distance: number;
  6600. faceId: number;
  6601. subMeshId: number;
  6602. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6603. }
  6604. }
  6605. declare module BABYLON {
  6606. /**
  6607. * Represens a plane by the equation ax + by + cz + d = 0
  6608. */
  6609. export class Plane {
  6610. private static _TmpMatrix;
  6611. /**
  6612. * Normal of the plane (a,b,c)
  6613. */
  6614. normal: Vector3;
  6615. /**
  6616. * d component of the plane
  6617. */
  6618. d: number;
  6619. /**
  6620. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6621. * @param a a component of the plane
  6622. * @param b b component of the plane
  6623. * @param c c component of the plane
  6624. * @param d d component of the plane
  6625. */
  6626. constructor(a: number, b: number, c: number, d: number);
  6627. /**
  6628. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6629. */
  6630. asArray(): number[];
  6631. /**
  6632. * @returns a new plane copied from the current Plane.
  6633. */
  6634. clone(): Plane;
  6635. /**
  6636. * @returns the string "Plane".
  6637. */
  6638. getClassName(): string;
  6639. /**
  6640. * @returns the Plane hash code.
  6641. */
  6642. getHashCode(): number;
  6643. /**
  6644. * Normalize the current Plane in place.
  6645. * @returns the updated Plane.
  6646. */
  6647. normalize(): Plane;
  6648. /**
  6649. * Applies a transformation the plane and returns the result
  6650. * @param transformation the transformation matrix to be applied to the plane
  6651. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6652. */
  6653. transform(transformation: DeepImmutable<Matrix>): Plane;
  6654. /**
  6655. * Calcualtte the dot product between the point and the plane normal
  6656. * @param point point to calculate the dot product with
  6657. * @returns the dot product (float) of the point coordinates and the plane normal.
  6658. */
  6659. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6660. /**
  6661. * Updates the current Plane from the plane defined by the three given points.
  6662. * @param point1 one of the points used to contruct the plane
  6663. * @param point2 one of the points used to contruct the plane
  6664. * @param point3 one of the points used to contruct the plane
  6665. * @returns the updated Plane.
  6666. */
  6667. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6668. /**
  6669. * Checks if the plane is facing a given direction
  6670. * @param direction the direction to check if the plane is facing
  6671. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6672. * @returns True is the vector "direction" is the same side than the plane normal.
  6673. */
  6674. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6675. /**
  6676. * Calculates the distance to a point
  6677. * @param point point to calculate distance to
  6678. * @returns the signed distance (float) from the given point to the Plane.
  6679. */
  6680. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6681. /**
  6682. * Creates a plane from an array
  6683. * @param array the array to create a plane from
  6684. * @returns a new Plane from the given array.
  6685. */
  6686. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6687. /**
  6688. * Creates a plane from three points
  6689. * @param point1 point used to create the plane
  6690. * @param point2 point used to create the plane
  6691. * @param point3 point used to create the plane
  6692. * @returns a new Plane defined by the three given points.
  6693. */
  6694. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6695. /**
  6696. * Creates a plane from an origin point and a normal
  6697. * @param origin origin of the plane to be constructed
  6698. * @param normal normal of the plane to be constructed
  6699. * @returns a new Plane the normal vector to this plane at the given origin point.
  6700. * Note : the vector "normal" is updated because normalized.
  6701. */
  6702. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6703. /**
  6704. * Calculates the distance from a plane and a point
  6705. * @param origin origin of the plane to be constructed
  6706. * @param normal normal of the plane to be constructed
  6707. * @param point point to calculate distance to
  6708. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6709. */
  6710. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6711. }
  6712. }
  6713. declare module BABYLON {
  6714. /**
  6715. * Class used to store bounding sphere information
  6716. */
  6717. export class BoundingSphere {
  6718. /**
  6719. * Gets the center of the bounding sphere in local space
  6720. */
  6721. readonly center: Vector3;
  6722. /**
  6723. * Radius of the bounding sphere in local space
  6724. */
  6725. radius: number;
  6726. /**
  6727. * Gets the center of the bounding sphere in world space
  6728. */
  6729. readonly centerWorld: Vector3;
  6730. /**
  6731. * Radius of the bounding sphere in world space
  6732. */
  6733. radiusWorld: number;
  6734. /**
  6735. * Gets the minimum vector in local space
  6736. */
  6737. readonly minimum: Vector3;
  6738. /**
  6739. * Gets the maximum vector in local space
  6740. */
  6741. readonly maximum: Vector3;
  6742. private _worldMatrix;
  6743. private static readonly TmpVector3;
  6744. /**
  6745. * Creates a new bounding sphere
  6746. * @param min defines the minimum vector (in local space)
  6747. * @param max defines the maximum vector (in local space)
  6748. * @param worldMatrix defines the new world matrix
  6749. */
  6750. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6751. /**
  6752. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6753. * @param min defines the new minimum vector (in local space)
  6754. * @param max defines the new maximum vector (in local space)
  6755. * @param worldMatrix defines the new world matrix
  6756. */
  6757. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6758. /**
  6759. * Scale the current bounding sphere by applying a scale factor
  6760. * @param factor defines the scale factor to apply
  6761. * @returns the current bounding box
  6762. */
  6763. scale(factor: number): BoundingSphere;
  6764. /**
  6765. * Gets the world matrix of the bounding box
  6766. * @returns a matrix
  6767. */
  6768. getWorldMatrix(): DeepImmutable<Matrix>;
  6769. /** @hidden */
  6770. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6771. /**
  6772. * Tests if the bounding sphere is intersecting the frustum planes
  6773. * @param frustumPlanes defines the frustum planes to test
  6774. * @returns true if there is an intersection
  6775. */
  6776. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6777. /**
  6778. * Tests if the bounding sphere center is in between the frustum planes.
  6779. * Used for optimistic fast inclusion.
  6780. * @param frustumPlanes defines the frustum planes to test
  6781. * @returns true if the sphere center is in between the frustum planes
  6782. */
  6783. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6784. /**
  6785. * Tests if a point is inside the bounding sphere
  6786. * @param point defines the point to test
  6787. * @returns true if the point is inside the bounding sphere
  6788. */
  6789. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6790. /**
  6791. * Checks if two sphere intersct
  6792. * @param sphere0 sphere 0
  6793. * @param sphere1 sphere 1
  6794. * @returns true if the speres intersect
  6795. */
  6796. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6797. }
  6798. }
  6799. declare module BABYLON {
  6800. /**
  6801. * Class used to store bounding box information
  6802. */
  6803. export class BoundingBox implements ICullable {
  6804. /**
  6805. * Gets the 8 vectors representing the bounding box in local space
  6806. */
  6807. readonly vectors: Vector3[];
  6808. /**
  6809. * Gets the center of the bounding box in local space
  6810. */
  6811. readonly center: Vector3;
  6812. /**
  6813. * Gets the center of the bounding box in world space
  6814. */
  6815. readonly centerWorld: Vector3;
  6816. /**
  6817. * Gets the extend size in local space
  6818. */
  6819. readonly extendSize: Vector3;
  6820. /**
  6821. * Gets the extend size in world space
  6822. */
  6823. readonly extendSizeWorld: Vector3;
  6824. /**
  6825. * Gets the OBB (object bounding box) directions
  6826. */
  6827. readonly directions: Vector3[];
  6828. /**
  6829. * Gets the 8 vectors representing the bounding box in world space
  6830. */
  6831. readonly vectorsWorld: Vector3[];
  6832. /**
  6833. * Gets the minimum vector in world space
  6834. */
  6835. readonly minimumWorld: Vector3;
  6836. /**
  6837. * Gets the maximum vector in world space
  6838. */
  6839. readonly maximumWorld: Vector3;
  6840. /**
  6841. * Gets the minimum vector in local space
  6842. */
  6843. readonly minimum: Vector3;
  6844. /**
  6845. * Gets the maximum vector in local space
  6846. */
  6847. readonly maximum: Vector3;
  6848. private _worldMatrix;
  6849. private static readonly TmpVector3;
  6850. /**
  6851. * @hidden
  6852. */
  6853. _tag: number;
  6854. /**
  6855. * Creates a new bounding box
  6856. * @param min defines the minimum vector (in local space)
  6857. * @param max defines the maximum vector (in local space)
  6858. * @param worldMatrix defines the new world matrix
  6859. */
  6860. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6861. /**
  6862. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6863. * @param min defines the new minimum vector (in local space)
  6864. * @param max defines the new maximum vector (in local space)
  6865. * @param worldMatrix defines the new world matrix
  6866. */
  6867. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6868. /**
  6869. * Scale the current bounding box by applying a scale factor
  6870. * @param factor defines the scale factor to apply
  6871. * @returns the current bounding box
  6872. */
  6873. scale(factor: number): BoundingBox;
  6874. /**
  6875. * Gets the world matrix of the bounding box
  6876. * @returns a matrix
  6877. */
  6878. getWorldMatrix(): DeepImmutable<Matrix>;
  6879. /** @hidden */
  6880. _update(world: DeepImmutable<Matrix>): void;
  6881. /**
  6882. * Tests if the bounding box is intersecting the frustum planes
  6883. * @param frustumPlanes defines the frustum planes to test
  6884. * @returns true if there is an intersection
  6885. */
  6886. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6887. /**
  6888. * Tests if the bounding box is entirely inside the frustum planes
  6889. * @param frustumPlanes defines the frustum planes to test
  6890. * @returns true if there is an inclusion
  6891. */
  6892. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6893. /**
  6894. * Tests if a point is inside the bounding box
  6895. * @param point defines the point to test
  6896. * @returns true if the point is inside the bounding box
  6897. */
  6898. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6899. /**
  6900. * Tests if the bounding box intersects with a bounding sphere
  6901. * @param sphere defines the sphere to test
  6902. * @returns true if there is an intersection
  6903. */
  6904. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6905. /**
  6906. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6907. * @param min defines the min vector to use
  6908. * @param max defines the max vector to use
  6909. * @returns true if there is an intersection
  6910. */
  6911. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6912. /**
  6913. * Tests if two bounding boxes are intersections
  6914. * @param box0 defines the first box to test
  6915. * @param box1 defines the second box to test
  6916. * @returns true if there is an intersection
  6917. */
  6918. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6919. /**
  6920. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6921. * @param minPoint defines the minimum vector of the bounding box
  6922. * @param maxPoint defines the maximum vector of the bounding box
  6923. * @param sphereCenter defines the sphere center
  6924. * @param sphereRadius defines the sphere radius
  6925. * @returns true if there is an intersection
  6926. */
  6927. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6928. /**
  6929. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6930. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6931. * @param frustumPlanes defines the frustum planes to test
  6932. * @return true if there is an inclusion
  6933. */
  6934. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6935. /**
  6936. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6937. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6938. * @param frustumPlanes defines the frustum planes to test
  6939. * @return true if there is an intersection
  6940. */
  6941. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6942. }
  6943. }
  6944. declare module BABYLON {
  6945. /** @hidden */
  6946. export class Collider {
  6947. /** Define if a collision was found */
  6948. collisionFound: boolean;
  6949. /**
  6950. * Define last intersection point in local space
  6951. */
  6952. intersectionPoint: Vector3;
  6953. /**
  6954. * Define last collided mesh
  6955. */
  6956. collidedMesh: Nullable<AbstractMesh>;
  6957. private _collisionPoint;
  6958. private _planeIntersectionPoint;
  6959. private _tempVector;
  6960. private _tempVector2;
  6961. private _tempVector3;
  6962. private _tempVector4;
  6963. private _edge;
  6964. private _baseToVertex;
  6965. private _destinationPoint;
  6966. private _slidePlaneNormal;
  6967. private _displacementVector;
  6968. /** @hidden */
  6969. _radius: Vector3;
  6970. /** @hidden */
  6971. _retry: number;
  6972. private _velocity;
  6973. private _basePoint;
  6974. private _epsilon;
  6975. /** @hidden */
  6976. _velocityWorldLength: number;
  6977. /** @hidden */
  6978. _basePointWorld: Vector3;
  6979. private _velocityWorld;
  6980. private _normalizedVelocity;
  6981. /** @hidden */
  6982. _initialVelocity: Vector3;
  6983. /** @hidden */
  6984. _initialPosition: Vector3;
  6985. private _nearestDistance;
  6986. private _collisionMask;
  6987. get collisionMask(): number;
  6988. set collisionMask(mask: number);
  6989. /**
  6990. * Gets the plane normal used to compute the sliding response (in local space)
  6991. */
  6992. get slidePlaneNormal(): Vector3;
  6993. /** @hidden */
  6994. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6995. /** @hidden */
  6996. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6997. /** @hidden */
  6998. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6999. /** @hidden */
  7000. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7001. /** @hidden */
  7002. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7003. /** @hidden */
  7004. _getResponse(pos: Vector3, vel: Vector3): void;
  7005. }
  7006. }
  7007. declare module BABYLON {
  7008. /**
  7009. * Interface for cullable objects
  7010. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7011. */
  7012. export interface ICullable {
  7013. /**
  7014. * Checks if the object or part of the object is in the frustum
  7015. * @param frustumPlanes Camera near/planes
  7016. * @returns true if the object is in frustum otherwise false
  7017. */
  7018. isInFrustum(frustumPlanes: Plane[]): boolean;
  7019. /**
  7020. * Checks if a cullable object (mesh...) is in the camera frustum
  7021. * Unlike isInFrustum this cheks the full bounding box
  7022. * @param frustumPlanes Camera near/planes
  7023. * @returns true if the object is in frustum otherwise false
  7024. */
  7025. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7026. }
  7027. /**
  7028. * Info for a bounding data of a mesh
  7029. */
  7030. export class BoundingInfo implements ICullable {
  7031. /**
  7032. * Bounding box for the mesh
  7033. */
  7034. readonly boundingBox: BoundingBox;
  7035. /**
  7036. * Bounding sphere for the mesh
  7037. */
  7038. readonly boundingSphere: BoundingSphere;
  7039. private _isLocked;
  7040. private static readonly TmpVector3;
  7041. /**
  7042. * Constructs bounding info
  7043. * @param minimum min vector of the bounding box/sphere
  7044. * @param maximum max vector of the bounding box/sphere
  7045. * @param worldMatrix defines the new world matrix
  7046. */
  7047. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7048. /**
  7049. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7050. * @param min defines the new minimum vector (in local space)
  7051. * @param max defines the new maximum vector (in local space)
  7052. * @param worldMatrix defines the new world matrix
  7053. */
  7054. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7055. /**
  7056. * min vector of the bounding box/sphere
  7057. */
  7058. get minimum(): Vector3;
  7059. /**
  7060. * max vector of the bounding box/sphere
  7061. */
  7062. get maximum(): Vector3;
  7063. /**
  7064. * If the info is locked and won't be updated to avoid perf overhead
  7065. */
  7066. get isLocked(): boolean;
  7067. set isLocked(value: boolean);
  7068. /**
  7069. * Updates the bounding sphere and box
  7070. * @param world world matrix to be used to update
  7071. */
  7072. update(world: DeepImmutable<Matrix>): void;
  7073. /**
  7074. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7075. * @param center New center of the bounding info
  7076. * @param extend New extend of the bounding info
  7077. * @returns the current bounding info
  7078. */
  7079. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7080. /**
  7081. * Scale the current bounding info by applying a scale factor
  7082. * @param factor defines the scale factor to apply
  7083. * @returns the current bounding info
  7084. */
  7085. scale(factor: number): BoundingInfo;
  7086. /**
  7087. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7088. * @param frustumPlanes defines the frustum to test
  7089. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7090. * @returns true if the bounding info is in the frustum planes
  7091. */
  7092. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7093. /**
  7094. * Gets the world distance between the min and max points of the bounding box
  7095. */
  7096. get diagonalLength(): number;
  7097. /**
  7098. * Checks if a cullable object (mesh...) is in the camera frustum
  7099. * Unlike isInFrustum this cheks the full bounding box
  7100. * @param frustumPlanes Camera near/planes
  7101. * @returns true if the object is in frustum otherwise false
  7102. */
  7103. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7104. /** @hidden */
  7105. _checkCollision(collider: Collider): boolean;
  7106. /**
  7107. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7108. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7109. * @param point the point to check intersection with
  7110. * @returns if the point intersects
  7111. */
  7112. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7113. /**
  7114. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7115. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7116. * @param boundingInfo the bounding info to check intersection with
  7117. * @param precise if the intersection should be done using OBB
  7118. * @returns if the bounding info intersects
  7119. */
  7120. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7121. }
  7122. }
  7123. declare module BABYLON {
  7124. /**
  7125. * Extracts minimum and maximum values from a list of indexed positions
  7126. * @param positions defines the positions to use
  7127. * @param indices defines the indices to the positions
  7128. * @param indexStart defines the start index
  7129. * @param indexCount defines the end index
  7130. * @param bias defines bias value to add to the result
  7131. * @return minimum and maximum values
  7132. */
  7133. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7134. minimum: Vector3;
  7135. maximum: Vector3;
  7136. };
  7137. /**
  7138. * Extracts minimum and maximum values from a list of positions
  7139. * @param positions defines the positions to use
  7140. * @param start defines the start index in the positions array
  7141. * @param count defines the number of positions to handle
  7142. * @param bias defines bias value to add to the result
  7143. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7144. * @return minimum and maximum values
  7145. */
  7146. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7147. minimum: Vector3;
  7148. maximum: Vector3;
  7149. };
  7150. }
  7151. declare module BABYLON {
  7152. /** @hidden */
  7153. export class WebGLDataBuffer extends DataBuffer {
  7154. private _buffer;
  7155. constructor(resource: WebGLBuffer);
  7156. get underlyingResource(): any;
  7157. }
  7158. }
  7159. declare module BABYLON {
  7160. /** @hidden */
  7161. export class WebGLPipelineContext implements IPipelineContext {
  7162. engine: ThinEngine;
  7163. program: Nullable<WebGLProgram>;
  7164. context?: WebGLRenderingContext;
  7165. vertexShader?: WebGLShader;
  7166. fragmentShader?: WebGLShader;
  7167. isParallelCompiled: boolean;
  7168. onCompiled?: () => void;
  7169. transformFeedback?: WebGLTransformFeedback | null;
  7170. vertexCompilationError: Nullable<string>;
  7171. fragmentCompilationError: Nullable<string>;
  7172. programLinkError: Nullable<string>;
  7173. programValidationError: Nullable<string>;
  7174. get isAsync(): boolean;
  7175. get isReady(): boolean;
  7176. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7177. _getVertexShaderCode(): string | null;
  7178. _getFragmentShaderCode(): string | null;
  7179. }
  7180. }
  7181. declare module BABYLON {
  7182. interface ThinEngine {
  7183. /**
  7184. * Create an uniform buffer
  7185. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7186. * @param elements defines the content of the uniform buffer
  7187. * @returns the webGL uniform buffer
  7188. */
  7189. createUniformBuffer(elements: FloatArray): DataBuffer;
  7190. /**
  7191. * Create a dynamic uniform buffer
  7192. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7193. * @param elements defines the content of the uniform buffer
  7194. * @returns the webGL uniform buffer
  7195. */
  7196. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7197. /**
  7198. * Update an existing uniform buffer
  7199. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7200. * @param uniformBuffer defines the target uniform buffer
  7201. * @param elements defines the content to update
  7202. * @param offset defines the offset in the uniform buffer where update should start
  7203. * @param count defines the size of the data to update
  7204. */
  7205. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7206. /**
  7207. * Bind an uniform buffer to the current webGL context
  7208. * @param buffer defines the buffer to bind
  7209. */
  7210. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7211. /**
  7212. * Bind a buffer to the current webGL context at a given location
  7213. * @param buffer defines the buffer to bind
  7214. * @param location defines the index where to bind the buffer
  7215. */
  7216. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7217. /**
  7218. * Bind a specific block at a given index in a specific shader program
  7219. * @param pipelineContext defines the pipeline context to use
  7220. * @param blockName defines the block name
  7221. * @param index defines the index where to bind the block
  7222. */
  7223. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7224. }
  7225. }
  7226. declare module BABYLON {
  7227. /**
  7228. * Uniform buffer objects.
  7229. *
  7230. * Handles blocks of uniform on the GPU.
  7231. *
  7232. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7233. *
  7234. * For more information, please refer to :
  7235. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7236. */
  7237. export class UniformBuffer {
  7238. private _engine;
  7239. private _buffer;
  7240. private _data;
  7241. private _bufferData;
  7242. private _dynamic?;
  7243. private _uniformLocations;
  7244. private _uniformSizes;
  7245. private _uniformLocationPointer;
  7246. private _needSync;
  7247. private _noUBO;
  7248. private _currentEffect;
  7249. /** @hidden */
  7250. _alreadyBound: boolean;
  7251. private static _MAX_UNIFORM_SIZE;
  7252. private static _tempBuffer;
  7253. /**
  7254. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7255. * This is dynamic to allow compat with webgl 1 and 2.
  7256. * You will need to pass the name of the uniform as well as the value.
  7257. */
  7258. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7259. /**
  7260. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7261. * This is dynamic to allow compat with webgl 1 and 2.
  7262. * You will need to pass the name of the uniform as well as the value.
  7263. */
  7264. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7265. /**
  7266. * Lambda to Update a single float in a uniform buffer.
  7267. * This is dynamic to allow compat with webgl 1 and 2.
  7268. * You will need to pass the name of the uniform as well as the value.
  7269. */
  7270. updateFloat: (name: string, x: number) => void;
  7271. /**
  7272. * Lambda to Update a vec2 of float in a uniform buffer.
  7273. * This is dynamic to allow compat with webgl 1 and 2.
  7274. * You will need to pass the name of the uniform as well as the value.
  7275. */
  7276. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7277. /**
  7278. * Lambda to Update a vec3 of float in a uniform buffer.
  7279. * This is dynamic to allow compat with webgl 1 and 2.
  7280. * You will need to pass the name of the uniform as well as the value.
  7281. */
  7282. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7283. /**
  7284. * Lambda to Update a vec4 of float in a uniform buffer.
  7285. * This is dynamic to allow compat with webgl 1 and 2.
  7286. * You will need to pass the name of the uniform as well as the value.
  7287. */
  7288. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7289. /**
  7290. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7291. * This is dynamic to allow compat with webgl 1 and 2.
  7292. * You will need to pass the name of the uniform as well as the value.
  7293. */
  7294. updateMatrix: (name: string, mat: Matrix) => void;
  7295. /**
  7296. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7297. * This is dynamic to allow compat with webgl 1 and 2.
  7298. * You will need to pass the name of the uniform as well as the value.
  7299. */
  7300. updateVector3: (name: string, vector: Vector3) => void;
  7301. /**
  7302. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7303. * This is dynamic to allow compat with webgl 1 and 2.
  7304. * You will need to pass the name of the uniform as well as the value.
  7305. */
  7306. updateVector4: (name: string, vector: Vector4) => void;
  7307. /**
  7308. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7309. * This is dynamic to allow compat with webgl 1 and 2.
  7310. * You will need to pass the name of the uniform as well as the value.
  7311. */
  7312. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7313. /**
  7314. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7315. * This is dynamic to allow compat with webgl 1 and 2.
  7316. * You will need to pass the name of the uniform as well as the value.
  7317. */
  7318. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7319. /**
  7320. * Instantiates a new Uniform buffer objects.
  7321. *
  7322. * Handles blocks of uniform on the GPU.
  7323. *
  7324. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7325. *
  7326. * For more information, please refer to :
  7327. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7328. * @param engine Define the engine the buffer is associated with
  7329. * @param data Define the data contained in the buffer
  7330. * @param dynamic Define if the buffer is updatable
  7331. */
  7332. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7333. /**
  7334. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7335. * or just falling back on setUniformXXX calls.
  7336. */
  7337. get useUbo(): boolean;
  7338. /**
  7339. * Indicates if the WebGL underlying uniform buffer is in sync
  7340. * with the javascript cache data.
  7341. */
  7342. get isSync(): boolean;
  7343. /**
  7344. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7345. * Also, a dynamic UniformBuffer will disable cache verification and always
  7346. * update the underlying WebGL uniform buffer to the GPU.
  7347. * @returns if Dynamic, otherwise false
  7348. */
  7349. isDynamic(): boolean;
  7350. /**
  7351. * The data cache on JS side.
  7352. * @returns the underlying data as a float array
  7353. */
  7354. getData(): Float32Array;
  7355. /**
  7356. * The underlying WebGL Uniform buffer.
  7357. * @returns the webgl buffer
  7358. */
  7359. getBuffer(): Nullable<DataBuffer>;
  7360. /**
  7361. * std140 layout specifies how to align data within an UBO structure.
  7362. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7363. * for specs.
  7364. */
  7365. private _fillAlignment;
  7366. /**
  7367. * Adds an uniform in the buffer.
  7368. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7369. * for the layout to be correct !
  7370. * @param name Name of the uniform, as used in the uniform block in the shader.
  7371. * @param size Data size, or data directly.
  7372. */
  7373. addUniform(name: string, size: number | number[]): void;
  7374. /**
  7375. * Adds a Matrix 4x4 to the uniform buffer.
  7376. * @param name Name of the uniform, as used in the uniform block in the shader.
  7377. * @param mat A 4x4 matrix.
  7378. */
  7379. addMatrix(name: string, mat: Matrix): void;
  7380. /**
  7381. * Adds a vec2 to the uniform buffer.
  7382. * @param name Name of the uniform, as used in the uniform block in the shader.
  7383. * @param x Define the x component value of the vec2
  7384. * @param y Define the y component value of the vec2
  7385. */
  7386. addFloat2(name: string, x: number, y: number): void;
  7387. /**
  7388. * Adds a vec3 to the uniform buffer.
  7389. * @param name Name of the uniform, as used in the uniform block in the shader.
  7390. * @param x Define the x component value of the vec3
  7391. * @param y Define the y component value of the vec3
  7392. * @param z Define the z component value of the vec3
  7393. */
  7394. addFloat3(name: string, x: number, y: number, z: number): void;
  7395. /**
  7396. * Adds a vec3 to the uniform buffer.
  7397. * @param name Name of the uniform, as used in the uniform block in the shader.
  7398. * @param color Define the vec3 from a Color
  7399. */
  7400. addColor3(name: string, color: Color3): void;
  7401. /**
  7402. * Adds a vec4 to the uniform buffer.
  7403. * @param name Name of the uniform, as used in the uniform block in the shader.
  7404. * @param color Define the rgb components from a Color
  7405. * @param alpha Define the a component of the vec4
  7406. */
  7407. addColor4(name: string, color: Color3, alpha: number): void;
  7408. /**
  7409. * Adds a vec3 to the uniform buffer.
  7410. * @param name Name of the uniform, as used in the uniform block in the shader.
  7411. * @param vector Define the vec3 components from a Vector
  7412. */
  7413. addVector3(name: string, vector: Vector3): void;
  7414. /**
  7415. * Adds a Matrix 3x3 to the uniform buffer.
  7416. * @param name Name of the uniform, as used in the uniform block in the shader.
  7417. */
  7418. addMatrix3x3(name: string): void;
  7419. /**
  7420. * Adds a Matrix 2x2 to the uniform buffer.
  7421. * @param name Name of the uniform, as used in the uniform block in the shader.
  7422. */
  7423. addMatrix2x2(name: string): void;
  7424. /**
  7425. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7426. */
  7427. create(): void;
  7428. /** @hidden */
  7429. _rebuild(): void;
  7430. /**
  7431. * Updates the WebGL Uniform Buffer on the GPU.
  7432. * If the `dynamic` flag is set to true, no cache comparison is done.
  7433. * Otherwise, the buffer will be updated only if the cache differs.
  7434. */
  7435. update(): void;
  7436. /**
  7437. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7438. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7439. * @param data Define the flattened data
  7440. * @param size Define the size of the data.
  7441. */
  7442. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7443. private _valueCache;
  7444. private _cacheMatrix;
  7445. private _updateMatrix3x3ForUniform;
  7446. private _updateMatrix3x3ForEffect;
  7447. private _updateMatrix2x2ForEffect;
  7448. private _updateMatrix2x2ForUniform;
  7449. private _updateFloatForEffect;
  7450. private _updateFloatForUniform;
  7451. private _updateFloat2ForEffect;
  7452. private _updateFloat2ForUniform;
  7453. private _updateFloat3ForEffect;
  7454. private _updateFloat3ForUniform;
  7455. private _updateFloat4ForEffect;
  7456. private _updateFloat4ForUniform;
  7457. private _updateMatrixForEffect;
  7458. private _updateMatrixForUniform;
  7459. private _updateVector3ForEffect;
  7460. private _updateVector3ForUniform;
  7461. private _updateVector4ForEffect;
  7462. private _updateVector4ForUniform;
  7463. private _updateColor3ForEffect;
  7464. private _updateColor3ForUniform;
  7465. private _updateColor4ForEffect;
  7466. private _updateColor4ForUniform;
  7467. /**
  7468. * Sets a sampler uniform on the effect.
  7469. * @param name Define the name of the sampler.
  7470. * @param texture Define the texture to set in the sampler
  7471. */
  7472. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7473. /**
  7474. * Directly updates the value of the uniform in the cache AND on the GPU.
  7475. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7476. * @param data Define the flattened data
  7477. */
  7478. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7479. /**
  7480. * Binds this uniform buffer to an effect.
  7481. * @param effect Define the effect to bind the buffer to
  7482. * @param name Name of the uniform block in the shader.
  7483. */
  7484. bindToEffect(effect: Effect, name: string): void;
  7485. /**
  7486. * Disposes the uniform buffer.
  7487. */
  7488. dispose(): void;
  7489. }
  7490. }
  7491. declare module BABYLON {
  7492. /**
  7493. * Enum that determines the text-wrapping mode to use.
  7494. */
  7495. export enum InspectableType {
  7496. /**
  7497. * Checkbox for booleans
  7498. */
  7499. Checkbox = 0,
  7500. /**
  7501. * Sliders for numbers
  7502. */
  7503. Slider = 1,
  7504. /**
  7505. * Vector3
  7506. */
  7507. Vector3 = 2,
  7508. /**
  7509. * Quaternions
  7510. */
  7511. Quaternion = 3,
  7512. /**
  7513. * Color3
  7514. */
  7515. Color3 = 4,
  7516. /**
  7517. * String
  7518. */
  7519. String = 5
  7520. }
  7521. /**
  7522. * Interface used to define custom inspectable properties.
  7523. * This interface is used by the inspector to display custom property grids
  7524. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7525. */
  7526. export interface IInspectable {
  7527. /**
  7528. * Gets the label to display
  7529. */
  7530. label: string;
  7531. /**
  7532. * Gets the name of the property to edit
  7533. */
  7534. propertyName: string;
  7535. /**
  7536. * Gets the type of the editor to use
  7537. */
  7538. type: InspectableType;
  7539. /**
  7540. * Gets the minimum value of the property when using in "slider" mode
  7541. */
  7542. min?: number;
  7543. /**
  7544. * Gets the maximum value of the property when using in "slider" mode
  7545. */
  7546. max?: number;
  7547. /**
  7548. * Gets the setp to use when using in "slider" mode
  7549. */
  7550. step?: number;
  7551. }
  7552. }
  7553. declare module BABYLON {
  7554. /**
  7555. * Class used to provide helper for timing
  7556. */
  7557. export class TimingTools {
  7558. /**
  7559. * Polyfill for setImmediate
  7560. * @param action defines the action to execute after the current execution block
  7561. */
  7562. static SetImmediate(action: () => void): void;
  7563. }
  7564. }
  7565. declare module BABYLON {
  7566. /**
  7567. * Class used to enable instatition of objects by class name
  7568. */
  7569. export class InstantiationTools {
  7570. /**
  7571. * Use this object to register external classes like custom textures or material
  7572. * to allow the laoders to instantiate them
  7573. */
  7574. static RegisteredExternalClasses: {
  7575. [key: string]: Object;
  7576. };
  7577. /**
  7578. * Tries to instantiate a new object from a given class name
  7579. * @param className defines the class name to instantiate
  7580. * @returns the new object or null if the system was not able to do the instantiation
  7581. */
  7582. static Instantiate(className: string): any;
  7583. }
  7584. }
  7585. declare module BABYLON {
  7586. /**
  7587. * Define options used to create a depth texture
  7588. */
  7589. export class DepthTextureCreationOptions {
  7590. /** Specifies whether or not a stencil should be allocated in the texture */
  7591. generateStencil?: boolean;
  7592. /** Specifies whether or not bilinear filtering is enable on the texture */
  7593. bilinearFiltering?: boolean;
  7594. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7595. comparisonFunction?: number;
  7596. /** Specifies if the created texture is a cube texture */
  7597. isCube?: boolean;
  7598. }
  7599. }
  7600. declare module BABYLON {
  7601. interface ThinEngine {
  7602. /**
  7603. * Creates a depth stencil cube texture.
  7604. * This is only available in WebGL 2.
  7605. * @param size The size of face edge in the cube texture.
  7606. * @param options The options defining the cube texture.
  7607. * @returns The cube texture
  7608. */
  7609. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7610. /**
  7611. * Creates a cube texture
  7612. * @param rootUrl defines the url where the files to load is located
  7613. * @param scene defines the current scene
  7614. * @param files defines the list of files to load (1 per face)
  7615. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7616. * @param onLoad defines an optional callback raised when the texture is loaded
  7617. * @param onError defines an optional callback raised if there is an issue to load the texture
  7618. * @param format defines the format of the data
  7619. * @param forcedExtension defines the extension to use to pick the right loader
  7620. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7621. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7622. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7623. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7624. * @returns the cube texture as an InternalTexture
  7625. */
  7626. 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;
  7627. /**
  7628. * Creates a cube texture
  7629. * @param rootUrl defines the url where the files to load is located
  7630. * @param scene defines the current scene
  7631. * @param files defines the list of files to load (1 per face)
  7632. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7633. * @param onLoad defines an optional callback raised when the texture is loaded
  7634. * @param onError defines an optional callback raised if there is an issue to load the texture
  7635. * @param format defines the format of the data
  7636. * @param forcedExtension defines the extension to use to pick the right loader
  7637. * @returns the cube texture as an InternalTexture
  7638. */
  7639. 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;
  7640. /**
  7641. * Creates a cube texture
  7642. * @param rootUrl defines the url where the files to load is located
  7643. * @param scene defines the current scene
  7644. * @param files defines the list of files to load (1 per face)
  7645. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7646. * @param onLoad defines an optional callback raised when the texture is loaded
  7647. * @param onError defines an optional callback raised if there is an issue to load the texture
  7648. * @param format defines the format of the data
  7649. * @param forcedExtension defines the extension to use to pick the right loader
  7650. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7651. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7652. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7653. * @returns the cube texture as an InternalTexture
  7654. */
  7655. 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;
  7656. /** @hidden */
  7657. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7658. /** @hidden */
  7659. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7660. /** @hidden */
  7661. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7662. /** @hidden */
  7663. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7664. /**
  7665. * @hidden
  7666. */
  7667. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7668. }
  7669. }
  7670. declare module BABYLON {
  7671. /**
  7672. * Class for creating a cube texture
  7673. */
  7674. export class CubeTexture extends BaseTexture {
  7675. private _delayedOnLoad;
  7676. /**
  7677. * Observable triggered once the texture has been loaded.
  7678. */
  7679. onLoadObservable: Observable<CubeTexture>;
  7680. /**
  7681. * The url of the texture
  7682. */
  7683. url: string;
  7684. /**
  7685. * Gets or sets the center of the bounding box associated with the cube texture.
  7686. * It must define where the camera used to render the texture was set
  7687. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7688. */
  7689. boundingBoxPosition: Vector3;
  7690. private _boundingBoxSize;
  7691. /**
  7692. * Gets or sets the size of the bounding box associated with the cube texture
  7693. * When defined, the cubemap will switch to local mode
  7694. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7695. * @example https://www.babylonjs-playground.com/#RNASML
  7696. */
  7697. set boundingBoxSize(value: Vector3);
  7698. /**
  7699. * Returns the bounding box size
  7700. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7701. */
  7702. get boundingBoxSize(): Vector3;
  7703. protected _rotationY: number;
  7704. /**
  7705. * Sets texture matrix rotation angle around Y axis in radians.
  7706. */
  7707. set rotationY(value: number);
  7708. /**
  7709. * Gets texture matrix rotation angle around Y axis radians.
  7710. */
  7711. get rotationY(): number;
  7712. /**
  7713. * Are mip maps generated for this texture or not.
  7714. */
  7715. get noMipmap(): boolean;
  7716. private _noMipmap;
  7717. private _files;
  7718. protected _forcedExtension: Nullable<string>;
  7719. private _extensions;
  7720. private _textureMatrix;
  7721. private _format;
  7722. private _createPolynomials;
  7723. /** @hidden */
  7724. _prefiltered: boolean;
  7725. /**
  7726. * Creates a cube texture from an array of image urls
  7727. * @param files defines an array of image urls
  7728. * @param scene defines the hosting scene
  7729. * @param noMipmap specifies if mip maps are not used
  7730. * @returns a cube texture
  7731. */
  7732. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7733. /**
  7734. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7735. * @param url defines the url of the prefiltered texture
  7736. * @param scene defines the scene the texture is attached to
  7737. * @param forcedExtension defines the extension of the file if different from the url
  7738. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7739. * @return the prefiltered texture
  7740. */
  7741. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7742. /**
  7743. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7744. * as prefiltered data.
  7745. * @param rootUrl defines the url of the texture or the root name of the six images
  7746. * @param scene defines the scene the texture is attached to
  7747. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7748. * @param noMipmap defines if mipmaps should be created or not
  7749. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7750. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7751. * @param onError defines a callback triggered in case of error during load
  7752. * @param format defines the internal format to use for the texture once loaded
  7753. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7754. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7755. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7756. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7757. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7758. * @return the cube texture
  7759. */
  7760. 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);
  7761. /**
  7762. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7763. */
  7764. get isPrefiltered(): boolean;
  7765. /**
  7766. * Get the current class name of the texture useful for serialization or dynamic coding.
  7767. * @returns "CubeTexture"
  7768. */
  7769. getClassName(): string;
  7770. /**
  7771. * Update the url (and optional buffer) of this texture if url was null during construction.
  7772. * @param url the url of the texture
  7773. * @param forcedExtension defines the extension to use
  7774. * @param onLoad callback called when the texture is loaded (defaults to null)
  7775. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7776. */
  7777. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7778. /**
  7779. * Delays loading of the cube texture
  7780. * @param forcedExtension defines the extension to use
  7781. */
  7782. delayLoad(forcedExtension?: string): void;
  7783. /**
  7784. * Returns the reflection texture matrix
  7785. * @returns the reflection texture matrix
  7786. */
  7787. getReflectionTextureMatrix(): Matrix;
  7788. /**
  7789. * Sets the reflection texture matrix
  7790. * @param value Reflection texture matrix
  7791. */
  7792. setReflectionTextureMatrix(value: Matrix): void;
  7793. /**
  7794. * Parses text to create a cube texture
  7795. * @param parsedTexture define the serialized text to read from
  7796. * @param scene defines the hosting scene
  7797. * @param rootUrl defines the root url of the cube texture
  7798. * @returns a cube texture
  7799. */
  7800. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7801. /**
  7802. * Makes a clone, or deep copy, of the cube texture
  7803. * @returns a new cube texture
  7804. */
  7805. clone(): CubeTexture;
  7806. }
  7807. }
  7808. declare module BABYLON {
  7809. /**
  7810. * Manages the defines for the Material
  7811. */
  7812. export class MaterialDefines {
  7813. /** @hidden */
  7814. protected _keys: string[];
  7815. private _isDirty;
  7816. /** @hidden */
  7817. _renderId: number;
  7818. /** @hidden */
  7819. _areLightsDirty: boolean;
  7820. /** @hidden */
  7821. _areLightsDisposed: boolean;
  7822. /** @hidden */
  7823. _areAttributesDirty: boolean;
  7824. /** @hidden */
  7825. _areTexturesDirty: boolean;
  7826. /** @hidden */
  7827. _areFresnelDirty: boolean;
  7828. /** @hidden */
  7829. _areMiscDirty: boolean;
  7830. /** @hidden */
  7831. _areImageProcessingDirty: boolean;
  7832. /** @hidden */
  7833. _normals: boolean;
  7834. /** @hidden */
  7835. _uvs: boolean;
  7836. /** @hidden */
  7837. _needNormals: boolean;
  7838. /** @hidden */
  7839. _needUVs: boolean;
  7840. [id: string]: any;
  7841. /**
  7842. * Specifies if the material needs to be re-calculated
  7843. */
  7844. get isDirty(): boolean;
  7845. /**
  7846. * Marks the material to indicate that it has been re-calculated
  7847. */
  7848. markAsProcessed(): void;
  7849. /**
  7850. * Marks the material to indicate that it needs to be re-calculated
  7851. */
  7852. markAsUnprocessed(): void;
  7853. /**
  7854. * Marks the material to indicate all of its defines need to be re-calculated
  7855. */
  7856. markAllAsDirty(): void;
  7857. /**
  7858. * Marks the material to indicate that image processing needs to be re-calculated
  7859. */
  7860. markAsImageProcessingDirty(): void;
  7861. /**
  7862. * Marks the material to indicate the lights need to be re-calculated
  7863. * @param disposed Defines whether the light is dirty due to dispose or not
  7864. */
  7865. markAsLightDirty(disposed?: boolean): void;
  7866. /**
  7867. * Marks the attribute state as changed
  7868. */
  7869. markAsAttributesDirty(): void;
  7870. /**
  7871. * Marks the texture state as changed
  7872. */
  7873. markAsTexturesDirty(): void;
  7874. /**
  7875. * Marks the fresnel state as changed
  7876. */
  7877. markAsFresnelDirty(): void;
  7878. /**
  7879. * Marks the misc state as changed
  7880. */
  7881. markAsMiscDirty(): void;
  7882. /**
  7883. * Rebuilds the material defines
  7884. */
  7885. rebuild(): void;
  7886. /**
  7887. * Specifies if two material defines are equal
  7888. * @param other - A material define instance to compare to
  7889. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7890. */
  7891. isEqual(other: MaterialDefines): boolean;
  7892. /**
  7893. * Clones this instance's defines to another instance
  7894. * @param other - material defines to clone values to
  7895. */
  7896. cloneTo(other: MaterialDefines): void;
  7897. /**
  7898. * Resets the material define values
  7899. */
  7900. reset(): void;
  7901. /**
  7902. * Converts the material define values to a string
  7903. * @returns - String of material define information
  7904. */
  7905. toString(): string;
  7906. }
  7907. }
  7908. declare module BABYLON {
  7909. /**
  7910. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7911. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7912. * 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;
  7913. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7914. */
  7915. export class ColorCurves {
  7916. private _dirty;
  7917. private _tempColor;
  7918. private _globalCurve;
  7919. private _highlightsCurve;
  7920. private _midtonesCurve;
  7921. private _shadowsCurve;
  7922. private _positiveCurve;
  7923. private _negativeCurve;
  7924. private _globalHue;
  7925. private _globalDensity;
  7926. private _globalSaturation;
  7927. private _globalExposure;
  7928. /**
  7929. * Gets the global Hue value.
  7930. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7931. */
  7932. get globalHue(): number;
  7933. /**
  7934. * Sets the global Hue value.
  7935. * 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).
  7936. */
  7937. set globalHue(value: number);
  7938. /**
  7939. * Gets the global Density value.
  7940. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7941. * Values less than zero provide a filter of opposite hue.
  7942. */
  7943. get globalDensity(): number;
  7944. /**
  7945. * Sets the global Density value.
  7946. * 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.
  7947. * Values less than zero provide a filter of opposite hue.
  7948. */
  7949. set globalDensity(value: number);
  7950. /**
  7951. * Gets the global Saturation value.
  7952. * 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.
  7953. */
  7954. get globalSaturation(): number;
  7955. /**
  7956. * Sets the global Saturation value.
  7957. * 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.
  7958. */
  7959. set globalSaturation(value: number);
  7960. /**
  7961. * Gets the global Exposure value.
  7962. * 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.
  7963. */
  7964. get globalExposure(): number;
  7965. /**
  7966. * Sets the global Exposure value.
  7967. * 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.
  7968. */
  7969. set globalExposure(value: number);
  7970. private _highlightsHue;
  7971. private _highlightsDensity;
  7972. private _highlightsSaturation;
  7973. private _highlightsExposure;
  7974. /**
  7975. * Gets the highlights Hue value.
  7976. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7977. */
  7978. get highlightsHue(): number;
  7979. /**
  7980. * Sets the highlights Hue value.
  7981. * 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).
  7982. */
  7983. set highlightsHue(value: number);
  7984. /**
  7985. * Gets the highlights Density value.
  7986. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7987. * Values less than zero provide a filter of opposite hue.
  7988. */
  7989. get highlightsDensity(): number;
  7990. /**
  7991. * Sets the highlights Density value.
  7992. * 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.
  7993. * Values less than zero provide a filter of opposite hue.
  7994. */
  7995. set highlightsDensity(value: number);
  7996. /**
  7997. * Gets the highlights Saturation value.
  7998. * 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.
  7999. */
  8000. get highlightsSaturation(): number;
  8001. /**
  8002. * Sets the highlights Saturation value.
  8003. * 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.
  8004. */
  8005. set highlightsSaturation(value: number);
  8006. /**
  8007. * Gets the highlights Exposure value.
  8008. * 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.
  8009. */
  8010. get highlightsExposure(): number;
  8011. /**
  8012. * Sets the highlights Exposure value.
  8013. * 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.
  8014. */
  8015. set highlightsExposure(value: number);
  8016. private _midtonesHue;
  8017. private _midtonesDensity;
  8018. private _midtonesSaturation;
  8019. private _midtonesExposure;
  8020. /**
  8021. * Gets the midtones Hue value.
  8022. * 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).
  8023. */
  8024. get midtonesHue(): number;
  8025. /**
  8026. * Sets the midtones Hue value.
  8027. * 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).
  8028. */
  8029. set midtonesHue(value: number);
  8030. /**
  8031. * Gets the midtones Density value.
  8032. * 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.
  8033. * Values less than zero provide a filter of opposite hue.
  8034. */
  8035. get midtonesDensity(): number;
  8036. /**
  8037. * Sets the midtones Density value.
  8038. * 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.
  8039. * Values less than zero provide a filter of opposite hue.
  8040. */
  8041. set midtonesDensity(value: number);
  8042. /**
  8043. * Gets the midtones Saturation value.
  8044. * 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.
  8045. */
  8046. get midtonesSaturation(): number;
  8047. /**
  8048. * Sets the midtones Saturation value.
  8049. * 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.
  8050. */
  8051. set midtonesSaturation(value: number);
  8052. /**
  8053. * Gets the midtones Exposure value.
  8054. * 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.
  8055. */
  8056. get midtonesExposure(): number;
  8057. /**
  8058. * Sets the midtones Exposure value.
  8059. * 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.
  8060. */
  8061. set midtonesExposure(value: number);
  8062. private _shadowsHue;
  8063. private _shadowsDensity;
  8064. private _shadowsSaturation;
  8065. private _shadowsExposure;
  8066. /**
  8067. * Gets the shadows Hue value.
  8068. * 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).
  8069. */
  8070. get shadowsHue(): number;
  8071. /**
  8072. * Sets the shadows Hue value.
  8073. * 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).
  8074. */
  8075. set shadowsHue(value: number);
  8076. /**
  8077. * Gets the shadows Density value.
  8078. * 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.
  8079. * Values less than zero provide a filter of opposite hue.
  8080. */
  8081. get shadowsDensity(): number;
  8082. /**
  8083. * Sets the shadows Density value.
  8084. * 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.
  8085. * Values less than zero provide a filter of opposite hue.
  8086. */
  8087. set shadowsDensity(value: number);
  8088. /**
  8089. * Gets the shadows Saturation value.
  8090. * 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.
  8091. */
  8092. get shadowsSaturation(): number;
  8093. /**
  8094. * Sets the shadows Saturation value.
  8095. * 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.
  8096. */
  8097. set shadowsSaturation(value: number);
  8098. /**
  8099. * Gets the shadows Exposure value.
  8100. * 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.
  8101. */
  8102. get shadowsExposure(): number;
  8103. /**
  8104. * Sets the shadows Exposure value.
  8105. * 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.
  8106. */
  8107. set shadowsExposure(value: number);
  8108. /**
  8109. * Returns the class name
  8110. * @returns The class name
  8111. */
  8112. getClassName(): string;
  8113. /**
  8114. * Binds the color curves to the shader.
  8115. * @param colorCurves The color curve to bind
  8116. * @param effect The effect to bind to
  8117. * @param positiveUniform The positive uniform shader parameter
  8118. * @param neutralUniform The neutral uniform shader parameter
  8119. * @param negativeUniform The negative uniform shader parameter
  8120. */
  8121. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8122. /**
  8123. * Prepare the list of uniforms associated with the ColorCurves effects.
  8124. * @param uniformsList The list of uniforms used in the effect
  8125. */
  8126. static PrepareUniforms(uniformsList: string[]): void;
  8127. /**
  8128. * Returns color grading data based on a hue, density, saturation and exposure value.
  8129. * @param filterHue The hue of the color filter.
  8130. * @param filterDensity The density of the color filter.
  8131. * @param saturation The saturation.
  8132. * @param exposure The exposure.
  8133. * @param result The result data container.
  8134. */
  8135. private getColorGradingDataToRef;
  8136. /**
  8137. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8138. * @param value The input slider value in range [-100,100].
  8139. * @returns Adjusted value.
  8140. */
  8141. private static applyColorGradingSliderNonlinear;
  8142. /**
  8143. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8144. * @param hue The hue (H) input.
  8145. * @param saturation The saturation (S) input.
  8146. * @param brightness The brightness (B) input.
  8147. * @result An RGBA color represented as Vector4.
  8148. */
  8149. private static fromHSBToRef;
  8150. /**
  8151. * Returns a value clamped between min and max
  8152. * @param value The value to clamp
  8153. * @param min The minimum of value
  8154. * @param max The maximum of value
  8155. * @returns The clamped value.
  8156. */
  8157. private static clamp;
  8158. /**
  8159. * Clones the current color curve instance.
  8160. * @return The cloned curves
  8161. */
  8162. clone(): ColorCurves;
  8163. /**
  8164. * Serializes the current color curve instance to a json representation.
  8165. * @return a JSON representation
  8166. */
  8167. serialize(): any;
  8168. /**
  8169. * Parses the color curve from a json representation.
  8170. * @param source the JSON source to parse
  8171. * @return The parsed curves
  8172. */
  8173. static Parse(source: any): ColorCurves;
  8174. }
  8175. }
  8176. declare module BABYLON {
  8177. /**
  8178. * Interface to follow in your material defines to integrate easily the
  8179. * Image proccessing functions.
  8180. * @hidden
  8181. */
  8182. export interface IImageProcessingConfigurationDefines {
  8183. IMAGEPROCESSING: boolean;
  8184. VIGNETTE: boolean;
  8185. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8186. VIGNETTEBLENDMODEOPAQUE: boolean;
  8187. TONEMAPPING: boolean;
  8188. TONEMAPPING_ACES: boolean;
  8189. CONTRAST: boolean;
  8190. EXPOSURE: boolean;
  8191. COLORCURVES: boolean;
  8192. COLORGRADING: boolean;
  8193. COLORGRADING3D: boolean;
  8194. SAMPLER3DGREENDEPTH: boolean;
  8195. SAMPLER3DBGRMAP: boolean;
  8196. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8197. }
  8198. /**
  8199. * @hidden
  8200. */
  8201. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8202. IMAGEPROCESSING: boolean;
  8203. VIGNETTE: boolean;
  8204. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8205. VIGNETTEBLENDMODEOPAQUE: boolean;
  8206. TONEMAPPING: boolean;
  8207. TONEMAPPING_ACES: boolean;
  8208. CONTRAST: boolean;
  8209. COLORCURVES: boolean;
  8210. COLORGRADING: boolean;
  8211. COLORGRADING3D: boolean;
  8212. SAMPLER3DGREENDEPTH: boolean;
  8213. SAMPLER3DBGRMAP: boolean;
  8214. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8215. EXPOSURE: boolean;
  8216. constructor();
  8217. }
  8218. /**
  8219. * This groups together the common properties used for image processing either in direct forward pass
  8220. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8221. * or not.
  8222. */
  8223. export class ImageProcessingConfiguration {
  8224. /**
  8225. * Default tone mapping applied in BabylonJS.
  8226. */
  8227. static readonly TONEMAPPING_STANDARD: number;
  8228. /**
  8229. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8230. * to other engines rendering to increase portability.
  8231. */
  8232. static readonly TONEMAPPING_ACES: number;
  8233. /**
  8234. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8235. */
  8236. colorCurves: Nullable<ColorCurves>;
  8237. private _colorCurvesEnabled;
  8238. /**
  8239. * Gets wether the color curves effect is enabled.
  8240. */
  8241. get colorCurvesEnabled(): boolean;
  8242. /**
  8243. * Sets wether the color curves effect is enabled.
  8244. */
  8245. set colorCurvesEnabled(value: boolean);
  8246. private _colorGradingTexture;
  8247. /**
  8248. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8249. */
  8250. get colorGradingTexture(): Nullable<BaseTexture>;
  8251. /**
  8252. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8253. */
  8254. set colorGradingTexture(value: Nullable<BaseTexture>);
  8255. private _colorGradingEnabled;
  8256. /**
  8257. * Gets wether the color grading effect is enabled.
  8258. */
  8259. get colorGradingEnabled(): boolean;
  8260. /**
  8261. * Sets wether the color grading effect is enabled.
  8262. */
  8263. set colorGradingEnabled(value: boolean);
  8264. private _colorGradingWithGreenDepth;
  8265. /**
  8266. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8267. */
  8268. get colorGradingWithGreenDepth(): boolean;
  8269. /**
  8270. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8271. */
  8272. set colorGradingWithGreenDepth(value: boolean);
  8273. private _colorGradingBGR;
  8274. /**
  8275. * Gets wether the color grading texture contains BGR values.
  8276. */
  8277. get colorGradingBGR(): boolean;
  8278. /**
  8279. * Sets wether the color grading texture contains BGR values.
  8280. */
  8281. set colorGradingBGR(value: boolean);
  8282. /** @hidden */
  8283. _exposure: number;
  8284. /**
  8285. * Gets the Exposure used in the effect.
  8286. */
  8287. get exposure(): number;
  8288. /**
  8289. * Sets the Exposure used in the effect.
  8290. */
  8291. set exposure(value: number);
  8292. private _toneMappingEnabled;
  8293. /**
  8294. * Gets wether the tone mapping effect is enabled.
  8295. */
  8296. get toneMappingEnabled(): boolean;
  8297. /**
  8298. * Sets wether the tone mapping effect is enabled.
  8299. */
  8300. set toneMappingEnabled(value: boolean);
  8301. private _toneMappingType;
  8302. /**
  8303. * Gets the type of tone mapping effect.
  8304. */
  8305. get toneMappingType(): number;
  8306. /**
  8307. * Sets the type of tone mapping effect used in BabylonJS.
  8308. */
  8309. set toneMappingType(value: number);
  8310. protected _contrast: number;
  8311. /**
  8312. * Gets the contrast used in the effect.
  8313. */
  8314. get contrast(): number;
  8315. /**
  8316. * Sets the contrast used in the effect.
  8317. */
  8318. set contrast(value: number);
  8319. /**
  8320. * Vignette stretch size.
  8321. */
  8322. vignetteStretch: number;
  8323. /**
  8324. * Vignette centre X Offset.
  8325. */
  8326. vignetteCentreX: number;
  8327. /**
  8328. * Vignette centre Y Offset.
  8329. */
  8330. vignetteCentreY: number;
  8331. /**
  8332. * Vignette weight or intensity of the vignette effect.
  8333. */
  8334. vignetteWeight: number;
  8335. /**
  8336. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8337. * if vignetteEnabled is set to true.
  8338. */
  8339. vignetteColor: Color4;
  8340. /**
  8341. * Camera field of view used by the Vignette effect.
  8342. */
  8343. vignetteCameraFov: number;
  8344. private _vignetteBlendMode;
  8345. /**
  8346. * Gets the vignette blend mode allowing different kind of effect.
  8347. */
  8348. get vignetteBlendMode(): number;
  8349. /**
  8350. * Sets the vignette blend mode allowing different kind of effect.
  8351. */
  8352. set vignetteBlendMode(value: number);
  8353. private _vignetteEnabled;
  8354. /**
  8355. * Gets wether the vignette effect is enabled.
  8356. */
  8357. get vignetteEnabled(): boolean;
  8358. /**
  8359. * Sets wether the vignette effect is enabled.
  8360. */
  8361. set vignetteEnabled(value: boolean);
  8362. private _applyByPostProcess;
  8363. /**
  8364. * Gets wether the image processing is applied through a post process or not.
  8365. */
  8366. get applyByPostProcess(): boolean;
  8367. /**
  8368. * Sets wether the image processing is applied through a post process or not.
  8369. */
  8370. set applyByPostProcess(value: boolean);
  8371. private _isEnabled;
  8372. /**
  8373. * Gets wether the image processing is enabled or not.
  8374. */
  8375. get isEnabled(): boolean;
  8376. /**
  8377. * Sets wether the image processing is enabled or not.
  8378. */
  8379. set isEnabled(value: boolean);
  8380. /**
  8381. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8382. */
  8383. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8384. /**
  8385. * Method called each time the image processing information changes requires to recompile the effect.
  8386. */
  8387. protected _updateParameters(): void;
  8388. /**
  8389. * Gets the current class name.
  8390. * @return "ImageProcessingConfiguration"
  8391. */
  8392. getClassName(): string;
  8393. /**
  8394. * Prepare the list of uniforms associated with the Image Processing effects.
  8395. * @param uniforms The list of uniforms used in the effect
  8396. * @param defines the list of defines currently in use
  8397. */
  8398. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8399. /**
  8400. * Prepare the list of samplers associated with the Image Processing effects.
  8401. * @param samplersList The list of uniforms used in the effect
  8402. * @param defines the list of defines currently in use
  8403. */
  8404. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8405. /**
  8406. * Prepare the list of defines associated to the shader.
  8407. * @param defines the list of defines to complete
  8408. * @param forPostProcess Define if we are currently in post process mode or not
  8409. */
  8410. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8411. /**
  8412. * Returns true if all the image processing information are ready.
  8413. * @returns True if ready, otherwise, false
  8414. */
  8415. isReady(): boolean;
  8416. /**
  8417. * Binds the image processing to the shader.
  8418. * @param effect The effect to bind to
  8419. * @param overrideAspectRatio Override the aspect ratio of the effect
  8420. */
  8421. bind(effect: Effect, overrideAspectRatio?: number): void;
  8422. /**
  8423. * Clones the current image processing instance.
  8424. * @return The cloned image processing
  8425. */
  8426. clone(): ImageProcessingConfiguration;
  8427. /**
  8428. * Serializes the current image processing instance to a json representation.
  8429. * @return a JSON representation
  8430. */
  8431. serialize(): any;
  8432. /**
  8433. * Parses the image processing from a json representation.
  8434. * @param source the JSON source to parse
  8435. * @return The parsed image processing
  8436. */
  8437. static Parse(source: any): ImageProcessingConfiguration;
  8438. private static _VIGNETTEMODE_MULTIPLY;
  8439. private static _VIGNETTEMODE_OPAQUE;
  8440. /**
  8441. * Used to apply the vignette as a mix with the pixel color.
  8442. */
  8443. static get VIGNETTEMODE_MULTIPLY(): number;
  8444. /**
  8445. * Used to apply the vignette as a replacement of the pixel color.
  8446. */
  8447. static get VIGNETTEMODE_OPAQUE(): number;
  8448. }
  8449. }
  8450. declare module BABYLON {
  8451. /** @hidden */
  8452. export var postprocessVertexShader: {
  8453. name: string;
  8454. shader: string;
  8455. };
  8456. }
  8457. declare module BABYLON {
  8458. interface ThinEngine {
  8459. /**
  8460. * Creates a new render target texture
  8461. * @param size defines the size of the texture
  8462. * @param options defines the options used to create the texture
  8463. * @returns a new render target texture stored in an InternalTexture
  8464. */
  8465. createRenderTargetTexture(size: number | {
  8466. width: number;
  8467. height: number;
  8468. layers?: number;
  8469. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8470. /**
  8471. * Creates a depth stencil texture.
  8472. * This is only available in WebGL 2 or with the depth texture extension available.
  8473. * @param size The size of face edge in the texture.
  8474. * @param options The options defining the texture.
  8475. * @returns The texture
  8476. */
  8477. createDepthStencilTexture(size: number | {
  8478. width: number;
  8479. height: number;
  8480. layers?: number;
  8481. }, options: DepthTextureCreationOptions): InternalTexture;
  8482. /** @hidden */
  8483. _createDepthStencilTexture(size: number | {
  8484. width: number;
  8485. height: number;
  8486. layers?: number;
  8487. }, options: DepthTextureCreationOptions): InternalTexture;
  8488. }
  8489. }
  8490. declare module BABYLON {
  8491. /** Defines supported spaces */
  8492. export enum Space {
  8493. /** Local (object) space */
  8494. LOCAL = 0,
  8495. /** World space */
  8496. WORLD = 1,
  8497. /** Bone space */
  8498. BONE = 2
  8499. }
  8500. /** Defines the 3 main axes */
  8501. export class Axis {
  8502. /** X axis */
  8503. static X: Vector3;
  8504. /** Y axis */
  8505. static Y: Vector3;
  8506. /** Z axis */
  8507. static Z: Vector3;
  8508. }
  8509. }
  8510. declare module BABYLON {
  8511. /**
  8512. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8513. * This is the base of the follow, arc rotate cameras and Free camera
  8514. * @see http://doc.babylonjs.com/features/cameras
  8515. */
  8516. export class TargetCamera extends Camera {
  8517. private static _RigCamTransformMatrix;
  8518. private static _TargetTransformMatrix;
  8519. private static _TargetFocalPoint;
  8520. /**
  8521. * Define the current direction the camera is moving to
  8522. */
  8523. cameraDirection: Vector3;
  8524. /**
  8525. * Define the current rotation the camera is rotating to
  8526. */
  8527. cameraRotation: Vector2;
  8528. /**
  8529. * When set, the up vector of the camera will be updated by the rotation of the camera
  8530. */
  8531. updateUpVectorFromRotation: boolean;
  8532. private _tmpQuaternion;
  8533. /**
  8534. * Define the current rotation of the camera
  8535. */
  8536. rotation: Vector3;
  8537. /**
  8538. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8539. */
  8540. rotationQuaternion: Quaternion;
  8541. /**
  8542. * Define the current speed of the camera
  8543. */
  8544. speed: number;
  8545. /**
  8546. * Add constraint to the camera to prevent it to move freely in all directions and
  8547. * around all axis.
  8548. */
  8549. noRotationConstraint: boolean;
  8550. /**
  8551. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8552. * panning
  8553. */
  8554. invertRotation: boolean;
  8555. /**
  8556. * Speed multiplier for inverse camera panning
  8557. */
  8558. inverseRotationSpeed: number;
  8559. /**
  8560. * Define the current target of the camera as an object or a position.
  8561. */
  8562. lockedTarget: any;
  8563. /** @hidden */
  8564. _currentTarget: Vector3;
  8565. /** @hidden */
  8566. _initialFocalDistance: number;
  8567. /** @hidden */
  8568. _viewMatrix: Matrix;
  8569. /** @hidden */
  8570. _camMatrix: Matrix;
  8571. /** @hidden */
  8572. _cameraTransformMatrix: Matrix;
  8573. /** @hidden */
  8574. _cameraRotationMatrix: Matrix;
  8575. /** @hidden */
  8576. _referencePoint: Vector3;
  8577. /** @hidden */
  8578. _transformedReferencePoint: Vector3;
  8579. protected _globalCurrentTarget: Vector3;
  8580. protected _globalCurrentUpVector: Vector3;
  8581. /** @hidden */
  8582. _reset: () => void;
  8583. private _defaultUp;
  8584. /**
  8585. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8586. * This is the base of the follow, arc rotate cameras and Free camera
  8587. * @see http://doc.babylonjs.com/features/cameras
  8588. * @param name Defines the name of the camera in the scene
  8589. * @param position Defines the start position of the camera in the scene
  8590. * @param scene Defines the scene the camera belongs to
  8591. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8592. */
  8593. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8594. /**
  8595. * Gets the position in front of the camera at a given distance.
  8596. * @param distance The distance from the camera we want the position to be
  8597. * @returns the position
  8598. */
  8599. getFrontPosition(distance: number): Vector3;
  8600. /** @hidden */
  8601. _getLockedTargetPosition(): Nullable<Vector3>;
  8602. private _storedPosition;
  8603. private _storedRotation;
  8604. private _storedRotationQuaternion;
  8605. /**
  8606. * Store current camera state of the camera (fov, position, rotation, etc..)
  8607. * @returns the camera
  8608. */
  8609. storeState(): Camera;
  8610. /**
  8611. * Restored camera state. You must call storeState() first
  8612. * @returns whether it was successful or not
  8613. * @hidden
  8614. */
  8615. _restoreStateValues(): boolean;
  8616. /** @hidden */
  8617. _initCache(): void;
  8618. /** @hidden */
  8619. _updateCache(ignoreParentClass?: boolean): void;
  8620. /** @hidden */
  8621. _isSynchronizedViewMatrix(): boolean;
  8622. /** @hidden */
  8623. _computeLocalCameraSpeed(): number;
  8624. /**
  8625. * Defines the target the camera should look at.
  8626. * @param target Defines the new target as a Vector or a mesh
  8627. */
  8628. setTarget(target: Vector3): void;
  8629. /**
  8630. * Return the current target position of the camera. This value is expressed in local space.
  8631. * @returns the target position
  8632. */
  8633. getTarget(): Vector3;
  8634. /** @hidden */
  8635. _decideIfNeedsToMove(): boolean;
  8636. /** @hidden */
  8637. _updatePosition(): void;
  8638. /** @hidden */
  8639. _checkInputs(): void;
  8640. protected _updateCameraRotationMatrix(): void;
  8641. /**
  8642. * 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)
  8643. * @returns the current camera
  8644. */
  8645. private _rotateUpVectorWithCameraRotationMatrix;
  8646. private _cachedRotationZ;
  8647. private _cachedQuaternionRotationZ;
  8648. /** @hidden */
  8649. _getViewMatrix(): Matrix;
  8650. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8651. /**
  8652. * @hidden
  8653. */
  8654. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8655. /**
  8656. * @hidden
  8657. */
  8658. _updateRigCameras(): void;
  8659. private _getRigCamPositionAndTarget;
  8660. /**
  8661. * Gets the current object class name.
  8662. * @return the class name
  8663. */
  8664. getClassName(): string;
  8665. }
  8666. }
  8667. declare module BABYLON {
  8668. /**
  8669. * Gather the list of keyboard event types as constants.
  8670. */
  8671. export class KeyboardEventTypes {
  8672. /**
  8673. * The keydown event is fired when a key becomes active (pressed).
  8674. */
  8675. static readonly KEYDOWN: number;
  8676. /**
  8677. * The keyup event is fired when a key has been released.
  8678. */
  8679. static readonly KEYUP: number;
  8680. }
  8681. /**
  8682. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8683. */
  8684. export class KeyboardInfo {
  8685. /**
  8686. * Defines the type of event (KeyboardEventTypes)
  8687. */
  8688. type: number;
  8689. /**
  8690. * Defines the related dom event
  8691. */
  8692. event: KeyboardEvent;
  8693. /**
  8694. * Instantiates a new keyboard info.
  8695. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8696. * @param type Defines the type of event (KeyboardEventTypes)
  8697. * @param event Defines the related dom event
  8698. */
  8699. constructor(
  8700. /**
  8701. * Defines the type of event (KeyboardEventTypes)
  8702. */
  8703. type: number,
  8704. /**
  8705. * Defines the related dom event
  8706. */
  8707. event: KeyboardEvent);
  8708. }
  8709. /**
  8710. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8711. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8712. */
  8713. export class KeyboardInfoPre extends KeyboardInfo {
  8714. /**
  8715. * Defines the type of event (KeyboardEventTypes)
  8716. */
  8717. type: number;
  8718. /**
  8719. * Defines the related dom event
  8720. */
  8721. event: KeyboardEvent;
  8722. /**
  8723. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8724. */
  8725. skipOnPointerObservable: boolean;
  8726. /**
  8727. * Instantiates a new keyboard pre info.
  8728. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8729. * @param type Defines the type of event (KeyboardEventTypes)
  8730. * @param event Defines the related dom event
  8731. */
  8732. constructor(
  8733. /**
  8734. * Defines the type of event (KeyboardEventTypes)
  8735. */
  8736. type: number,
  8737. /**
  8738. * Defines the related dom event
  8739. */
  8740. event: KeyboardEvent);
  8741. }
  8742. }
  8743. declare module BABYLON {
  8744. /**
  8745. * Manage the keyboard inputs to control the movement of a free camera.
  8746. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8747. */
  8748. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8749. /**
  8750. * Defines the camera the input is attached to.
  8751. */
  8752. camera: FreeCamera;
  8753. /**
  8754. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8755. */
  8756. keysUp: number[];
  8757. /**
  8758. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  8759. */
  8760. keysUpward: number[];
  8761. /**
  8762. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8763. */
  8764. keysDown: number[];
  8765. /**
  8766. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  8767. */
  8768. keysDownward: number[];
  8769. /**
  8770. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8771. */
  8772. keysLeft: number[];
  8773. /**
  8774. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8775. */
  8776. keysRight: number[];
  8777. private _keys;
  8778. private _onCanvasBlurObserver;
  8779. private _onKeyboardObserver;
  8780. private _engine;
  8781. private _scene;
  8782. /**
  8783. * Attach the input controls to a specific dom element to get the input from.
  8784. * @param element Defines the element the controls should be listened from
  8785. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8786. */
  8787. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8788. /**
  8789. * Detach the current controls from the specified dom element.
  8790. * @param element Defines the element to stop listening the inputs from
  8791. */
  8792. detachControl(element: Nullable<HTMLElement>): void;
  8793. /**
  8794. * Update the current camera state depending on the inputs that have been used this frame.
  8795. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8796. */
  8797. checkInputs(): void;
  8798. /**
  8799. * Gets the class name of the current intput.
  8800. * @returns the class name
  8801. */
  8802. getClassName(): string;
  8803. /** @hidden */
  8804. _onLostFocus(): void;
  8805. /**
  8806. * Get the friendly name associated with the input class.
  8807. * @returns the input friendly name
  8808. */
  8809. getSimpleName(): string;
  8810. }
  8811. }
  8812. declare module BABYLON {
  8813. /**
  8814. * Interface describing all the common properties and methods a shadow light needs to implement.
  8815. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8816. * as well as binding the different shadow properties to the effects.
  8817. */
  8818. export interface IShadowLight extends Light {
  8819. /**
  8820. * The light id in the scene (used in scene.findLighById for instance)
  8821. */
  8822. id: string;
  8823. /**
  8824. * The position the shdow will be casted from.
  8825. */
  8826. position: Vector3;
  8827. /**
  8828. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8829. */
  8830. direction: Vector3;
  8831. /**
  8832. * The transformed position. Position of the light in world space taking parenting in account.
  8833. */
  8834. transformedPosition: Vector3;
  8835. /**
  8836. * The transformed direction. Direction of the light in world space taking parenting in account.
  8837. */
  8838. transformedDirection: Vector3;
  8839. /**
  8840. * The friendly name of the light in the scene.
  8841. */
  8842. name: string;
  8843. /**
  8844. * Defines the shadow projection clipping minimum z value.
  8845. */
  8846. shadowMinZ: number;
  8847. /**
  8848. * Defines the shadow projection clipping maximum z value.
  8849. */
  8850. shadowMaxZ: number;
  8851. /**
  8852. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8853. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8854. */
  8855. computeTransformedInformation(): boolean;
  8856. /**
  8857. * Gets the scene the light belongs to.
  8858. * @returns The scene
  8859. */
  8860. getScene(): Scene;
  8861. /**
  8862. * Callback defining a custom Projection Matrix Builder.
  8863. * This can be used to override the default projection matrix computation.
  8864. */
  8865. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8866. /**
  8867. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8868. * @param matrix The materix to updated with the projection information
  8869. * @param viewMatrix The transform matrix of the light
  8870. * @param renderList The list of mesh to render in the map
  8871. * @returns The current light
  8872. */
  8873. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8874. /**
  8875. * Gets the current depth scale used in ESM.
  8876. * @returns The scale
  8877. */
  8878. getDepthScale(): number;
  8879. /**
  8880. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8881. * @returns true if a cube texture needs to be use
  8882. */
  8883. needCube(): boolean;
  8884. /**
  8885. * Detects if the projection matrix requires to be recomputed this frame.
  8886. * @returns true if it requires to be recomputed otherwise, false.
  8887. */
  8888. needProjectionMatrixCompute(): boolean;
  8889. /**
  8890. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8891. */
  8892. forceProjectionMatrixCompute(): void;
  8893. /**
  8894. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8895. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8896. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8897. */
  8898. getShadowDirection(faceIndex?: number): Vector3;
  8899. /**
  8900. * Gets the minZ used for shadow according to both the scene and the light.
  8901. * @param activeCamera The camera we are returning the min for
  8902. * @returns the depth min z
  8903. */
  8904. getDepthMinZ(activeCamera: Camera): number;
  8905. /**
  8906. * Gets the maxZ used for shadow according to both the scene and the light.
  8907. * @param activeCamera The camera we are returning the max for
  8908. * @returns the depth max z
  8909. */
  8910. getDepthMaxZ(activeCamera: Camera): number;
  8911. }
  8912. /**
  8913. * Base implementation IShadowLight
  8914. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8915. */
  8916. export abstract class ShadowLight extends Light implements IShadowLight {
  8917. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8918. protected _position: Vector3;
  8919. protected _setPosition(value: Vector3): void;
  8920. /**
  8921. * Sets the position the shadow will be casted from. Also use as the light position for both
  8922. * point and spot lights.
  8923. */
  8924. get position(): Vector3;
  8925. /**
  8926. * Sets the position the shadow will be casted from. Also use as the light position for both
  8927. * point and spot lights.
  8928. */
  8929. set position(value: Vector3);
  8930. protected _direction: Vector3;
  8931. protected _setDirection(value: Vector3): void;
  8932. /**
  8933. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8934. * Also use as the light direction on spot and directional lights.
  8935. */
  8936. get direction(): Vector3;
  8937. /**
  8938. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8939. * Also use as the light direction on spot and directional lights.
  8940. */
  8941. set direction(value: Vector3);
  8942. protected _shadowMinZ: number;
  8943. /**
  8944. * Gets the shadow projection clipping minimum z value.
  8945. */
  8946. get shadowMinZ(): number;
  8947. /**
  8948. * Sets the shadow projection clipping minimum z value.
  8949. */
  8950. set shadowMinZ(value: number);
  8951. protected _shadowMaxZ: number;
  8952. /**
  8953. * Sets the shadow projection clipping maximum z value.
  8954. */
  8955. get shadowMaxZ(): number;
  8956. /**
  8957. * Gets the shadow projection clipping maximum z value.
  8958. */
  8959. set shadowMaxZ(value: number);
  8960. /**
  8961. * Callback defining a custom Projection Matrix Builder.
  8962. * This can be used to override the default projection matrix computation.
  8963. */
  8964. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8965. /**
  8966. * The transformed position. Position of the light in world space taking parenting in account.
  8967. */
  8968. transformedPosition: Vector3;
  8969. /**
  8970. * The transformed direction. Direction of the light in world space taking parenting in account.
  8971. */
  8972. transformedDirection: Vector3;
  8973. private _needProjectionMatrixCompute;
  8974. /**
  8975. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8976. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8977. */
  8978. computeTransformedInformation(): boolean;
  8979. /**
  8980. * Return the depth scale used for the shadow map.
  8981. * @returns the depth scale.
  8982. */
  8983. getDepthScale(): number;
  8984. /**
  8985. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8986. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8987. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8988. */
  8989. getShadowDirection(faceIndex?: number): Vector3;
  8990. /**
  8991. * Returns the ShadowLight absolute position in the World.
  8992. * @returns the position vector in world space
  8993. */
  8994. getAbsolutePosition(): Vector3;
  8995. /**
  8996. * Sets the ShadowLight direction toward the passed target.
  8997. * @param target The point to target in local space
  8998. * @returns the updated ShadowLight direction
  8999. */
  9000. setDirectionToTarget(target: Vector3): Vector3;
  9001. /**
  9002. * Returns the light rotation in euler definition.
  9003. * @returns the x y z rotation in local space.
  9004. */
  9005. getRotation(): Vector3;
  9006. /**
  9007. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9008. * @returns true if a cube texture needs to be use
  9009. */
  9010. needCube(): boolean;
  9011. /**
  9012. * Detects if the projection matrix requires to be recomputed this frame.
  9013. * @returns true if it requires to be recomputed otherwise, false.
  9014. */
  9015. needProjectionMatrixCompute(): boolean;
  9016. /**
  9017. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9018. */
  9019. forceProjectionMatrixCompute(): void;
  9020. /** @hidden */
  9021. _initCache(): void;
  9022. /** @hidden */
  9023. _isSynchronized(): boolean;
  9024. /**
  9025. * Computes the world matrix of the node
  9026. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9027. * @returns the world matrix
  9028. */
  9029. computeWorldMatrix(force?: boolean): Matrix;
  9030. /**
  9031. * Gets the minZ used for shadow according to both the scene and the light.
  9032. * @param activeCamera The camera we are returning the min for
  9033. * @returns the depth min z
  9034. */
  9035. getDepthMinZ(activeCamera: Camera): number;
  9036. /**
  9037. * Gets the maxZ used for shadow according to both the scene and the light.
  9038. * @param activeCamera The camera we are returning the max for
  9039. * @returns the depth max z
  9040. */
  9041. getDepthMaxZ(activeCamera: Camera): number;
  9042. /**
  9043. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9044. * @param matrix The materix to updated with the projection information
  9045. * @param viewMatrix The transform matrix of the light
  9046. * @param renderList The list of mesh to render in the map
  9047. * @returns The current light
  9048. */
  9049. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9050. }
  9051. }
  9052. declare module BABYLON {
  9053. /**
  9054. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9055. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9056. */
  9057. export class EffectFallbacks implements IEffectFallbacks {
  9058. private _defines;
  9059. private _currentRank;
  9060. private _maxRank;
  9061. private _mesh;
  9062. /**
  9063. * Removes the fallback from the bound mesh.
  9064. */
  9065. unBindMesh(): void;
  9066. /**
  9067. * Adds a fallback on the specified property.
  9068. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9069. * @param define The name of the define in the shader
  9070. */
  9071. addFallback(rank: number, define: string): void;
  9072. /**
  9073. * Sets the mesh to use CPU skinning when needing to fallback.
  9074. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9075. * @param mesh The mesh to use the fallbacks.
  9076. */
  9077. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9078. /**
  9079. * Checks to see if more fallbacks are still availible.
  9080. */
  9081. get hasMoreFallbacks(): boolean;
  9082. /**
  9083. * Removes the defines that should be removed when falling back.
  9084. * @param currentDefines defines the current define statements for the shader.
  9085. * @param effect defines the current effect we try to compile
  9086. * @returns The resulting defines with defines of the current rank removed.
  9087. */
  9088. reduce(currentDefines: string, effect: Effect): string;
  9089. }
  9090. }
  9091. declare module BABYLON {
  9092. /**
  9093. * "Static Class" containing the most commonly used helper while dealing with material for
  9094. * rendering purpose.
  9095. *
  9096. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9097. *
  9098. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9099. */
  9100. export class MaterialHelper {
  9101. /**
  9102. * Bind the current view position to an effect.
  9103. * @param effect The effect to be bound
  9104. * @param scene The scene the eyes position is used from
  9105. */
  9106. static BindEyePosition(effect: Effect, scene: Scene): void;
  9107. /**
  9108. * Helps preparing the defines values about the UVs in used in the effect.
  9109. * UVs are shared as much as we can accross channels in the shaders.
  9110. * @param texture The texture we are preparing the UVs for
  9111. * @param defines The defines to update
  9112. * @param key The channel key "diffuse", "specular"... used in the shader
  9113. */
  9114. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9115. /**
  9116. * Binds a texture matrix value to its corrsponding uniform
  9117. * @param texture The texture to bind the matrix for
  9118. * @param uniformBuffer The uniform buffer receivin the data
  9119. * @param key The channel key "diffuse", "specular"... used in the shader
  9120. */
  9121. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9122. /**
  9123. * Gets the current status of the fog (should it be enabled?)
  9124. * @param mesh defines the mesh to evaluate for fog support
  9125. * @param scene defines the hosting scene
  9126. * @returns true if fog must be enabled
  9127. */
  9128. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9129. /**
  9130. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9131. * @param mesh defines the current mesh
  9132. * @param scene defines the current scene
  9133. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9134. * @param pointsCloud defines if point cloud rendering has to be turned on
  9135. * @param fogEnabled defines if fog has to be turned on
  9136. * @param alphaTest defines if alpha testing has to be turned on
  9137. * @param defines defines the current list of defines
  9138. */
  9139. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9140. /**
  9141. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9142. * @param scene defines the current scene
  9143. * @param engine defines the current engine
  9144. * @param defines specifies the list of active defines
  9145. * @param useInstances defines if instances have to be turned on
  9146. * @param useClipPlane defines if clip plane have to be turned on
  9147. */
  9148. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9149. /**
  9150. * Prepares the defines for bones
  9151. * @param mesh The mesh containing the geometry data we will draw
  9152. * @param defines The defines to update
  9153. */
  9154. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9155. /**
  9156. * Prepares the defines for morph targets
  9157. * @param mesh The mesh containing the geometry data we will draw
  9158. * @param defines The defines to update
  9159. */
  9160. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9161. /**
  9162. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9163. * @param mesh The mesh containing the geometry data we will draw
  9164. * @param defines The defines to update
  9165. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9166. * @param useBones Precise whether bones should be used or not (override mesh info)
  9167. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9168. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9169. * @returns false if defines are considered not dirty and have not been checked
  9170. */
  9171. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9172. /**
  9173. * Prepares the defines related to multiview
  9174. * @param scene The scene we are intending to draw
  9175. * @param defines The defines to update
  9176. */
  9177. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9178. /**
  9179. * Prepares the defines related to the light information passed in parameter
  9180. * @param scene The scene we are intending to draw
  9181. * @param mesh The mesh the effect is compiling for
  9182. * @param light The light the effect is compiling for
  9183. * @param lightIndex The index of the light
  9184. * @param defines The defines to update
  9185. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9186. * @param state Defines the current state regarding what is needed (normals, etc...)
  9187. */
  9188. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9189. needNormals: boolean;
  9190. needRebuild: boolean;
  9191. shadowEnabled: boolean;
  9192. specularEnabled: boolean;
  9193. lightmapMode: boolean;
  9194. }): void;
  9195. /**
  9196. * Prepares the defines related to the light information passed in parameter
  9197. * @param scene The scene we are intending to draw
  9198. * @param mesh The mesh the effect is compiling for
  9199. * @param defines The defines to update
  9200. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9201. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9202. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9203. * @returns true if normals will be required for the rest of the effect
  9204. */
  9205. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9206. /**
  9207. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9208. * @param lightIndex defines the light index
  9209. * @param uniformsList The uniform list
  9210. * @param samplersList The sampler list
  9211. * @param projectedLightTexture defines if projected texture must be used
  9212. * @param uniformBuffersList defines an optional list of uniform buffers
  9213. */
  9214. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9215. /**
  9216. * Prepares the uniforms and samplers list to be used in the effect
  9217. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9218. * @param samplersList The sampler list
  9219. * @param defines The defines helping in the list generation
  9220. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9221. */
  9222. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9223. /**
  9224. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9225. * @param defines The defines to update while falling back
  9226. * @param fallbacks The authorized effect fallbacks
  9227. * @param maxSimultaneousLights The maximum number of lights allowed
  9228. * @param rank the current rank of the Effect
  9229. * @returns The newly affected rank
  9230. */
  9231. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9232. private static _TmpMorphInfluencers;
  9233. /**
  9234. * Prepares the list of attributes required for morph targets according to the effect defines.
  9235. * @param attribs The current list of supported attribs
  9236. * @param mesh The mesh to prepare the morph targets attributes for
  9237. * @param influencers The number of influencers
  9238. */
  9239. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9240. /**
  9241. * Prepares the list of attributes required for morph targets according to the effect defines.
  9242. * @param attribs The current list of supported attribs
  9243. * @param mesh The mesh to prepare the morph targets attributes for
  9244. * @param defines The current Defines of the effect
  9245. */
  9246. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9247. /**
  9248. * Prepares the list of attributes required for bones according to the effect defines.
  9249. * @param attribs The current list of supported attribs
  9250. * @param mesh The mesh to prepare the bones attributes for
  9251. * @param defines The current Defines of the effect
  9252. * @param fallbacks The current efffect fallback strategy
  9253. */
  9254. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9255. /**
  9256. * Check and prepare the list of attributes required for instances according to the effect defines.
  9257. * @param attribs The current list of supported attribs
  9258. * @param defines The current MaterialDefines of the effect
  9259. */
  9260. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9261. /**
  9262. * Add the list of attributes required for instances to the attribs array.
  9263. * @param attribs The current list of supported attribs
  9264. */
  9265. static PushAttributesForInstances(attribs: string[]): void;
  9266. /**
  9267. * Binds the light information to the effect.
  9268. * @param light The light containing the generator
  9269. * @param effect The effect we are binding the data to
  9270. * @param lightIndex The light index in the effect used to render
  9271. */
  9272. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9273. /**
  9274. * Binds the lights information from the scene to the effect for the given mesh.
  9275. * @param light Light to bind
  9276. * @param lightIndex Light index
  9277. * @param scene The scene where the light belongs to
  9278. * @param effect The effect we are binding the data to
  9279. * @param useSpecular Defines if specular is supported
  9280. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9281. */
  9282. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9283. /**
  9284. * Binds the lights information from the scene to the effect for the given mesh.
  9285. * @param scene The scene the lights belongs to
  9286. * @param mesh The mesh we are binding the information to render
  9287. * @param effect The effect we are binding the data to
  9288. * @param defines The generated defines for the effect
  9289. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9290. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9291. */
  9292. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9293. private static _tempFogColor;
  9294. /**
  9295. * Binds the fog 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 linearSpace Defines if the fog effect is applied in linear space
  9300. */
  9301. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9302. /**
  9303. * Binds the bones information from the mesh to the effect.
  9304. * @param mesh The mesh we are binding the information to render
  9305. * @param effect The effect we are binding the data to
  9306. */
  9307. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9308. /**
  9309. * Binds the morph targets information from the mesh to the effect.
  9310. * @param abstractMesh The mesh we are binding the information to render
  9311. * @param effect The effect we are binding the data to
  9312. */
  9313. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9314. /**
  9315. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9316. * @param defines The generated defines used in the effect
  9317. * @param effect The effect we are binding the data to
  9318. * @param scene The scene we are willing to render with logarithmic scale for
  9319. */
  9320. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9321. /**
  9322. * Binds the clip plane information from the scene to the effect.
  9323. * @param scene The scene the clip plane information are extracted from
  9324. * @param effect The effect we are binding the data to
  9325. */
  9326. static BindClipPlane(effect: Effect, scene: Scene): void;
  9327. }
  9328. }
  9329. declare module BABYLON {
  9330. /** @hidden */
  9331. export var packingFunctions: {
  9332. name: string;
  9333. shader: string;
  9334. };
  9335. }
  9336. declare module BABYLON {
  9337. /** @hidden */
  9338. export var clipPlaneFragmentDeclaration: {
  9339. name: string;
  9340. shader: string;
  9341. };
  9342. }
  9343. declare module BABYLON {
  9344. /** @hidden */
  9345. export var clipPlaneFragment: {
  9346. name: string;
  9347. shader: string;
  9348. };
  9349. }
  9350. declare module BABYLON {
  9351. /** @hidden */
  9352. export var shadowMapPixelShader: {
  9353. name: string;
  9354. shader: string;
  9355. };
  9356. }
  9357. declare module BABYLON {
  9358. /** @hidden */
  9359. export var bonesDeclaration: {
  9360. name: string;
  9361. shader: string;
  9362. };
  9363. }
  9364. declare module BABYLON {
  9365. /** @hidden */
  9366. export var morphTargetsVertexGlobalDeclaration: {
  9367. name: string;
  9368. shader: string;
  9369. };
  9370. }
  9371. declare module BABYLON {
  9372. /** @hidden */
  9373. export var morphTargetsVertexDeclaration: {
  9374. name: string;
  9375. shader: string;
  9376. };
  9377. }
  9378. declare module BABYLON {
  9379. /** @hidden */
  9380. export var instancesDeclaration: {
  9381. name: string;
  9382. shader: string;
  9383. };
  9384. }
  9385. declare module BABYLON {
  9386. /** @hidden */
  9387. export var helperFunctions: {
  9388. name: string;
  9389. shader: string;
  9390. };
  9391. }
  9392. declare module BABYLON {
  9393. /** @hidden */
  9394. export var clipPlaneVertexDeclaration: {
  9395. name: string;
  9396. shader: string;
  9397. };
  9398. }
  9399. declare module BABYLON {
  9400. /** @hidden */
  9401. export var morphTargetsVertex: {
  9402. name: string;
  9403. shader: string;
  9404. };
  9405. }
  9406. declare module BABYLON {
  9407. /** @hidden */
  9408. export var instancesVertex: {
  9409. name: string;
  9410. shader: string;
  9411. };
  9412. }
  9413. declare module BABYLON {
  9414. /** @hidden */
  9415. export var bonesVertex: {
  9416. name: string;
  9417. shader: string;
  9418. };
  9419. }
  9420. declare module BABYLON {
  9421. /** @hidden */
  9422. export var clipPlaneVertex: {
  9423. name: string;
  9424. shader: string;
  9425. };
  9426. }
  9427. declare module BABYLON {
  9428. /** @hidden */
  9429. export var shadowMapVertexShader: {
  9430. name: string;
  9431. shader: string;
  9432. };
  9433. }
  9434. declare module BABYLON {
  9435. /** @hidden */
  9436. export var depthBoxBlurPixelShader: {
  9437. name: string;
  9438. shader: string;
  9439. };
  9440. }
  9441. declare module BABYLON {
  9442. /**
  9443. * Class representing a ray with position and direction
  9444. */
  9445. export class Ray {
  9446. /** origin point */
  9447. origin: Vector3;
  9448. /** direction */
  9449. direction: Vector3;
  9450. /** length of the ray */
  9451. length: number;
  9452. private static readonly TmpVector3;
  9453. private _tmpRay;
  9454. /**
  9455. * Creates a new ray
  9456. * @param origin origin point
  9457. * @param direction direction
  9458. * @param length length of the ray
  9459. */
  9460. constructor(
  9461. /** origin point */
  9462. origin: Vector3,
  9463. /** direction */
  9464. direction: Vector3,
  9465. /** length of the ray */
  9466. length?: number);
  9467. /**
  9468. * Checks if the ray intersects a box
  9469. * @param minimum bound of the box
  9470. * @param maximum bound of the box
  9471. * @param intersectionTreshold extra extend to be added to the box in all direction
  9472. * @returns if the box was hit
  9473. */
  9474. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9475. /**
  9476. * Checks if the ray intersects a box
  9477. * @param box the bounding box to check
  9478. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9479. * @returns if the box was hit
  9480. */
  9481. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9482. /**
  9483. * If the ray hits a sphere
  9484. * @param sphere the bounding sphere to check
  9485. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9486. * @returns true if it hits the sphere
  9487. */
  9488. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9489. /**
  9490. * If the ray hits a triange
  9491. * @param vertex0 triangle vertex
  9492. * @param vertex1 triangle vertex
  9493. * @param vertex2 triangle vertex
  9494. * @returns intersection information if hit
  9495. */
  9496. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9497. /**
  9498. * Checks if ray intersects a plane
  9499. * @param plane the plane to check
  9500. * @returns the distance away it was hit
  9501. */
  9502. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9503. /**
  9504. * Calculate the intercept of a ray on a given axis
  9505. * @param axis to check 'x' | 'y' | 'z'
  9506. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9507. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9508. */
  9509. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9510. /**
  9511. * Checks if ray intersects a mesh
  9512. * @param mesh the mesh to check
  9513. * @param fastCheck if only the bounding box should checked
  9514. * @returns picking info of the intersecton
  9515. */
  9516. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9517. /**
  9518. * Checks if ray intersects a mesh
  9519. * @param meshes the meshes to check
  9520. * @param fastCheck if only the bounding box should checked
  9521. * @param results array to store result in
  9522. * @returns Array of picking infos
  9523. */
  9524. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9525. private _comparePickingInfo;
  9526. private static smallnum;
  9527. private static rayl;
  9528. /**
  9529. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9530. * @param sega the first point of the segment to test the intersection against
  9531. * @param segb the second point of the segment to test the intersection against
  9532. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9533. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9534. */
  9535. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9536. /**
  9537. * Update the ray from viewport position
  9538. * @param x position
  9539. * @param y y position
  9540. * @param viewportWidth viewport width
  9541. * @param viewportHeight viewport height
  9542. * @param world world matrix
  9543. * @param view view matrix
  9544. * @param projection projection matrix
  9545. * @returns this ray updated
  9546. */
  9547. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9548. /**
  9549. * Creates a ray with origin and direction of 0,0,0
  9550. * @returns the new ray
  9551. */
  9552. static Zero(): Ray;
  9553. /**
  9554. * Creates a new ray from screen space and viewport
  9555. * @param x position
  9556. * @param y y position
  9557. * @param viewportWidth viewport width
  9558. * @param viewportHeight viewport height
  9559. * @param world world matrix
  9560. * @param view view matrix
  9561. * @param projection projection matrix
  9562. * @returns new ray
  9563. */
  9564. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9565. /**
  9566. * 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
  9567. * transformed to the given world matrix.
  9568. * @param origin The origin point
  9569. * @param end The end point
  9570. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9571. * @returns the new ray
  9572. */
  9573. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9574. /**
  9575. * Transforms a ray by a matrix
  9576. * @param ray ray to transform
  9577. * @param matrix matrix to apply
  9578. * @returns the resulting new ray
  9579. */
  9580. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9581. /**
  9582. * Transforms a ray by a matrix
  9583. * @param ray ray to transform
  9584. * @param matrix matrix to apply
  9585. * @param result ray to store result in
  9586. */
  9587. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9588. /**
  9589. * Unproject a ray from screen space to object space
  9590. * @param sourceX defines the screen space x coordinate to use
  9591. * @param sourceY defines the screen space y coordinate to use
  9592. * @param viewportWidth defines the current width of the viewport
  9593. * @param viewportHeight defines the current height of the viewport
  9594. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9595. * @param view defines the view matrix to use
  9596. * @param projection defines the projection matrix to use
  9597. */
  9598. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9599. }
  9600. /**
  9601. * Type used to define predicate used to select faces when a mesh intersection is detected
  9602. */
  9603. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9604. interface Scene {
  9605. /** @hidden */
  9606. _tempPickingRay: Nullable<Ray>;
  9607. /** @hidden */
  9608. _cachedRayForTransform: Ray;
  9609. /** @hidden */
  9610. _pickWithRayInverseMatrix: Matrix;
  9611. /** @hidden */
  9612. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9613. /** @hidden */
  9614. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9615. }
  9616. }
  9617. declare module BABYLON {
  9618. /**
  9619. * Groups all the scene component constants in one place to ease maintenance.
  9620. * @hidden
  9621. */
  9622. export class SceneComponentConstants {
  9623. static readonly NAME_EFFECTLAYER: string;
  9624. static readonly NAME_LAYER: string;
  9625. static readonly NAME_LENSFLARESYSTEM: string;
  9626. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9627. static readonly NAME_PARTICLESYSTEM: string;
  9628. static readonly NAME_GAMEPAD: string;
  9629. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9630. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9631. static readonly NAME_DEPTHRENDERER: string;
  9632. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9633. static readonly NAME_SPRITE: string;
  9634. static readonly NAME_OUTLINERENDERER: string;
  9635. static readonly NAME_PROCEDURALTEXTURE: string;
  9636. static readonly NAME_SHADOWGENERATOR: string;
  9637. static readonly NAME_OCTREE: string;
  9638. static readonly NAME_PHYSICSENGINE: string;
  9639. static readonly NAME_AUDIO: string;
  9640. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9641. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9642. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9643. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9644. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9645. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9646. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9647. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9648. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9649. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9650. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9651. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9652. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9653. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9654. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9655. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9656. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9657. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9658. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9659. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9660. static readonly STEP_AFTERRENDER_AUDIO: number;
  9661. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9662. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9663. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9664. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9665. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9666. static readonly STEP_POINTERMOVE_SPRITE: number;
  9667. static readonly STEP_POINTERDOWN_SPRITE: number;
  9668. static readonly STEP_POINTERUP_SPRITE: number;
  9669. }
  9670. /**
  9671. * This represents a scene component.
  9672. *
  9673. * This is used to decouple the dependency the scene is having on the different workloads like
  9674. * layers, post processes...
  9675. */
  9676. export interface ISceneComponent {
  9677. /**
  9678. * The name of the component. Each component must have a unique name.
  9679. */
  9680. name: string;
  9681. /**
  9682. * The scene the component belongs to.
  9683. */
  9684. scene: Scene;
  9685. /**
  9686. * Register the component to one instance of a scene.
  9687. */
  9688. register(): void;
  9689. /**
  9690. * Rebuilds the elements related to this component in case of
  9691. * context lost for instance.
  9692. */
  9693. rebuild(): void;
  9694. /**
  9695. * Disposes the component and the associated ressources.
  9696. */
  9697. dispose(): void;
  9698. }
  9699. /**
  9700. * This represents a SERIALIZABLE scene component.
  9701. *
  9702. * This extends Scene Component to add Serialization methods on top.
  9703. */
  9704. export interface ISceneSerializableComponent extends ISceneComponent {
  9705. /**
  9706. * Adds all the elements from the container to the scene
  9707. * @param container the container holding the elements
  9708. */
  9709. addFromContainer(container: AbstractScene): void;
  9710. /**
  9711. * Removes all the elements in the container from the scene
  9712. * @param container contains the elements to remove
  9713. * @param dispose if the removed element should be disposed (default: false)
  9714. */
  9715. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9716. /**
  9717. * Serializes the component data to the specified json object
  9718. * @param serializationObject The object to serialize to
  9719. */
  9720. serialize(serializationObject: any): void;
  9721. }
  9722. /**
  9723. * Strong typing of a Mesh related stage step action
  9724. */
  9725. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9726. /**
  9727. * Strong typing of a Evaluate Sub Mesh related stage step action
  9728. */
  9729. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9730. /**
  9731. * Strong typing of a Active Mesh related stage step action
  9732. */
  9733. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9734. /**
  9735. * Strong typing of a Camera related stage step action
  9736. */
  9737. export type CameraStageAction = (camera: Camera) => void;
  9738. /**
  9739. * Strong typing of a Camera Frame buffer related stage step action
  9740. */
  9741. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9742. /**
  9743. * Strong typing of a Render Target related stage step action
  9744. */
  9745. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9746. /**
  9747. * Strong typing of a RenderingGroup related stage step action
  9748. */
  9749. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9750. /**
  9751. * Strong typing of a Mesh Render related stage step action
  9752. */
  9753. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9754. /**
  9755. * Strong typing of a simple stage step action
  9756. */
  9757. export type SimpleStageAction = () => void;
  9758. /**
  9759. * Strong typing of a render target action.
  9760. */
  9761. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9762. /**
  9763. * Strong typing of a pointer move action.
  9764. */
  9765. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9766. /**
  9767. * Strong typing of a pointer up/down action.
  9768. */
  9769. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9770. /**
  9771. * Representation of a stage in the scene (Basically a list of ordered steps)
  9772. * @hidden
  9773. */
  9774. export class Stage<T extends Function> extends Array<{
  9775. index: number;
  9776. component: ISceneComponent;
  9777. action: T;
  9778. }> {
  9779. /**
  9780. * Hide ctor from the rest of the world.
  9781. * @param items The items to add.
  9782. */
  9783. private constructor();
  9784. /**
  9785. * Creates a new Stage.
  9786. * @returns A new instance of a Stage
  9787. */
  9788. static Create<T extends Function>(): Stage<T>;
  9789. /**
  9790. * Registers a step in an ordered way in the targeted stage.
  9791. * @param index Defines the position to register the step in
  9792. * @param component Defines the component attached to the step
  9793. * @param action Defines the action to launch during the step
  9794. */
  9795. registerStep(index: number, component: ISceneComponent, action: T): void;
  9796. /**
  9797. * Clears all the steps from the stage.
  9798. */
  9799. clear(): void;
  9800. }
  9801. }
  9802. declare module BABYLON {
  9803. interface Scene {
  9804. /** @hidden */
  9805. _pointerOverSprite: Nullable<Sprite>;
  9806. /** @hidden */
  9807. _pickedDownSprite: Nullable<Sprite>;
  9808. /** @hidden */
  9809. _tempSpritePickingRay: Nullable<Ray>;
  9810. /**
  9811. * All of the sprite managers added to this scene
  9812. * @see http://doc.babylonjs.com/babylon101/sprites
  9813. */
  9814. spriteManagers: Array<ISpriteManager>;
  9815. /**
  9816. * An event triggered when sprites rendering is about to start
  9817. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9818. */
  9819. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9820. /**
  9821. * An event triggered when sprites rendering is done
  9822. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9823. */
  9824. onAfterSpritesRenderingObservable: Observable<Scene>;
  9825. /** @hidden */
  9826. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9827. /** Launch a ray to try to pick a sprite in the scene
  9828. * @param x position on screen
  9829. * @param y position on screen
  9830. * @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
  9831. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9832. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9833. * @returns a PickingInfo
  9834. */
  9835. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9836. /** Use the given ray to pick a sprite in the scene
  9837. * @param ray The ray (in world space) to use to pick meshes
  9838. * @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
  9839. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9840. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9841. * @returns a PickingInfo
  9842. */
  9843. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9844. /** @hidden */
  9845. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9846. /** Launch a ray to try to pick sprites in the scene
  9847. * @param x position on screen
  9848. * @param y position on screen
  9849. * @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
  9850. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9851. * @returns a PickingInfo array
  9852. */
  9853. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9854. /** Use the given ray to pick sprites in the scene
  9855. * @param ray The ray (in world space) to use to pick meshes
  9856. * @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
  9857. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9858. * @returns a PickingInfo array
  9859. */
  9860. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9861. /**
  9862. * Force the sprite under the pointer
  9863. * @param sprite defines the sprite to use
  9864. */
  9865. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  9866. /**
  9867. * Gets the sprite under the pointer
  9868. * @returns a Sprite or null if no sprite is under the pointer
  9869. */
  9870. getPointerOverSprite(): Nullable<Sprite>;
  9871. }
  9872. /**
  9873. * Defines the sprite scene component responsible to manage sprites
  9874. * in a given scene.
  9875. */
  9876. export class SpriteSceneComponent implements ISceneComponent {
  9877. /**
  9878. * The component name helpfull to identify the component in the list of scene components.
  9879. */
  9880. readonly name: string;
  9881. /**
  9882. * The scene the component belongs to.
  9883. */
  9884. scene: Scene;
  9885. /** @hidden */
  9886. private _spritePredicate;
  9887. /**
  9888. * Creates a new instance of the component for the given scene
  9889. * @param scene Defines the scene to register the component in
  9890. */
  9891. constructor(scene: Scene);
  9892. /**
  9893. * Registers the component in a given scene
  9894. */
  9895. register(): void;
  9896. /**
  9897. * Rebuilds the elements related to this component in case of
  9898. * context lost for instance.
  9899. */
  9900. rebuild(): void;
  9901. /**
  9902. * Disposes the component and the associated ressources.
  9903. */
  9904. dispose(): void;
  9905. private _pickSpriteButKeepRay;
  9906. private _pointerMove;
  9907. private _pointerDown;
  9908. private _pointerUp;
  9909. }
  9910. }
  9911. declare module BABYLON {
  9912. /** @hidden */
  9913. export var fogFragmentDeclaration: {
  9914. name: string;
  9915. shader: string;
  9916. };
  9917. }
  9918. declare module BABYLON {
  9919. /** @hidden */
  9920. export var fogFragment: {
  9921. name: string;
  9922. shader: string;
  9923. };
  9924. }
  9925. declare module BABYLON {
  9926. /** @hidden */
  9927. export var spritesPixelShader: {
  9928. name: string;
  9929. shader: string;
  9930. };
  9931. }
  9932. declare module BABYLON {
  9933. /** @hidden */
  9934. export var fogVertexDeclaration: {
  9935. name: string;
  9936. shader: string;
  9937. };
  9938. }
  9939. declare module BABYLON {
  9940. /** @hidden */
  9941. export var spritesVertexShader: {
  9942. name: string;
  9943. shader: string;
  9944. };
  9945. }
  9946. declare module BABYLON {
  9947. /**
  9948. * Defines the minimum interface to fullfil in order to be a sprite manager.
  9949. */
  9950. export interface ISpriteManager extends IDisposable {
  9951. /**
  9952. * Restricts the camera to viewing objects with the same layerMask.
  9953. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  9954. */
  9955. layerMask: number;
  9956. /**
  9957. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  9958. */
  9959. isPickable: boolean;
  9960. /**
  9961. * Specifies the rendering group id for this mesh (0 by default)
  9962. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  9963. */
  9964. renderingGroupId: number;
  9965. /**
  9966. * Defines the list of sprites managed by the manager.
  9967. */
  9968. sprites: Array<Sprite>;
  9969. /**
  9970. * Tests the intersection of a sprite with a specific ray.
  9971. * @param ray The ray we are sending to test the collision
  9972. * @param camera The camera space we are sending rays in
  9973. * @param predicate A predicate allowing excluding sprites from the list of object to test
  9974. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  9975. * @returns picking info or null.
  9976. */
  9977. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  9978. /**
  9979. * Intersects the sprites with a ray
  9980. * @param ray defines the ray to intersect with
  9981. * @param camera defines the current active camera
  9982. * @param predicate defines a predicate used to select candidate sprites
  9983. * @returns null if no hit or a PickingInfo array
  9984. */
  9985. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  9986. /**
  9987. * Renders the list of sprites on screen.
  9988. */
  9989. render(): void;
  9990. }
  9991. /**
  9992. * Class used to manage multiple sprites on the same spritesheet
  9993. * @see http://doc.babylonjs.com/babylon101/sprites
  9994. */
  9995. export class SpriteManager implements ISpriteManager {
  9996. /** defines the manager's name */
  9997. name: string;
  9998. /** Gets the list of sprites */
  9999. sprites: Sprite[];
  10000. /** Gets or sets the rendering group id (0 by default) */
  10001. renderingGroupId: number;
  10002. /** Gets or sets camera layer mask */
  10003. layerMask: number;
  10004. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10005. fogEnabled: boolean;
  10006. /** Gets or sets a boolean indicating if the sprites are pickable */
  10007. isPickable: boolean;
  10008. /** Defines the default width of a cell in the spritesheet */
  10009. cellWidth: number;
  10010. /** Defines the default height of a cell in the spritesheet */
  10011. cellHeight: number;
  10012. /** Associative array from JSON sprite data file */
  10013. private _cellData;
  10014. /** Array of sprite names from JSON sprite data file */
  10015. private _spriteMap;
  10016. /** True when packed cell data from JSON file is ready*/
  10017. private _packedAndReady;
  10018. /**
  10019. * An event triggered when the manager is disposed.
  10020. */
  10021. onDisposeObservable: Observable<SpriteManager>;
  10022. private _onDisposeObserver;
  10023. /**
  10024. * Callback called when the manager is disposed
  10025. */
  10026. set onDispose(callback: () => void);
  10027. private _capacity;
  10028. private _fromPacked;
  10029. private _spriteTexture;
  10030. private _epsilon;
  10031. private _scene;
  10032. private _vertexData;
  10033. private _buffer;
  10034. private _vertexBuffers;
  10035. private _indexBuffer;
  10036. private _effectBase;
  10037. private _effectFog;
  10038. /**
  10039. * Gets or sets the spritesheet texture
  10040. */
  10041. get texture(): Texture;
  10042. set texture(value: Texture);
  10043. private _blendMode;
  10044. /**
  10045. * Blend mode use to render the particle, it can be any of
  10046. * the static Constants.ALPHA_x properties provided in this class.
  10047. * Default value is Constants.ALPHA_COMBINE
  10048. */
  10049. get blendMode(): number;
  10050. set blendMode(blendMode: number);
  10051. /** Disables writing to the depth buffer when rendering the sprites.
  10052. * It can be handy to disable depth writing when using textures without alpha channel
  10053. * and setting some specific blend modes.
  10054. */
  10055. disableDepthWrite: boolean;
  10056. /**
  10057. * Creates a new sprite manager
  10058. * @param name defines the manager's name
  10059. * @param imgUrl defines the sprite sheet url
  10060. * @param capacity defines the maximum allowed number of sprites
  10061. * @param cellSize defines the size of a sprite cell
  10062. * @param scene defines the hosting scene
  10063. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10064. * @param samplingMode defines the smapling mode to use with spritesheet
  10065. * @param fromPacked set to false; do not alter
  10066. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10067. */
  10068. constructor(
  10069. /** defines the manager's name */
  10070. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10071. private _makePacked;
  10072. private _appendSpriteVertex;
  10073. /**
  10074. * Intersects the sprites with a ray
  10075. * @param ray defines the ray to intersect with
  10076. * @param camera defines the current active camera
  10077. * @param predicate defines a predicate used to select candidate sprites
  10078. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10079. * @returns null if no hit or a PickingInfo
  10080. */
  10081. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10082. /**
  10083. * Intersects the sprites with a ray
  10084. * @param ray defines the ray to intersect with
  10085. * @param camera defines the current active camera
  10086. * @param predicate defines a predicate used to select candidate sprites
  10087. * @returns null if no hit or a PickingInfo array
  10088. */
  10089. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10090. /**
  10091. * Render all child sprites
  10092. */
  10093. render(): void;
  10094. /**
  10095. * Release associated resources
  10096. */
  10097. dispose(): void;
  10098. }
  10099. }
  10100. declare module BABYLON {
  10101. /** Interface used by value gradients (color, factor, ...) */
  10102. export interface IValueGradient {
  10103. /**
  10104. * Gets or sets the gradient value (between 0 and 1)
  10105. */
  10106. gradient: number;
  10107. }
  10108. /** Class used to store color4 gradient */
  10109. export class ColorGradient implements IValueGradient {
  10110. /**
  10111. * Gets or sets the gradient value (between 0 and 1)
  10112. */
  10113. gradient: number;
  10114. /**
  10115. * Gets or sets first associated color
  10116. */
  10117. color1: Color4;
  10118. /**
  10119. * Gets or sets second associated color
  10120. */
  10121. color2?: Color4 | undefined;
  10122. /**
  10123. * Creates a new color4 gradient
  10124. * @param gradient gets or sets the gradient value (between 0 and 1)
  10125. * @param color1 gets or sets first associated color
  10126. * @param color2 gets or sets first second color
  10127. */
  10128. constructor(
  10129. /**
  10130. * Gets or sets the gradient value (between 0 and 1)
  10131. */
  10132. gradient: number,
  10133. /**
  10134. * Gets or sets first associated color
  10135. */
  10136. color1: Color4,
  10137. /**
  10138. * Gets or sets second associated color
  10139. */
  10140. color2?: Color4 | undefined);
  10141. /**
  10142. * Will get a color picked randomly between color1 and color2.
  10143. * If color2 is undefined then color1 will be used
  10144. * @param result defines the target Color4 to store the result in
  10145. */
  10146. getColorToRef(result: Color4): void;
  10147. }
  10148. /** Class used to store color 3 gradient */
  10149. export class Color3Gradient implements IValueGradient {
  10150. /**
  10151. * Gets or sets the gradient value (between 0 and 1)
  10152. */
  10153. gradient: number;
  10154. /**
  10155. * Gets or sets the associated color
  10156. */
  10157. color: Color3;
  10158. /**
  10159. * Creates a new color3 gradient
  10160. * @param gradient gets or sets the gradient value (between 0 and 1)
  10161. * @param color gets or sets associated color
  10162. */
  10163. constructor(
  10164. /**
  10165. * Gets or sets the gradient value (between 0 and 1)
  10166. */
  10167. gradient: number,
  10168. /**
  10169. * Gets or sets the associated color
  10170. */
  10171. color: Color3);
  10172. }
  10173. /** Class used to store factor gradient */
  10174. export class FactorGradient implements IValueGradient {
  10175. /**
  10176. * Gets or sets the gradient value (between 0 and 1)
  10177. */
  10178. gradient: number;
  10179. /**
  10180. * Gets or sets first associated factor
  10181. */
  10182. factor1: number;
  10183. /**
  10184. * Gets or sets second associated factor
  10185. */
  10186. factor2?: number | undefined;
  10187. /**
  10188. * Creates a new factor gradient
  10189. * @param gradient gets or sets the gradient value (between 0 and 1)
  10190. * @param factor1 gets or sets first associated factor
  10191. * @param factor2 gets or sets second associated factor
  10192. */
  10193. constructor(
  10194. /**
  10195. * Gets or sets the gradient value (between 0 and 1)
  10196. */
  10197. gradient: number,
  10198. /**
  10199. * Gets or sets first associated factor
  10200. */
  10201. factor1: number,
  10202. /**
  10203. * Gets or sets second associated factor
  10204. */
  10205. factor2?: number | undefined);
  10206. /**
  10207. * Will get a number picked randomly between factor1 and factor2.
  10208. * If factor2 is undefined then factor1 will be used
  10209. * @returns the picked number
  10210. */
  10211. getFactor(): number;
  10212. }
  10213. /**
  10214. * Helper used to simplify some generic gradient tasks
  10215. */
  10216. export class GradientHelper {
  10217. /**
  10218. * Gets the current gradient from an array of IValueGradient
  10219. * @param ratio defines the current ratio to get
  10220. * @param gradients defines the array of IValueGradient
  10221. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10222. */
  10223. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10224. }
  10225. }
  10226. declare module BABYLON {
  10227. /**
  10228. * Interface for the size containing width and height
  10229. */
  10230. export interface ISize {
  10231. /**
  10232. * Width
  10233. */
  10234. width: number;
  10235. /**
  10236. * Heighht
  10237. */
  10238. height: number;
  10239. }
  10240. /**
  10241. * Size containing widht and height
  10242. */
  10243. export class Size implements ISize {
  10244. /**
  10245. * Width
  10246. */
  10247. width: number;
  10248. /**
  10249. * Height
  10250. */
  10251. height: number;
  10252. /**
  10253. * Creates a Size object from the given width and height (floats).
  10254. * @param width width of the new size
  10255. * @param height height of the new size
  10256. */
  10257. constructor(width: number, height: number);
  10258. /**
  10259. * Returns a string with the Size width and height
  10260. * @returns a string with the Size width and height
  10261. */
  10262. toString(): string;
  10263. /**
  10264. * "Size"
  10265. * @returns the string "Size"
  10266. */
  10267. getClassName(): string;
  10268. /**
  10269. * Returns the Size hash code.
  10270. * @returns a hash code for a unique width and height
  10271. */
  10272. getHashCode(): number;
  10273. /**
  10274. * Updates the current size from the given one.
  10275. * @param src the given size
  10276. */
  10277. copyFrom(src: Size): void;
  10278. /**
  10279. * Updates in place the current Size from the given floats.
  10280. * @param width width of the new size
  10281. * @param height height of the new size
  10282. * @returns the updated Size.
  10283. */
  10284. copyFromFloats(width: number, height: number): Size;
  10285. /**
  10286. * Updates in place the current Size from the given floats.
  10287. * @param width width to set
  10288. * @param height height to set
  10289. * @returns the updated Size.
  10290. */
  10291. set(width: number, height: number): Size;
  10292. /**
  10293. * Multiplies the width and height by numbers
  10294. * @param w factor to multiple the width by
  10295. * @param h factor to multiple the height by
  10296. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10297. */
  10298. multiplyByFloats(w: number, h: number): Size;
  10299. /**
  10300. * Clones the size
  10301. * @returns a new Size copied from the given one.
  10302. */
  10303. clone(): Size;
  10304. /**
  10305. * True if the current Size and the given one width and height are strictly equal.
  10306. * @param other the other size to compare against
  10307. * @returns True if the current Size and the given one width and height are strictly equal.
  10308. */
  10309. equals(other: Size): boolean;
  10310. /**
  10311. * The surface of the Size : width * height (float).
  10312. */
  10313. get surface(): number;
  10314. /**
  10315. * Create a new size of zero
  10316. * @returns a new Size set to (0.0, 0.0)
  10317. */
  10318. static Zero(): Size;
  10319. /**
  10320. * Sums the width and height of two sizes
  10321. * @param otherSize size to add to this size
  10322. * @returns a new Size set as the addition result of the current Size and the given one.
  10323. */
  10324. add(otherSize: Size): Size;
  10325. /**
  10326. * Subtracts the width and height of two
  10327. * @param otherSize size to subtract to this size
  10328. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10329. */
  10330. subtract(otherSize: Size): Size;
  10331. /**
  10332. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10333. * @param start starting size to lerp between
  10334. * @param end end size to lerp between
  10335. * @param amount amount to lerp between the start and end values
  10336. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10337. */
  10338. static Lerp(start: Size, end: Size, amount: number): Size;
  10339. }
  10340. }
  10341. declare module BABYLON {
  10342. interface ThinEngine {
  10343. /**
  10344. * Creates a dynamic texture
  10345. * @param width defines the width of the texture
  10346. * @param height defines the height of the texture
  10347. * @param generateMipMaps defines if the engine should generate the mip levels
  10348. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10349. * @returns the dynamic texture inside an InternalTexture
  10350. */
  10351. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10352. /**
  10353. * Update the content of a dynamic texture
  10354. * @param texture defines the texture to update
  10355. * @param canvas defines the canvas containing the source
  10356. * @param invertY defines if data must be stored with Y axis inverted
  10357. * @param premulAlpha defines if alpha is stored as premultiplied
  10358. * @param format defines the format of the data
  10359. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10360. */
  10361. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10362. }
  10363. }
  10364. declare module BABYLON {
  10365. /**
  10366. * Helper class used to generate a canvas to manipulate images
  10367. */
  10368. export class CanvasGenerator {
  10369. /**
  10370. * Create a new canvas (or offscreen canvas depending on the context)
  10371. * @param width defines the expected width
  10372. * @param height defines the expected height
  10373. * @return a new canvas or offscreen canvas
  10374. */
  10375. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10376. }
  10377. }
  10378. declare module BABYLON {
  10379. /**
  10380. * A class extending Texture allowing drawing on a texture
  10381. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10382. */
  10383. export class DynamicTexture extends Texture {
  10384. private _generateMipMaps;
  10385. private _canvas;
  10386. private _context;
  10387. private _engine;
  10388. /**
  10389. * Creates a DynamicTexture
  10390. * @param name defines the name of the texture
  10391. * @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
  10392. * @param scene defines the scene where you want the texture
  10393. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10394. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10395. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10396. */
  10397. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10398. /**
  10399. * Get the current class name of the texture useful for serialization or dynamic coding.
  10400. * @returns "DynamicTexture"
  10401. */
  10402. getClassName(): string;
  10403. /**
  10404. * Gets the current state of canRescale
  10405. */
  10406. get canRescale(): boolean;
  10407. private _recreate;
  10408. /**
  10409. * Scales the texture
  10410. * @param ratio the scale factor to apply to both width and height
  10411. */
  10412. scale(ratio: number): void;
  10413. /**
  10414. * Resizes the texture
  10415. * @param width the new width
  10416. * @param height the new height
  10417. */
  10418. scaleTo(width: number, height: number): void;
  10419. /**
  10420. * Gets the context of the canvas used by the texture
  10421. * @returns the canvas context of the dynamic texture
  10422. */
  10423. getContext(): CanvasRenderingContext2D;
  10424. /**
  10425. * Clears the texture
  10426. */
  10427. clear(): void;
  10428. /**
  10429. * Updates the texture
  10430. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10431. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10432. */
  10433. update(invertY?: boolean, premulAlpha?: boolean): void;
  10434. /**
  10435. * Draws text onto the texture
  10436. * @param text defines the text to be drawn
  10437. * @param x defines the placement of the text from the left
  10438. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10439. * @param font defines the font to be used with font-style, font-size, font-name
  10440. * @param color defines the color used for the text
  10441. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10442. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10443. * @param update defines whether texture is immediately update (default is true)
  10444. */
  10445. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  10446. /**
  10447. * Clones the texture
  10448. * @returns the clone of the texture.
  10449. */
  10450. clone(): DynamicTexture;
  10451. /**
  10452. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10453. * @returns a serialized dynamic texture object
  10454. */
  10455. serialize(): any;
  10456. /** @hidden */
  10457. _rebuild(): void;
  10458. }
  10459. }
  10460. declare module BABYLON {
  10461. interface Engine {
  10462. /**
  10463. * Creates a raw texture
  10464. * @param data defines the data to store in the texture
  10465. * @param width defines the width of the texture
  10466. * @param height defines the height of the texture
  10467. * @param format defines the format of the data
  10468. * @param generateMipMaps defines if the engine should generate the mip levels
  10469. * @param invertY defines if data must be stored with Y axis inverted
  10470. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10471. * @param compression defines the compression used (null by default)
  10472. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10473. * @returns the raw texture inside an InternalTexture
  10474. */
  10475. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10476. /**
  10477. * Update a raw texture
  10478. * @param texture defines the texture to update
  10479. * @param data defines the data to store in the texture
  10480. * @param format defines the format of the data
  10481. * @param invertY defines if data must be stored with Y axis inverted
  10482. */
  10483. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10484. /**
  10485. * Update a raw texture
  10486. * @param texture defines the texture to update
  10487. * @param data defines the data to store in the texture
  10488. * @param format defines the format of the data
  10489. * @param invertY defines if data must be stored with Y axis inverted
  10490. * @param compression defines the compression used (null by default)
  10491. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10492. */
  10493. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10494. /**
  10495. * Creates a new raw cube texture
  10496. * @param data defines the array of data to use to create each face
  10497. * @param size defines the size of the textures
  10498. * @param format defines the format of the data
  10499. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10500. * @param generateMipMaps defines if the engine should generate the mip levels
  10501. * @param invertY defines if data must be stored with Y axis inverted
  10502. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10503. * @param compression defines the compression used (null by default)
  10504. * @returns the cube texture as an InternalTexture
  10505. */
  10506. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10507. /**
  10508. * Update a raw cube texture
  10509. * @param texture defines the texture to udpdate
  10510. * @param data defines the data to store
  10511. * @param format defines the data format
  10512. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10513. * @param invertY defines if data must be stored with Y axis inverted
  10514. */
  10515. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10516. /**
  10517. * Update a raw cube texture
  10518. * @param texture defines the texture to udpdate
  10519. * @param data defines the data to store
  10520. * @param format defines the data format
  10521. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10522. * @param invertY defines if data must be stored with Y axis inverted
  10523. * @param compression defines the compression used (null by default)
  10524. */
  10525. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10526. /**
  10527. * Update a raw cube texture
  10528. * @param texture defines the texture to udpdate
  10529. * @param data defines the data to store
  10530. * @param format defines the data format
  10531. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10532. * @param invertY defines if data must be stored with Y axis inverted
  10533. * @param compression defines the compression used (null by default)
  10534. * @param level defines which level of the texture to update
  10535. */
  10536. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10537. /**
  10538. * Creates a new raw cube texture from a specified url
  10539. * @param url defines the url where the data is located
  10540. * @param scene defines the current scene
  10541. * @param size defines the size of the textures
  10542. * @param format defines the format of the data
  10543. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10544. * @param noMipmap defines if the engine should avoid generating the mip levels
  10545. * @param callback defines a callback used to extract texture data from loaded data
  10546. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10547. * @param onLoad defines a callback called when texture is loaded
  10548. * @param onError defines a callback called if there is an error
  10549. * @returns the cube texture as an InternalTexture
  10550. */
  10551. 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;
  10552. /**
  10553. * Creates a new raw cube texture from a specified url
  10554. * @param url defines the url where the data is located
  10555. * @param scene defines the current scene
  10556. * @param size defines the size of the textures
  10557. * @param format defines the format of the data
  10558. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10559. * @param noMipmap defines if the engine should avoid generating the mip levels
  10560. * @param callback defines a callback used to extract texture data from loaded data
  10561. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10562. * @param onLoad defines a callback called when texture is loaded
  10563. * @param onError defines a callback called if there is an error
  10564. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10565. * @param invertY defines if data must be stored with Y axis inverted
  10566. * @returns the cube texture as an InternalTexture
  10567. */
  10568. 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;
  10569. /**
  10570. * Creates a new raw 3D texture
  10571. * @param data defines the data used to create the texture
  10572. * @param width defines the width of the texture
  10573. * @param height defines the height of the texture
  10574. * @param depth defines the depth of the texture
  10575. * @param format defines the format of the texture
  10576. * @param generateMipMaps defines if the engine must generate mip levels
  10577. * @param invertY defines if data must be stored with Y axis inverted
  10578. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10579. * @param compression defines the compressed used (can be null)
  10580. * @param textureType defines the compressed used (can be null)
  10581. * @returns a new raw 3D texture (stored in an InternalTexture)
  10582. */
  10583. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10584. /**
  10585. * Update a raw 3D texture
  10586. * @param texture defines the texture to update
  10587. * @param data defines the data to store
  10588. * @param format defines the data format
  10589. * @param invertY defines if data must be stored with Y axis inverted
  10590. */
  10591. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10592. /**
  10593. * Update a raw 3D texture
  10594. * @param texture defines the texture to update
  10595. * @param data defines the data to store
  10596. * @param format defines the data format
  10597. * @param invertY defines if data must be stored with Y axis inverted
  10598. * @param compression defines the used compression (can be null)
  10599. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10600. */
  10601. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10602. /**
  10603. * Creates a new raw 2D array texture
  10604. * @param data defines the data used to create the texture
  10605. * @param width defines the width of the texture
  10606. * @param height defines the height of the texture
  10607. * @param depth defines the number of layers of the texture
  10608. * @param format defines the format of the texture
  10609. * @param generateMipMaps defines if the engine must generate mip levels
  10610. * @param invertY defines if data must be stored with Y axis inverted
  10611. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10612. * @param compression defines the compressed used (can be null)
  10613. * @param textureType defines the compressed used (can be null)
  10614. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10615. */
  10616. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10617. /**
  10618. * Update a raw 2D array texture
  10619. * @param texture defines the texture to update
  10620. * @param data defines the data to store
  10621. * @param format defines the data format
  10622. * @param invertY defines if data must be stored with Y axis inverted
  10623. */
  10624. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10625. /**
  10626. * Update a raw 2D array texture
  10627. * @param texture defines the texture to update
  10628. * @param data defines the data to store
  10629. * @param format defines the data format
  10630. * @param invertY defines if data must be stored with Y axis inverted
  10631. * @param compression defines the used compression (can be null)
  10632. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10633. */
  10634. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10635. }
  10636. }
  10637. declare module BABYLON {
  10638. /**
  10639. * Raw texture can help creating a texture directly from an array of data.
  10640. * This can be super useful if you either get the data from an uncompressed source or
  10641. * if you wish to create your texture pixel by pixel.
  10642. */
  10643. export class RawTexture extends Texture {
  10644. /**
  10645. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10646. */
  10647. format: number;
  10648. private _engine;
  10649. /**
  10650. * Instantiates a new RawTexture.
  10651. * Raw texture can help creating a texture directly from an array of data.
  10652. * This can be super useful if you either get the data from an uncompressed source or
  10653. * if you wish to create your texture pixel by pixel.
  10654. * @param data define the array of data to use to create the texture
  10655. * @param width define the width of the texture
  10656. * @param height define the height of the texture
  10657. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10658. * @param scene define the scene the texture belongs to
  10659. * @param generateMipMaps define whether mip maps should be generated or not
  10660. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10661. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10662. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10663. */
  10664. constructor(data: ArrayBufferView, width: number, height: number,
  10665. /**
  10666. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10667. */
  10668. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10669. /**
  10670. * Updates the texture underlying data.
  10671. * @param data Define the new data of the texture
  10672. */
  10673. update(data: ArrayBufferView): void;
  10674. /**
  10675. * Creates a luminance texture from some data.
  10676. * @param data Define the texture data
  10677. * @param width Define the width of the texture
  10678. * @param height Define the height of the texture
  10679. * @param scene Define the scene the texture belongs to
  10680. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10681. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10682. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10683. * @returns the luminance texture
  10684. */
  10685. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10686. /**
  10687. * Creates a luminance alpha texture from some data.
  10688. * @param data Define the texture data
  10689. * @param width Define the width of the texture
  10690. * @param height Define the height of the texture
  10691. * @param scene Define the scene the texture belongs to
  10692. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10693. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10694. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10695. * @returns the luminance alpha texture
  10696. */
  10697. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10698. /**
  10699. * Creates an alpha texture from some data.
  10700. * @param data Define the texture data
  10701. * @param width Define the width of the texture
  10702. * @param height Define the height of the texture
  10703. * @param scene Define the scene the texture belongs to
  10704. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10705. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10706. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10707. * @returns the alpha texture
  10708. */
  10709. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10710. /**
  10711. * Creates a RGB texture from some data.
  10712. * @param data Define the texture data
  10713. * @param width Define the width of the texture
  10714. * @param height Define the height of the texture
  10715. * @param scene Define the scene the texture belongs to
  10716. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10717. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10718. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10719. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10720. * @returns the RGB alpha texture
  10721. */
  10722. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10723. /**
  10724. * Creates a RGBA texture from some data.
  10725. * @param data Define the texture data
  10726. * @param width Define the width of the texture
  10727. * @param height Define the height of the texture
  10728. * @param scene Define the scene the texture belongs to
  10729. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10730. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10731. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10732. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10733. * @returns the RGBA texture
  10734. */
  10735. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10736. /**
  10737. * Creates a R 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. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10746. * @returns the R texture
  10747. */
  10748. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10749. }
  10750. }
  10751. declare module BABYLON {
  10752. interface AbstractScene {
  10753. /**
  10754. * The list of procedural textures added to the scene
  10755. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10756. */
  10757. proceduralTextures: Array<ProceduralTexture>;
  10758. }
  10759. /**
  10760. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10761. * in a given scene.
  10762. */
  10763. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10764. /**
  10765. * The component name helpfull to identify the component in the list of scene components.
  10766. */
  10767. readonly name: string;
  10768. /**
  10769. * The scene the component belongs to.
  10770. */
  10771. scene: Scene;
  10772. /**
  10773. * Creates a new instance of the component for the given scene
  10774. * @param scene Defines the scene to register the component in
  10775. */
  10776. constructor(scene: Scene);
  10777. /**
  10778. * Registers the component in a given scene
  10779. */
  10780. register(): void;
  10781. /**
  10782. * Rebuilds the elements related to this component in case of
  10783. * context lost for instance.
  10784. */
  10785. rebuild(): void;
  10786. /**
  10787. * Disposes the component and the associated ressources.
  10788. */
  10789. dispose(): void;
  10790. private _beforeClear;
  10791. }
  10792. }
  10793. declare module BABYLON {
  10794. interface ThinEngine {
  10795. /**
  10796. * Creates a new render target cube texture
  10797. * @param size defines the size of the texture
  10798. * @param options defines the options used to create the texture
  10799. * @returns a new render target cube texture stored in an InternalTexture
  10800. */
  10801. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10802. }
  10803. }
  10804. declare module BABYLON {
  10805. /** @hidden */
  10806. export var proceduralVertexShader: {
  10807. name: string;
  10808. shader: string;
  10809. };
  10810. }
  10811. declare module BABYLON {
  10812. /**
  10813. * 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.
  10814. * This is the base class of any Procedural texture and contains most of the shareable code.
  10815. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10816. */
  10817. export class ProceduralTexture extends Texture {
  10818. isCube: boolean;
  10819. /**
  10820. * Define if the texture is enabled or not (disabled texture will not render)
  10821. */
  10822. isEnabled: boolean;
  10823. /**
  10824. * Define if the texture must be cleared before rendering (default is true)
  10825. */
  10826. autoClear: boolean;
  10827. /**
  10828. * Callback called when the texture is generated
  10829. */
  10830. onGenerated: () => void;
  10831. /**
  10832. * Event raised when the texture is generated
  10833. */
  10834. onGeneratedObservable: Observable<ProceduralTexture>;
  10835. /** @hidden */
  10836. _generateMipMaps: boolean;
  10837. /** @hidden **/
  10838. _effect: Effect;
  10839. /** @hidden */
  10840. _textures: {
  10841. [key: string]: Texture;
  10842. };
  10843. private _size;
  10844. private _currentRefreshId;
  10845. private _frameId;
  10846. private _refreshRate;
  10847. private _vertexBuffers;
  10848. private _indexBuffer;
  10849. private _uniforms;
  10850. private _samplers;
  10851. private _fragment;
  10852. private _floats;
  10853. private _ints;
  10854. private _floatsArrays;
  10855. private _colors3;
  10856. private _colors4;
  10857. private _vectors2;
  10858. private _vectors3;
  10859. private _matrices;
  10860. private _fallbackTexture;
  10861. private _fallbackTextureUsed;
  10862. private _engine;
  10863. private _cachedDefines;
  10864. private _contentUpdateId;
  10865. private _contentData;
  10866. /**
  10867. * Instantiates a new procedural texture.
  10868. * 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.
  10869. * This is the base class of any Procedural texture and contains most of the shareable code.
  10870. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10871. * @param name Define the name of the texture
  10872. * @param size Define the size of the texture to create
  10873. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  10874. * @param scene Define the scene the texture belongs to
  10875. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  10876. * @param generateMipMaps Define if the texture should creates mip maps or not
  10877. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  10878. */
  10879. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  10880. /**
  10881. * The effect that is created when initializing the post process.
  10882. * @returns The created effect corresponding the the postprocess.
  10883. */
  10884. getEffect(): Effect;
  10885. /**
  10886. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  10887. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  10888. */
  10889. getContent(): Nullable<ArrayBufferView>;
  10890. private _createIndexBuffer;
  10891. /** @hidden */
  10892. _rebuild(): void;
  10893. /**
  10894. * Resets the texture in order to recreate its associated resources.
  10895. * This can be called in case of context loss
  10896. */
  10897. reset(): void;
  10898. protected _getDefines(): string;
  10899. /**
  10900. * Is the texture ready to be used ? (rendered at least once)
  10901. * @returns true if ready, otherwise, false.
  10902. */
  10903. isReady(): boolean;
  10904. /**
  10905. * Resets the refresh counter of the texture and start bak from scratch.
  10906. * Could be useful to regenerate the texture if it is setup to render only once.
  10907. */
  10908. resetRefreshCounter(): void;
  10909. /**
  10910. * Set the fragment shader to use in order to render the texture.
  10911. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  10912. */
  10913. setFragment(fragment: any): void;
  10914. /**
  10915. * Define the refresh rate of the texture or the rendering frequency.
  10916. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  10917. */
  10918. get refreshRate(): number;
  10919. set refreshRate(value: number);
  10920. /** @hidden */
  10921. _shouldRender(): boolean;
  10922. /**
  10923. * Get the size the texture is rendering at.
  10924. * @returns the size (texture is always squared)
  10925. */
  10926. getRenderSize(): number;
  10927. /**
  10928. * Resize the texture to new value.
  10929. * @param size Define the new size the texture should have
  10930. * @param generateMipMaps Define whether the new texture should create mip maps
  10931. */
  10932. resize(size: number, generateMipMaps: boolean): void;
  10933. private _checkUniform;
  10934. /**
  10935. * Set a texture in the shader program used to render.
  10936. * @param name Define the name of the uniform samplers as defined in the shader
  10937. * @param texture Define the texture to bind to this sampler
  10938. * @return the texture itself allowing "fluent" like uniform updates
  10939. */
  10940. setTexture(name: string, texture: Texture): ProceduralTexture;
  10941. /**
  10942. * Set a float in the shader.
  10943. * @param name Define the name of the uniform as defined in the shader
  10944. * @param value Define the value to give to the uniform
  10945. * @return the texture itself allowing "fluent" like uniform updates
  10946. */
  10947. setFloat(name: string, value: number): ProceduralTexture;
  10948. /**
  10949. * Set a int in the shader.
  10950. * @param name Define the name of the uniform as defined in the shader
  10951. * @param value Define the value to give to the uniform
  10952. * @return the texture itself allowing "fluent" like uniform updates
  10953. */
  10954. setInt(name: string, value: number): ProceduralTexture;
  10955. /**
  10956. * Set an array of floats in the shader.
  10957. * @param name Define the name of the uniform as defined in the shader
  10958. * @param value Define the value to give to the uniform
  10959. * @return the texture itself allowing "fluent" like uniform updates
  10960. */
  10961. setFloats(name: string, value: number[]): ProceduralTexture;
  10962. /**
  10963. * Set a vec3 in the shader from a Color3.
  10964. * @param name Define the name of the uniform as defined in the shader
  10965. * @param value Define the value to give to the uniform
  10966. * @return the texture itself allowing "fluent" like uniform updates
  10967. */
  10968. setColor3(name: string, value: Color3): ProceduralTexture;
  10969. /**
  10970. * Set a vec4 in the shader from a Color4.
  10971. * @param name Define the name of the uniform as defined in the shader
  10972. * @param value Define the value to give to the uniform
  10973. * @return the texture itself allowing "fluent" like uniform updates
  10974. */
  10975. setColor4(name: string, value: Color4): ProceduralTexture;
  10976. /**
  10977. * Set a vec2 in the shader from a Vector2.
  10978. * @param name Define the name of the uniform as defined in the shader
  10979. * @param value Define the value to give to the uniform
  10980. * @return the texture itself allowing "fluent" like uniform updates
  10981. */
  10982. setVector2(name: string, value: Vector2): ProceduralTexture;
  10983. /**
  10984. * Set a vec3 in the shader from a Vector3.
  10985. * @param name Define the name of the uniform as defined in the shader
  10986. * @param value Define the value to give to the uniform
  10987. * @return the texture itself allowing "fluent" like uniform updates
  10988. */
  10989. setVector3(name: string, value: Vector3): ProceduralTexture;
  10990. /**
  10991. * Set a mat4 in the shader from a MAtrix.
  10992. * @param name Define the name of the uniform as defined in the shader
  10993. * @param value Define the value to give to the uniform
  10994. * @return the texture itself allowing "fluent" like uniform updates
  10995. */
  10996. setMatrix(name: string, value: Matrix): ProceduralTexture;
  10997. /**
  10998. * Render the texture to its associated render target.
  10999. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11000. */
  11001. render(useCameraPostProcess?: boolean): void;
  11002. /**
  11003. * Clone the texture.
  11004. * @returns the cloned texture
  11005. */
  11006. clone(): ProceduralTexture;
  11007. /**
  11008. * Dispose the texture and release its asoociated resources.
  11009. */
  11010. dispose(): void;
  11011. }
  11012. }
  11013. declare module BABYLON {
  11014. /**
  11015. * This represents the base class for particle system in Babylon.
  11016. * 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.
  11017. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11018. * @example https://doc.babylonjs.com/babylon101/particles
  11019. */
  11020. export class BaseParticleSystem {
  11021. /**
  11022. * Source color is added to the destination color without alpha affecting the result
  11023. */
  11024. static BLENDMODE_ONEONE: number;
  11025. /**
  11026. * Blend current color and particle color using particle’s alpha
  11027. */
  11028. static BLENDMODE_STANDARD: number;
  11029. /**
  11030. * Add current color and particle color multiplied by particle’s alpha
  11031. */
  11032. static BLENDMODE_ADD: number;
  11033. /**
  11034. * Multiply current color with particle color
  11035. */
  11036. static BLENDMODE_MULTIPLY: number;
  11037. /**
  11038. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11039. */
  11040. static BLENDMODE_MULTIPLYADD: number;
  11041. /**
  11042. * List of animations used by the particle system.
  11043. */
  11044. animations: Animation[];
  11045. /**
  11046. * The id of the Particle system.
  11047. */
  11048. id: string;
  11049. /**
  11050. * The friendly name of the Particle system.
  11051. */
  11052. name: string;
  11053. /**
  11054. * The rendering group used by the Particle system to chose when to render.
  11055. */
  11056. renderingGroupId: number;
  11057. /**
  11058. * The emitter represents the Mesh or position we are attaching the particle system to.
  11059. */
  11060. emitter: Nullable<AbstractMesh | Vector3>;
  11061. /**
  11062. * The maximum number of particles to emit per frame
  11063. */
  11064. emitRate: number;
  11065. /**
  11066. * If you want to launch only a few particles at once, that can be done, as well.
  11067. */
  11068. manualEmitCount: number;
  11069. /**
  11070. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11071. */
  11072. updateSpeed: number;
  11073. /**
  11074. * The amount of time the particle system is running (depends of the overall update speed).
  11075. */
  11076. targetStopDuration: number;
  11077. /**
  11078. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11079. */
  11080. disposeOnStop: boolean;
  11081. /**
  11082. * Minimum power of emitting particles.
  11083. */
  11084. minEmitPower: number;
  11085. /**
  11086. * Maximum power of emitting particles.
  11087. */
  11088. maxEmitPower: number;
  11089. /**
  11090. * Minimum life time of emitting particles.
  11091. */
  11092. minLifeTime: number;
  11093. /**
  11094. * Maximum life time of emitting particles.
  11095. */
  11096. maxLifeTime: number;
  11097. /**
  11098. * Minimum Size of emitting particles.
  11099. */
  11100. minSize: number;
  11101. /**
  11102. * Maximum Size of emitting particles.
  11103. */
  11104. maxSize: number;
  11105. /**
  11106. * Minimum scale of emitting particles on X axis.
  11107. */
  11108. minScaleX: number;
  11109. /**
  11110. * Maximum scale of emitting particles on X axis.
  11111. */
  11112. maxScaleX: number;
  11113. /**
  11114. * Minimum scale of emitting particles on Y axis.
  11115. */
  11116. minScaleY: number;
  11117. /**
  11118. * Maximum scale of emitting particles on Y axis.
  11119. */
  11120. maxScaleY: number;
  11121. /**
  11122. * Gets or sets the minimal initial rotation in radians.
  11123. */
  11124. minInitialRotation: number;
  11125. /**
  11126. * Gets or sets the maximal initial rotation in radians.
  11127. */
  11128. maxInitialRotation: number;
  11129. /**
  11130. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11131. */
  11132. minAngularSpeed: number;
  11133. /**
  11134. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11135. */
  11136. maxAngularSpeed: number;
  11137. /**
  11138. * The texture used to render each particle. (this can be a spritesheet)
  11139. */
  11140. particleTexture: Nullable<Texture>;
  11141. /**
  11142. * The layer mask we are rendering the particles through.
  11143. */
  11144. layerMask: number;
  11145. /**
  11146. * This can help using your own shader to render the particle system.
  11147. * The according effect will be created
  11148. */
  11149. customShader: any;
  11150. /**
  11151. * By default particle system starts as soon as they are created. This prevents the
  11152. * automatic start to happen and let you decide when to start emitting particles.
  11153. */
  11154. preventAutoStart: boolean;
  11155. private _noiseTexture;
  11156. /**
  11157. * Gets or sets a texture used to add random noise to particle positions
  11158. */
  11159. get noiseTexture(): Nullable<ProceduralTexture>;
  11160. set noiseTexture(value: Nullable<ProceduralTexture>);
  11161. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11162. noiseStrength: Vector3;
  11163. /**
  11164. * Callback triggered when the particle animation is ending.
  11165. */
  11166. onAnimationEnd: Nullable<() => void>;
  11167. /**
  11168. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11169. */
  11170. blendMode: number;
  11171. /**
  11172. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11173. * to override the particles.
  11174. */
  11175. forceDepthWrite: boolean;
  11176. /** 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 */
  11177. preWarmCycles: number;
  11178. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11179. preWarmStepOffset: number;
  11180. /**
  11181. * 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)
  11182. */
  11183. spriteCellChangeSpeed: number;
  11184. /**
  11185. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11186. */
  11187. startSpriteCellID: number;
  11188. /**
  11189. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11190. */
  11191. endSpriteCellID: number;
  11192. /**
  11193. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11194. */
  11195. spriteCellWidth: number;
  11196. /**
  11197. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11198. */
  11199. spriteCellHeight: number;
  11200. /**
  11201. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11202. */
  11203. spriteRandomStartCell: boolean;
  11204. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11205. translationPivot: Vector2;
  11206. /** @hidden */
  11207. protected _isAnimationSheetEnabled: boolean;
  11208. /**
  11209. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11210. */
  11211. beginAnimationOnStart: boolean;
  11212. /**
  11213. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11214. */
  11215. beginAnimationFrom: number;
  11216. /**
  11217. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11218. */
  11219. beginAnimationTo: number;
  11220. /**
  11221. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11222. */
  11223. beginAnimationLoop: boolean;
  11224. /**
  11225. * Gets or sets a world offset applied to all particles
  11226. */
  11227. worldOffset: Vector3;
  11228. /**
  11229. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11230. */
  11231. get isAnimationSheetEnabled(): boolean;
  11232. set isAnimationSheetEnabled(value: boolean);
  11233. /**
  11234. * Get hosting scene
  11235. * @returns the scene
  11236. */
  11237. getScene(): Scene;
  11238. /**
  11239. * You can use gravity if you want to give an orientation to your particles.
  11240. */
  11241. gravity: Vector3;
  11242. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11243. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11244. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11245. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11246. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11247. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11248. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11249. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11250. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11251. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11252. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11253. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11254. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11255. /**
  11256. * Defines the delay in milliseconds before starting the system (0 by default)
  11257. */
  11258. startDelay: number;
  11259. /**
  11260. * Gets the current list of drag gradients.
  11261. * You must use addDragGradient and removeDragGradient to udpate this list
  11262. * @returns the list of drag gradients
  11263. */
  11264. getDragGradients(): Nullable<Array<FactorGradient>>;
  11265. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11266. limitVelocityDamping: number;
  11267. /**
  11268. * Gets the current list of limit velocity gradients.
  11269. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11270. * @returns the list of limit velocity gradients
  11271. */
  11272. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11273. /**
  11274. * Gets the current list of color gradients.
  11275. * You must use addColorGradient and removeColorGradient to udpate this list
  11276. * @returns the list of color gradients
  11277. */
  11278. getColorGradients(): Nullable<Array<ColorGradient>>;
  11279. /**
  11280. * Gets the current list of size gradients.
  11281. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11282. * @returns the list of size gradients
  11283. */
  11284. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11285. /**
  11286. * Gets the current list of color remap gradients.
  11287. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11288. * @returns the list of color remap gradients
  11289. */
  11290. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11291. /**
  11292. * Gets the current list of alpha remap gradients.
  11293. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11294. * @returns the list of alpha remap gradients
  11295. */
  11296. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11297. /**
  11298. * Gets the current list of life time gradients.
  11299. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11300. * @returns the list of life time gradients
  11301. */
  11302. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11303. /**
  11304. * Gets the current list of angular speed gradients.
  11305. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11306. * @returns the list of angular speed gradients
  11307. */
  11308. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11309. /**
  11310. * Gets the current list of velocity gradients.
  11311. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11312. * @returns the list of velocity gradients
  11313. */
  11314. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11315. /**
  11316. * Gets the current list of start size gradients.
  11317. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11318. * @returns the list of start size gradients
  11319. */
  11320. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11321. /**
  11322. * Gets the current list of emit rate gradients.
  11323. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11324. * @returns the list of emit rate gradients
  11325. */
  11326. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11327. /**
  11328. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11329. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11330. */
  11331. get direction1(): Vector3;
  11332. set direction1(value: Vector3);
  11333. /**
  11334. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11335. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11336. */
  11337. get direction2(): Vector3;
  11338. set direction2(value: Vector3);
  11339. /**
  11340. * 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.
  11341. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11342. */
  11343. get minEmitBox(): Vector3;
  11344. set minEmitBox(value: Vector3);
  11345. /**
  11346. * 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.
  11347. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11348. */
  11349. get maxEmitBox(): Vector3;
  11350. set maxEmitBox(value: Vector3);
  11351. /**
  11352. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11353. */
  11354. color1: Color4;
  11355. /**
  11356. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11357. */
  11358. color2: Color4;
  11359. /**
  11360. * Color the particle will have at the end of its lifetime
  11361. */
  11362. colorDead: Color4;
  11363. /**
  11364. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11365. */
  11366. textureMask: Color4;
  11367. /**
  11368. * The particle emitter type defines the emitter used by the particle system.
  11369. * It can be for example box, sphere, or cone...
  11370. */
  11371. particleEmitterType: IParticleEmitterType;
  11372. /** @hidden */
  11373. _isSubEmitter: boolean;
  11374. /**
  11375. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11376. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11377. */
  11378. billboardMode: number;
  11379. protected _isBillboardBased: boolean;
  11380. /**
  11381. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11382. */
  11383. get isBillboardBased(): boolean;
  11384. set isBillboardBased(value: boolean);
  11385. /**
  11386. * The scene the particle system belongs to.
  11387. */
  11388. protected _scene: Scene;
  11389. /**
  11390. * Local cache of defines for image processing.
  11391. */
  11392. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11393. /**
  11394. * Default configuration related to image processing available in the standard Material.
  11395. */
  11396. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11397. /**
  11398. * Gets the image processing configuration used either in this material.
  11399. */
  11400. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11401. /**
  11402. * Sets the Default image processing configuration used either in the this material.
  11403. *
  11404. * If sets to null, the scene one is in use.
  11405. */
  11406. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11407. /**
  11408. * Attaches a new image processing configuration to the Standard Material.
  11409. * @param configuration
  11410. */
  11411. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11412. /** @hidden */
  11413. protected _reset(): void;
  11414. /** @hidden */
  11415. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11416. /**
  11417. * Instantiates a particle system.
  11418. * 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.
  11419. * @param name The name of the particle system
  11420. */
  11421. constructor(name: string);
  11422. /**
  11423. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11424. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11425. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11426. * @returns the emitter
  11427. */
  11428. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11429. /**
  11430. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11431. * @param radius The radius of the hemisphere to emit from
  11432. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11433. * @returns the emitter
  11434. */
  11435. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11436. /**
  11437. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11438. * @param radius The radius of the sphere to emit from
  11439. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11440. * @returns the emitter
  11441. */
  11442. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11443. /**
  11444. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11445. * @param radius The radius of the sphere to emit from
  11446. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11447. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11448. * @returns the emitter
  11449. */
  11450. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11451. /**
  11452. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11453. * @param radius The radius of the emission cylinder
  11454. * @param height The height of the emission cylinder
  11455. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11456. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11457. * @returns the emitter
  11458. */
  11459. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11460. /**
  11461. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11462. * @param radius The radius of the cylinder to emit from
  11463. * @param height The height of the emission cylinder
  11464. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11465. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11466. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11467. * @returns the emitter
  11468. */
  11469. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11470. /**
  11471. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11472. * @param radius The radius of the cone to emit from
  11473. * @param angle The base angle of the cone
  11474. * @returns the emitter
  11475. */
  11476. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11477. /**
  11478. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11479. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11480. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11481. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11482. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11483. * @returns the emitter
  11484. */
  11485. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11486. }
  11487. }
  11488. declare module BABYLON {
  11489. /**
  11490. * Type of sub emitter
  11491. */
  11492. export enum SubEmitterType {
  11493. /**
  11494. * Attached to the particle over it's lifetime
  11495. */
  11496. ATTACHED = 0,
  11497. /**
  11498. * Created when the particle dies
  11499. */
  11500. END = 1
  11501. }
  11502. /**
  11503. * Sub emitter class used to emit particles from an existing particle
  11504. */
  11505. export class SubEmitter {
  11506. /**
  11507. * the particle system to be used by the sub emitter
  11508. */
  11509. particleSystem: ParticleSystem;
  11510. /**
  11511. * Type of the submitter (Default: END)
  11512. */
  11513. type: SubEmitterType;
  11514. /**
  11515. * 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)
  11516. * Note: This only is supported when using an emitter of type Mesh
  11517. */
  11518. inheritDirection: boolean;
  11519. /**
  11520. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11521. */
  11522. inheritedVelocityAmount: number;
  11523. /**
  11524. * Creates a sub emitter
  11525. * @param particleSystem the particle system to be used by the sub emitter
  11526. */
  11527. constructor(
  11528. /**
  11529. * the particle system to be used by the sub emitter
  11530. */
  11531. particleSystem: ParticleSystem);
  11532. /**
  11533. * Clones the sub emitter
  11534. * @returns the cloned sub emitter
  11535. */
  11536. clone(): SubEmitter;
  11537. /**
  11538. * Serialize current object to a JSON object
  11539. * @returns the serialized object
  11540. */
  11541. serialize(): any;
  11542. /** @hidden */
  11543. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11544. /**
  11545. * Creates a new SubEmitter from a serialized JSON version
  11546. * @param serializationObject defines the JSON object to read from
  11547. * @param scene defines the hosting scene
  11548. * @param rootUrl defines the rootUrl for data loading
  11549. * @returns a new SubEmitter
  11550. */
  11551. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11552. /** Release associated resources */
  11553. dispose(): void;
  11554. }
  11555. }
  11556. declare module BABYLON {
  11557. /** @hidden */
  11558. export var imageProcessingDeclaration: {
  11559. name: string;
  11560. shader: string;
  11561. };
  11562. }
  11563. declare module BABYLON {
  11564. /** @hidden */
  11565. export var imageProcessingFunctions: {
  11566. name: string;
  11567. shader: string;
  11568. };
  11569. }
  11570. declare module BABYLON {
  11571. /** @hidden */
  11572. export var particlesPixelShader: {
  11573. name: string;
  11574. shader: string;
  11575. };
  11576. }
  11577. declare module BABYLON {
  11578. /** @hidden */
  11579. export var particlesVertexShader: {
  11580. name: string;
  11581. shader: string;
  11582. };
  11583. }
  11584. declare module BABYLON {
  11585. /**
  11586. * This represents a particle system in Babylon.
  11587. * 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.
  11588. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11589. * @example https://doc.babylonjs.com/babylon101/particles
  11590. */
  11591. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11592. /**
  11593. * Billboard mode will only apply to Y axis
  11594. */
  11595. static readonly BILLBOARDMODE_Y: number;
  11596. /**
  11597. * Billboard mode will apply to all axes
  11598. */
  11599. static readonly BILLBOARDMODE_ALL: number;
  11600. /**
  11601. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11602. */
  11603. static readonly BILLBOARDMODE_STRETCHED: number;
  11604. /**
  11605. * This function can be defined to provide custom update for active particles.
  11606. * This function will be called instead of regular update (age, position, color, etc.).
  11607. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11608. */
  11609. updateFunction: (particles: Particle[]) => void;
  11610. private _emitterWorldMatrix;
  11611. /**
  11612. * This function can be defined to specify initial direction for every new particle.
  11613. * It by default use the emitterType defined function
  11614. */
  11615. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11616. /**
  11617. * This function can be defined to specify initial position for every new particle.
  11618. * It by default use the emitterType defined function
  11619. */
  11620. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11621. /**
  11622. * @hidden
  11623. */
  11624. _inheritedVelocityOffset: Vector3;
  11625. /**
  11626. * An event triggered when the system is disposed
  11627. */
  11628. onDisposeObservable: Observable<ParticleSystem>;
  11629. private _onDisposeObserver;
  11630. /**
  11631. * Sets a callback that will be triggered when the system is disposed
  11632. */
  11633. set onDispose(callback: () => void);
  11634. private _particles;
  11635. private _epsilon;
  11636. private _capacity;
  11637. private _stockParticles;
  11638. private _newPartsExcess;
  11639. private _vertexData;
  11640. private _vertexBuffer;
  11641. private _vertexBuffers;
  11642. private _spriteBuffer;
  11643. private _indexBuffer;
  11644. private _effect;
  11645. private _customEffect;
  11646. private _cachedDefines;
  11647. private _scaledColorStep;
  11648. private _colorDiff;
  11649. private _scaledDirection;
  11650. private _scaledGravity;
  11651. private _currentRenderId;
  11652. private _alive;
  11653. private _useInstancing;
  11654. private _started;
  11655. private _stopped;
  11656. private _actualFrame;
  11657. private _scaledUpdateSpeed;
  11658. private _vertexBufferSize;
  11659. /** @hidden */
  11660. _currentEmitRateGradient: Nullable<FactorGradient>;
  11661. /** @hidden */
  11662. _currentEmitRate1: number;
  11663. /** @hidden */
  11664. _currentEmitRate2: number;
  11665. /** @hidden */
  11666. _currentStartSizeGradient: Nullable<FactorGradient>;
  11667. /** @hidden */
  11668. _currentStartSize1: number;
  11669. /** @hidden */
  11670. _currentStartSize2: number;
  11671. private readonly _rawTextureWidth;
  11672. private _rampGradientsTexture;
  11673. private _useRampGradients;
  11674. /** Gets or sets a boolean indicating that ramp gradients must be used
  11675. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11676. */
  11677. get useRampGradients(): boolean;
  11678. set useRampGradients(value: boolean);
  11679. /**
  11680. * 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.
  11681. * 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: [])
  11682. */
  11683. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11684. private _subEmitters;
  11685. /**
  11686. * @hidden
  11687. * If the particle systems emitter should be disposed when the particle system is disposed
  11688. */
  11689. _disposeEmitterOnDispose: boolean;
  11690. /**
  11691. * The current active Sub-systems, this property is used by the root particle system only.
  11692. */
  11693. activeSubSystems: Array<ParticleSystem>;
  11694. /**
  11695. * Specifies if the particles are updated in emitter local space or world space
  11696. */
  11697. isLocal: boolean;
  11698. private _rootParticleSystem;
  11699. /**
  11700. * Gets the current list of active particles
  11701. */
  11702. get particles(): Particle[];
  11703. /**
  11704. * Returns the string "ParticleSystem"
  11705. * @returns a string containing the class name
  11706. */
  11707. getClassName(): string;
  11708. /**
  11709. * Instantiates a particle system.
  11710. * 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.
  11711. * @param name The name of the particle system
  11712. * @param capacity The max number of particles alive at the same time
  11713. * @param scene The scene the particle system belongs to
  11714. * @param customEffect a custom effect used to change the way particles are rendered by default
  11715. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11716. * @param epsilon Offset used to render the particles
  11717. */
  11718. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11719. private _addFactorGradient;
  11720. private _removeFactorGradient;
  11721. /**
  11722. * Adds a new life time gradient
  11723. * @param gradient defines the gradient to use (between 0 and 1)
  11724. * @param factor defines the life time factor to affect to the specified gradient
  11725. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11726. * @returns the current particle system
  11727. */
  11728. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11729. /**
  11730. * Remove a specific life time gradient
  11731. * @param gradient defines the gradient to remove
  11732. * @returns the current particle system
  11733. */
  11734. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11735. /**
  11736. * Adds a new size gradient
  11737. * @param gradient defines the gradient to use (between 0 and 1)
  11738. * @param factor defines the size factor to affect to the specified gradient
  11739. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11740. * @returns the current particle system
  11741. */
  11742. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11743. /**
  11744. * Remove a specific size gradient
  11745. * @param gradient defines the gradient to remove
  11746. * @returns the current particle system
  11747. */
  11748. removeSizeGradient(gradient: number): IParticleSystem;
  11749. /**
  11750. * Adds a new color remap gradient
  11751. * @param gradient defines the gradient to use (between 0 and 1)
  11752. * @param min defines the color remap minimal range
  11753. * @param max defines the color remap maximal range
  11754. * @returns the current particle system
  11755. */
  11756. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11757. /**
  11758. * Remove a specific color remap gradient
  11759. * @param gradient defines the gradient to remove
  11760. * @returns the current particle system
  11761. */
  11762. removeColorRemapGradient(gradient: number): IParticleSystem;
  11763. /**
  11764. * Adds a new alpha remap gradient
  11765. * @param gradient defines the gradient to use (between 0 and 1)
  11766. * @param min defines the alpha remap minimal range
  11767. * @param max defines the alpha remap maximal range
  11768. * @returns the current particle system
  11769. */
  11770. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11771. /**
  11772. * Remove a specific alpha remap gradient
  11773. * @param gradient defines the gradient to remove
  11774. * @returns the current particle system
  11775. */
  11776. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11777. /**
  11778. * Adds a new angular speed gradient
  11779. * @param gradient defines the gradient to use (between 0 and 1)
  11780. * @param factor defines the angular speed to affect to the specified gradient
  11781. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11782. * @returns the current particle system
  11783. */
  11784. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11785. /**
  11786. * Remove a specific angular speed gradient
  11787. * @param gradient defines the gradient to remove
  11788. * @returns the current particle system
  11789. */
  11790. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11791. /**
  11792. * Adds a new velocity gradient
  11793. * @param gradient defines the gradient to use (between 0 and 1)
  11794. * @param factor defines the velocity to affect to the specified gradient
  11795. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11796. * @returns the current particle system
  11797. */
  11798. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11799. /**
  11800. * Remove a specific velocity gradient
  11801. * @param gradient defines the gradient to remove
  11802. * @returns the current particle system
  11803. */
  11804. removeVelocityGradient(gradient: number): IParticleSystem;
  11805. /**
  11806. * Adds a new limit velocity gradient
  11807. * @param gradient defines the gradient to use (between 0 and 1)
  11808. * @param factor defines the limit velocity value to affect to the specified gradient
  11809. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11810. * @returns the current particle system
  11811. */
  11812. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11813. /**
  11814. * Remove a specific limit velocity gradient
  11815. * @param gradient defines the gradient to remove
  11816. * @returns the current particle system
  11817. */
  11818. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11819. /**
  11820. * Adds a new drag gradient
  11821. * @param gradient defines the gradient to use (between 0 and 1)
  11822. * @param factor defines the drag value to affect to the specified gradient
  11823. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11824. * @returns the current particle system
  11825. */
  11826. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11827. /**
  11828. * Remove a specific drag gradient
  11829. * @param gradient defines the gradient to remove
  11830. * @returns the current particle system
  11831. */
  11832. removeDragGradient(gradient: number): IParticleSystem;
  11833. /**
  11834. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  11835. * @param gradient defines the gradient to use (between 0 and 1)
  11836. * @param factor defines the emit rate value to affect to the specified gradient
  11837. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11838. * @returns the current particle system
  11839. */
  11840. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11841. /**
  11842. * Remove a specific emit rate gradient
  11843. * @param gradient defines the gradient to remove
  11844. * @returns the current particle system
  11845. */
  11846. removeEmitRateGradient(gradient: number): IParticleSystem;
  11847. /**
  11848. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  11849. * @param gradient defines the gradient to use (between 0 and 1)
  11850. * @param factor defines the start size value to affect to the specified gradient
  11851. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11852. * @returns the current particle system
  11853. */
  11854. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11855. /**
  11856. * Remove a specific start size gradient
  11857. * @param gradient defines the gradient to remove
  11858. * @returns the current particle system
  11859. */
  11860. removeStartSizeGradient(gradient: number): IParticleSystem;
  11861. private _createRampGradientTexture;
  11862. /**
  11863. * Gets the current list of ramp gradients.
  11864. * You must use addRampGradient and removeRampGradient to udpate this list
  11865. * @returns the list of ramp gradients
  11866. */
  11867. getRampGradients(): Nullable<Array<Color3Gradient>>;
  11868. /**
  11869. * Adds a new ramp gradient used to remap particle colors
  11870. * @param gradient defines the gradient to use (between 0 and 1)
  11871. * @param color defines the color to affect to the specified gradient
  11872. * @returns the current particle system
  11873. */
  11874. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  11875. /**
  11876. * Remove a specific ramp gradient
  11877. * @param gradient defines the gradient to remove
  11878. * @returns the current particle system
  11879. */
  11880. removeRampGradient(gradient: number): ParticleSystem;
  11881. /**
  11882. * Adds a new color gradient
  11883. * @param gradient defines the gradient to use (between 0 and 1)
  11884. * @param color1 defines the color to affect to the specified gradient
  11885. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  11886. * @returns this particle system
  11887. */
  11888. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  11889. /**
  11890. * Remove a specific color gradient
  11891. * @param gradient defines the gradient to remove
  11892. * @returns this particle system
  11893. */
  11894. removeColorGradient(gradient: number): IParticleSystem;
  11895. private _fetchR;
  11896. protected _reset(): void;
  11897. private _resetEffect;
  11898. private _createVertexBuffers;
  11899. private _createIndexBuffer;
  11900. /**
  11901. * Gets the maximum number of particles active at the same time.
  11902. * @returns The max number of active particles.
  11903. */
  11904. getCapacity(): number;
  11905. /**
  11906. * Gets whether there are still active particles in the system.
  11907. * @returns True if it is alive, otherwise false.
  11908. */
  11909. isAlive(): boolean;
  11910. /**
  11911. * Gets if the system has been started. (Note: this will still be true after stop is called)
  11912. * @returns True if it has been started, otherwise false.
  11913. */
  11914. isStarted(): boolean;
  11915. private _prepareSubEmitterInternalArray;
  11916. /**
  11917. * Starts the particle system and begins to emit
  11918. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  11919. */
  11920. start(delay?: number): void;
  11921. /**
  11922. * Stops the particle system.
  11923. * @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.
  11924. */
  11925. stop(stopSubEmitters?: boolean): void;
  11926. /**
  11927. * Remove all active particles
  11928. */
  11929. reset(): void;
  11930. /**
  11931. * @hidden (for internal use only)
  11932. */
  11933. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  11934. /**
  11935. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  11936. * Its lifetime will start back at 0.
  11937. */
  11938. recycleParticle: (particle: Particle) => void;
  11939. private _stopSubEmitters;
  11940. private _createParticle;
  11941. private _removeFromRoot;
  11942. private _emitFromParticle;
  11943. private _update;
  11944. /** @hidden */
  11945. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  11946. /** @hidden */
  11947. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  11948. /** @hidden */
  11949. private _getEffect;
  11950. /**
  11951. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  11952. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  11953. */
  11954. animate(preWarmOnly?: boolean): void;
  11955. private _appendParticleVertices;
  11956. /**
  11957. * Rebuilds the particle system.
  11958. */
  11959. rebuild(): void;
  11960. /**
  11961. * Is this system ready to be used/rendered
  11962. * @return true if the system is ready
  11963. */
  11964. isReady(): boolean;
  11965. private _render;
  11966. /**
  11967. * Renders the particle system in its current state.
  11968. * @returns the current number of particles
  11969. */
  11970. render(): number;
  11971. /**
  11972. * Disposes the particle system and free the associated resources
  11973. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  11974. */
  11975. dispose(disposeTexture?: boolean): void;
  11976. /**
  11977. * Clones the particle system.
  11978. * @param name The name of the cloned object
  11979. * @param newEmitter The new emitter to use
  11980. * @returns the cloned particle system
  11981. */
  11982. clone(name: string, newEmitter: any): ParticleSystem;
  11983. /**
  11984. * Serializes the particle system to a JSON object.
  11985. * @returns the JSON object
  11986. */
  11987. serialize(): any;
  11988. /** @hidden */
  11989. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  11990. /** @hidden */
  11991. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  11992. /**
  11993. * Parses a JSON object to create a particle system.
  11994. * @param parsedParticleSystem The JSON object to parse
  11995. * @param scene The scene to create the particle system in
  11996. * @param rootUrl The root url to use to load external dependencies like texture
  11997. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  11998. * @returns the Parsed particle system
  11999. */
  12000. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12001. }
  12002. }
  12003. declare module BABYLON {
  12004. /**
  12005. * A particle represents one of the element emitted by a particle system.
  12006. * This is mainly define by its coordinates, direction, velocity and age.
  12007. */
  12008. export class Particle {
  12009. /**
  12010. * The particle system the particle belongs to.
  12011. */
  12012. particleSystem: ParticleSystem;
  12013. private static _Count;
  12014. /**
  12015. * Unique ID of the particle
  12016. */
  12017. id: number;
  12018. /**
  12019. * The world position of the particle in the scene.
  12020. */
  12021. position: Vector3;
  12022. /**
  12023. * The world direction of the particle in the scene.
  12024. */
  12025. direction: Vector3;
  12026. /**
  12027. * The color of the particle.
  12028. */
  12029. color: Color4;
  12030. /**
  12031. * The color change of the particle per step.
  12032. */
  12033. colorStep: Color4;
  12034. /**
  12035. * Defines how long will the life of the particle be.
  12036. */
  12037. lifeTime: number;
  12038. /**
  12039. * The current age of the particle.
  12040. */
  12041. age: number;
  12042. /**
  12043. * The current size of the particle.
  12044. */
  12045. size: number;
  12046. /**
  12047. * The current scale of the particle.
  12048. */
  12049. scale: Vector2;
  12050. /**
  12051. * The current angle of the particle.
  12052. */
  12053. angle: number;
  12054. /**
  12055. * Defines how fast is the angle changing.
  12056. */
  12057. angularSpeed: number;
  12058. /**
  12059. * Defines the cell index used by the particle to be rendered from a sprite.
  12060. */
  12061. cellIndex: number;
  12062. /**
  12063. * The information required to support color remapping
  12064. */
  12065. remapData: Vector4;
  12066. /** @hidden */
  12067. _randomCellOffset?: number;
  12068. /** @hidden */
  12069. _initialDirection: Nullable<Vector3>;
  12070. /** @hidden */
  12071. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12072. /** @hidden */
  12073. _initialStartSpriteCellID: number;
  12074. /** @hidden */
  12075. _initialEndSpriteCellID: number;
  12076. /** @hidden */
  12077. _currentColorGradient: Nullable<ColorGradient>;
  12078. /** @hidden */
  12079. _currentColor1: Color4;
  12080. /** @hidden */
  12081. _currentColor2: Color4;
  12082. /** @hidden */
  12083. _currentSizeGradient: Nullable<FactorGradient>;
  12084. /** @hidden */
  12085. _currentSize1: number;
  12086. /** @hidden */
  12087. _currentSize2: number;
  12088. /** @hidden */
  12089. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12090. /** @hidden */
  12091. _currentAngularSpeed1: number;
  12092. /** @hidden */
  12093. _currentAngularSpeed2: number;
  12094. /** @hidden */
  12095. _currentVelocityGradient: Nullable<FactorGradient>;
  12096. /** @hidden */
  12097. _currentVelocity1: number;
  12098. /** @hidden */
  12099. _currentVelocity2: number;
  12100. /** @hidden */
  12101. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12102. /** @hidden */
  12103. _currentLimitVelocity1: number;
  12104. /** @hidden */
  12105. _currentLimitVelocity2: number;
  12106. /** @hidden */
  12107. _currentDragGradient: Nullable<FactorGradient>;
  12108. /** @hidden */
  12109. _currentDrag1: number;
  12110. /** @hidden */
  12111. _currentDrag2: number;
  12112. /** @hidden */
  12113. _randomNoiseCoordinates1: Vector3;
  12114. /** @hidden */
  12115. _randomNoiseCoordinates2: Vector3;
  12116. /** @hidden */
  12117. _localPosition?: Vector3;
  12118. /**
  12119. * Creates a new instance Particle
  12120. * @param particleSystem the particle system the particle belongs to
  12121. */
  12122. constructor(
  12123. /**
  12124. * The particle system the particle belongs to.
  12125. */
  12126. particleSystem: ParticleSystem);
  12127. private updateCellInfoFromSystem;
  12128. /**
  12129. * Defines how the sprite cell index is updated for the particle
  12130. */
  12131. updateCellIndex(): void;
  12132. /** @hidden */
  12133. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12134. /** @hidden */
  12135. _inheritParticleInfoToSubEmitters(): void;
  12136. /** @hidden */
  12137. _reset(): void;
  12138. /**
  12139. * Copy the properties of particle to another one.
  12140. * @param other the particle to copy the information to.
  12141. */
  12142. copyTo(other: Particle): void;
  12143. }
  12144. }
  12145. declare module BABYLON {
  12146. /**
  12147. * Particle emitter represents a volume emitting particles.
  12148. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12149. */
  12150. export interface IParticleEmitterType {
  12151. /**
  12152. * Called by the particle System when the direction is computed for the created particle.
  12153. * @param worldMatrix is the world matrix of the particle system
  12154. * @param directionToUpdate is the direction vector to update with the result
  12155. * @param particle is the particle we are computed the direction for
  12156. * @param isLocal defines if the direction should be set in local space
  12157. */
  12158. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12159. /**
  12160. * Called by the particle System when the position is computed for the created particle.
  12161. * @param worldMatrix is the world matrix of the particle system
  12162. * @param positionToUpdate is the position vector to update with the result
  12163. * @param particle is the particle we are computed the position for
  12164. * @param isLocal defines if the position should be set in local space
  12165. */
  12166. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12167. /**
  12168. * Clones the current emitter and returns a copy of it
  12169. * @returns the new emitter
  12170. */
  12171. clone(): IParticleEmitterType;
  12172. /**
  12173. * Called by the GPUParticleSystem to setup the update shader
  12174. * @param effect defines the update shader
  12175. */
  12176. applyToShader(effect: Effect): void;
  12177. /**
  12178. * Returns a string to use to update the GPU particles update shader
  12179. * @returns the effect defines string
  12180. */
  12181. getEffectDefines(): string;
  12182. /**
  12183. * Returns a string representing the class name
  12184. * @returns a string containing the class name
  12185. */
  12186. getClassName(): string;
  12187. /**
  12188. * Serializes the particle system to a JSON object.
  12189. * @returns the JSON object
  12190. */
  12191. serialize(): any;
  12192. /**
  12193. * Parse properties from a JSON object
  12194. * @param serializationObject defines the JSON object
  12195. * @param scene defines the hosting scene
  12196. */
  12197. parse(serializationObject: any, scene: Scene): void;
  12198. }
  12199. }
  12200. declare module BABYLON {
  12201. /**
  12202. * Particle emitter emitting particles from the inside of a box.
  12203. * It emits the particles randomly between 2 given directions.
  12204. */
  12205. export class BoxParticleEmitter implements IParticleEmitterType {
  12206. /**
  12207. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12208. */
  12209. direction1: Vector3;
  12210. /**
  12211. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12212. */
  12213. direction2: Vector3;
  12214. /**
  12215. * 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.
  12216. */
  12217. minEmitBox: Vector3;
  12218. /**
  12219. * 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.
  12220. */
  12221. maxEmitBox: Vector3;
  12222. /**
  12223. * Creates a new instance BoxParticleEmitter
  12224. */
  12225. constructor();
  12226. /**
  12227. * Called by the particle System when the direction is computed for the created particle.
  12228. * @param worldMatrix is the world matrix of the particle system
  12229. * @param directionToUpdate is the direction vector to update with the result
  12230. * @param particle is the particle we are computed the direction for
  12231. * @param isLocal defines if the direction should be set in local space
  12232. */
  12233. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12234. /**
  12235. * Called by the particle System when the position is computed for the created particle.
  12236. * @param worldMatrix is the world matrix of the particle system
  12237. * @param positionToUpdate is the position vector to update with the result
  12238. * @param particle is the particle we are computed the position for
  12239. * @param isLocal defines if the position should be set in local space
  12240. */
  12241. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12242. /**
  12243. * Clones the current emitter and returns a copy of it
  12244. * @returns the new emitter
  12245. */
  12246. clone(): BoxParticleEmitter;
  12247. /**
  12248. * Called by the GPUParticleSystem to setup the update shader
  12249. * @param effect defines the update shader
  12250. */
  12251. applyToShader(effect: Effect): void;
  12252. /**
  12253. * Returns a string to use to update the GPU particles update shader
  12254. * @returns a string containng the defines string
  12255. */
  12256. getEffectDefines(): string;
  12257. /**
  12258. * Returns the string "BoxParticleEmitter"
  12259. * @returns a string containing the class name
  12260. */
  12261. getClassName(): string;
  12262. /**
  12263. * Serializes the particle system to a JSON object.
  12264. * @returns the JSON object
  12265. */
  12266. serialize(): any;
  12267. /**
  12268. * Parse properties from a JSON object
  12269. * @param serializationObject defines the JSON object
  12270. */
  12271. parse(serializationObject: any): void;
  12272. }
  12273. }
  12274. declare module BABYLON {
  12275. /**
  12276. * Particle emitter emitting particles from the inside of a cone.
  12277. * It emits the particles alongside the cone volume from the base to the particle.
  12278. * The emission direction might be randomized.
  12279. */
  12280. export class ConeParticleEmitter implements IParticleEmitterType {
  12281. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12282. directionRandomizer: number;
  12283. private _radius;
  12284. private _angle;
  12285. private _height;
  12286. /**
  12287. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12288. */
  12289. radiusRange: number;
  12290. /**
  12291. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12292. */
  12293. heightRange: number;
  12294. /**
  12295. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12296. */
  12297. emitFromSpawnPointOnly: boolean;
  12298. /**
  12299. * Gets or sets the radius of the emission cone
  12300. */
  12301. get radius(): number;
  12302. set radius(value: number);
  12303. /**
  12304. * Gets or sets the angle of the emission cone
  12305. */
  12306. get angle(): number;
  12307. set angle(value: number);
  12308. private _buildHeight;
  12309. /**
  12310. * Creates a new instance ConeParticleEmitter
  12311. * @param radius the radius of the emission cone (1 by default)
  12312. * @param angle the cone base angle (PI by default)
  12313. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12314. */
  12315. constructor(radius?: number, angle?: number,
  12316. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12317. directionRandomizer?: number);
  12318. /**
  12319. * Called by the particle System when the direction is computed for the created particle.
  12320. * @param worldMatrix is the world matrix of the particle system
  12321. * @param directionToUpdate is the direction vector to update with the result
  12322. * @param particle is the particle we are computed the direction for
  12323. * @param isLocal defines if the direction should be set in local space
  12324. */
  12325. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12326. /**
  12327. * Called by the particle System when the position is computed for the created particle.
  12328. * @param worldMatrix is the world matrix of the particle system
  12329. * @param positionToUpdate is the position vector to update with the result
  12330. * @param particle is the particle we are computed the position for
  12331. * @param isLocal defines if the position should be set in local space
  12332. */
  12333. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12334. /**
  12335. * Clones the current emitter and returns a copy of it
  12336. * @returns the new emitter
  12337. */
  12338. clone(): ConeParticleEmitter;
  12339. /**
  12340. * Called by the GPUParticleSystem to setup the update shader
  12341. * @param effect defines the update shader
  12342. */
  12343. applyToShader(effect: Effect): void;
  12344. /**
  12345. * Returns a string to use to update the GPU particles update shader
  12346. * @returns a string containng the defines string
  12347. */
  12348. getEffectDefines(): string;
  12349. /**
  12350. * Returns the string "ConeParticleEmitter"
  12351. * @returns a string containing the class name
  12352. */
  12353. getClassName(): string;
  12354. /**
  12355. * Serializes the particle system to a JSON object.
  12356. * @returns the JSON object
  12357. */
  12358. serialize(): any;
  12359. /**
  12360. * Parse properties from a JSON object
  12361. * @param serializationObject defines the JSON object
  12362. */
  12363. parse(serializationObject: any): void;
  12364. }
  12365. }
  12366. declare module BABYLON {
  12367. /**
  12368. * Particle emitter emitting particles from the inside of a cylinder.
  12369. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12370. */
  12371. export class CylinderParticleEmitter implements IParticleEmitterType {
  12372. /**
  12373. * The radius of the emission cylinder.
  12374. */
  12375. radius: number;
  12376. /**
  12377. * The height of the emission cylinder.
  12378. */
  12379. height: number;
  12380. /**
  12381. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12382. */
  12383. radiusRange: number;
  12384. /**
  12385. * How much to randomize the particle direction [0-1].
  12386. */
  12387. directionRandomizer: number;
  12388. /**
  12389. * Creates a new instance CylinderParticleEmitter
  12390. * @param radius the radius of the emission cylinder (1 by default)
  12391. * @param height the height of the emission cylinder (1 by default)
  12392. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12393. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12394. */
  12395. constructor(
  12396. /**
  12397. * The radius of the emission cylinder.
  12398. */
  12399. radius?: number,
  12400. /**
  12401. * The height of the emission cylinder.
  12402. */
  12403. height?: number,
  12404. /**
  12405. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12406. */
  12407. radiusRange?: number,
  12408. /**
  12409. * How much to randomize the particle direction [0-1].
  12410. */
  12411. directionRandomizer?: number);
  12412. /**
  12413. * Called by the particle System when the direction is computed for the created particle.
  12414. * @param worldMatrix is the world matrix of the particle system
  12415. * @param directionToUpdate is the direction vector to update with the result
  12416. * @param particle is the particle we are computed the direction for
  12417. * @param isLocal defines if the direction should be set in local space
  12418. */
  12419. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12420. /**
  12421. * Called by the particle System when the position is computed for the created particle.
  12422. * @param worldMatrix is the world matrix of the particle system
  12423. * @param positionToUpdate is the position vector to update with the result
  12424. * @param particle is the particle we are computed the position for
  12425. * @param isLocal defines if the position should be set in local space
  12426. */
  12427. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12428. /**
  12429. * Clones the current emitter and returns a copy of it
  12430. * @returns the new emitter
  12431. */
  12432. clone(): CylinderParticleEmitter;
  12433. /**
  12434. * Called by the GPUParticleSystem to setup the update shader
  12435. * @param effect defines the update shader
  12436. */
  12437. applyToShader(effect: Effect): void;
  12438. /**
  12439. * Returns a string to use to update the GPU particles update shader
  12440. * @returns a string containng the defines string
  12441. */
  12442. getEffectDefines(): string;
  12443. /**
  12444. * Returns the string "CylinderParticleEmitter"
  12445. * @returns a string containing the class name
  12446. */
  12447. getClassName(): string;
  12448. /**
  12449. * Serializes the particle system to a JSON object.
  12450. * @returns the JSON object
  12451. */
  12452. serialize(): any;
  12453. /**
  12454. * Parse properties from a JSON object
  12455. * @param serializationObject defines the JSON object
  12456. */
  12457. parse(serializationObject: any): void;
  12458. }
  12459. /**
  12460. * Particle emitter emitting particles from the inside of a cylinder.
  12461. * It emits the particles randomly between two vectors.
  12462. */
  12463. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12464. /**
  12465. * The min limit of the emission direction.
  12466. */
  12467. direction1: Vector3;
  12468. /**
  12469. * The max limit of the emission direction.
  12470. */
  12471. direction2: Vector3;
  12472. /**
  12473. * Creates a new instance CylinderDirectedParticleEmitter
  12474. * @param radius the radius of the emission cylinder (1 by default)
  12475. * @param height the height of the emission cylinder (1 by default)
  12476. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12477. * @param direction1 the min limit of the emission direction (up vector by default)
  12478. * @param direction2 the max limit of the emission direction (up vector by default)
  12479. */
  12480. constructor(radius?: number, height?: number, radiusRange?: number,
  12481. /**
  12482. * The min limit of the emission direction.
  12483. */
  12484. direction1?: Vector3,
  12485. /**
  12486. * The max limit of the emission direction.
  12487. */
  12488. direction2?: Vector3);
  12489. /**
  12490. * Called by the particle System when the direction is computed for the created particle.
  12491. * @param worldMatrix is the world matrix of the particle system
  12492. * @param directionToUpdate is the direction vector to update with the result
  12493. * @param particle is the particle we are computed the direction for
  12494. */
  12495. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12496. /**
  12497. * Clones the current emitter and returns a copy of it
  12498. * @returns the new emitter
  12499. */
  12500. clone(): CylinderDirectedParticleEmitter;
  12501. /**
  12502. * Called by the GPUParticleSystem to setup the update shader
  12503. * @param effect defines the update shader
  12504. */
  12505. applyToShader(effect: Effect): void;
  12506. /**
  12507. * Returns a string to use to update the GPU particles update shader
  12508. * @returns a string containng the defines string
  12509. */
  12510. getEffectDefines(): string;
  12511. /**
  12512. * Returns the string "CylinderDirectedParticleEmitter"
  12513. * @returns a string containing the class name
  12514. */
  12515. getClassName(): string;
  12516. /**
  12517. * Serializes the particle system to a JSON object.
  12518. * @returns the JSON object
  12519. */
  12520. serialize(): any;
  12521. /**
  12522. * Parse properties from a JSON object
  12523. * @param serializationObject defines the JSON object
  12524. */
  12525. parse(serializationObject: any): void;
  12526. }
  12527. }
  12528. declare module BABYLON {
  12529. /**
  12530. * Particle emitter emitting particles from the inside of a hemisphere.
  12531. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12532. */
  12533. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12534. /**
  12535. * The radius of the emission hemisphere.
  12536. */
  12537. radius: number;
  12538. /**
  12539. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12540. */
  12541. radiusRange: number;
  12542. /**
  12543. * How much to randomize the particle direction [0-1].
  12544. */
  12545. directionRandomizer: number;
  12546. /**
  12547. * Creates a new instance HemisphericParticleEmitter
  12548. * @param radius the radius of the emission hemisphere (1 by default)
  12549. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12550. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12551. */
  12552. constructor(
  12553. /**
  12554. * The radius of the emission hemisphere.
  12555. */
  12556. radius?: number,
  12557. /**
  12558. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12559. */
  12560. radiusRange?: number,
  12561. /**
  12562. * How much to randomize the particle direction [0-1].
  12563. */
  12564. directionRandomizer?: number);
  12565. /**
  12566. * Called by the particle System when the direction is computed for the created particle.
  12567. * @param worldMatrix is the world matrix of the particle system
  12568. * @param directionToUpdate is the direction vector to update with the result
  12569. * @param particle is the particle we are computed the direction for
  12570. * @param isLocal defines if the direction should be set in local space
  12571. */
  12572. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12573. /**
  12574. * Called by the particle System when the position is computed for the created particle.
  12575. * @param worldMatrix is the world matrix of the particle system
  12576. * @param positionToUpdate is the position vector to update with the result
  12577. * @param particle is the particle we are computed the position for
  12578. * @param isLocal defines if the position should be set in local space
  12579. */
  12580. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12581. /**
  12582. * Clones the current emitter and returns a copy of it
  12583. * @returns the new emitter
  12584. */
  12585. clone(): HemisphericParticleEmitter;
  12586. /**
  12587. * Called by the GPUParticleSystem to setup the update shader
  12588. * @param effect defines the update shader
  12589. */
  12590. applyToShader(effect: Effect): void;
  12591. /**
  12592. * Returns a string to use to update the GPU particles update shader
  12593. * @returns a string containng the defines string
  12594. */
  12595. getEffectDefines(): string;
  12596. /**
  12597. * Returns the string "HemisphericParticleEmitter"
  12598. * @returns a string containing the class name
  12599. */
  12600. getClassName(): string;
  12601. /**
  12602. * Serializes the particle system to a JSON object.
  12603. * @returns the JSON object
  12604. */
  12605. serialize(): any;
  12606. /**
  12607. * Parse properties from a JSON object
  12608. * @param serializationObject defines the JSON object
  12609. */
  12610. parse(serializationObject: any): void;
  12611. }
  12612. }
  12613. declare module BABYLON {
  12614. /**
  12615. * Particle emitter emitting particles from a point.
  12616. * It emits the particles randomly between 2 given directions.
  12617. */
  12618. export class PointParticleEmitter implements IParticleEmitterType {
  12619. /**
  12620. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12621. */
  12622. direction1: Vector3;
  12623. /**
  12624. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12625. */
  12626. direction2: Vector3;
  12627. /**
  12628. * Creates a new instance PointParticleEmitter
  12629. */
  12630. constructor();
  12631. /**
  12632. * Called by the particle System when the direction is computed for the created particle.
  12633. * @param worldMatrix is the world matrix of the particle system
  12634. * @param directionToUpdate is the direction vector to update with the result
  12635. * @param particle is the particle we are computed the direction for
  12636. * @param isLocal defines if the direction should be set in local space
  12637. */
  12638. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12639. /**
  12640. * Called by the particle System when the position is computed for the created particle.
  12641. * @param worldMatrix is the world matrix of the particle system
  12642. * @param positionToUpdate is the position vector to update with the result
  12643. * @param particle is the particle we are computed the position for
  12644. * @param isLocal defines if the position should be set in local space
  12645. */
  12646. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12647. /**
  12648. * Clones the current emitter and returns a copy of it
  12649. * @returns the new emitter
  12650. */
  12651. clone(): PointParticleEmitter;
  12652. /**
  12653. * Called by the GPUParticleSystem to setup the update shader
  12654. * @param effect defines the update shader
  12655. */
  12656. applyToShader(effect: Effect): void;
  12657. /**
  12658. * Returns a string to use to update the GPU particles update shader
  12659. * @returns a string containng the defines string
  12660. */
  12661. getEffectDefines(): string;
  12662. /**
  12663. * Returns the string "PointParticleEmitter"
  12664. * @returns a string containing the class name
  12665. */
  12666. getClassName(): string;
  12667. /**
  12668. * Serializes the particle system to a JSON object.
  12669. * @returns the JSON object
  12670. */
  12671. serialize(): any;
  12672. /**
  12673. * Parse properties from a JSON object
  12674. * @param serializationObject defines the JSON object
  12675. */
  12676. parse(serializationObject: any): void;
  12677. }
  12678. }
  12679. declare module BABYLON {
  12680. /**
  12681. * Particle emitter emitting particles from the inside of a sphere.
  12682. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12683. */
  12684. export class SphereParticleEmitter implements IParticleEmitterType {
  12685. /**
  12686. * The radius of the emission sphere.
  12687. */
  12688. radius: number;
  12689. /**
  12690. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12691. */
  12692. radiusRange: number;
  12693. /**
  12694. * How much to randomize the particle direction [0-1].
  12695. */
  12696. directionRandomizer: number;
  12697. /**
  12698. * Creates a new instance SphereParticleEmitter
  12699. * @param radius the radius of the emission sphere (1 by default)
  12700. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12701. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12702. */
  12703. constructor(
  12704. /**
  12705. * The radius of the emission sphere.
  12706. */
  12707. radius?: number,
  12708. /**
  12709. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12710. */
  12711. radiusRange?: number,
  12712. /**
  12713. * How much to randomize the particle direction [0-1].
  12714. */
  12715. directionRandomizer?: number);
  12716. /**
  12717. * Called by the particle System when the direction is computed for the created particle.
  12718. * @param worldMatrix is the world matrix of the particle system
  12719. * @param directionToUpdate is the direction vector to update with the result
  12720. * @param particle is the particle we are computed the direction for
  12721. * @param isLocal defines if the direction should be set in local space
  12722. */
  12723. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12724. /**
  12725. * Called by the particle System when the position is computed for the created particle.
  12726. * @param worldMatrix is the world matrix of the particle system
  12727. * @param positionToUpdate is the position vector to update with the result
  12728. * @param particle is the particle we are computed the position for
  12729. * @param isLocal defines if the position should be set in local space
  12730. */
  12731. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12732. /**
  12733. * Clones the current emitter and returns a copy of it
  12734. * @returns the new emitter
  12735. */
  12736. clone(): SphereParticleEmitter;
  12737. /**
  12738. * Called by the GPUParticleSystem to setup the update shader
  12739. * @param effect defines the update shader
  12740. */
  12741. applyToShader(effect: Effect): void;
  12742. /**
  12743. * Returns a string to use to update the GPU particles update shader
  12744. * @returns a string containng the defines string
  12745. */
  12746. getEffectDefines(): string;
  12747. /**
  12748. * Returns the string "SphereParticleEmitter"
  12749. * @returns a string containing the class name
  12750. */
  12751. getClassName(): string;
  12752. /**
  12753. * Serializes the particle system to a JSON object.
  12754. * @returns the JSON object
  12755. */
  12756. serialize(): any;
  12757. /**
  12758. * Parse properties from a JSON object
  12759. * @param serializationObject defines the JSON object
  12760. */
  12761. parse(serializationObject: any): void;
  12762. }
  12763. /**
  12764. * Particle emitter emitting particles from the inside of a sphere.
  12765. * It emits the particles randomly between two vectors.
  12766. */
  12767. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12768. /**
  12769. * The min limit of the emission direction.
  12770. */
  12771. direction1: Vector3;
  12772. /**
  12773. * The max limit of the emission direction.
  12774. */
  12775. direction2: Vector3;
  12776. /**
  12777. * Creates a new instance SphereDirectedParticleEmitter
  12778. * @param radius the radius of the emission sphere (1 by default)
  12779. * @param direction1 the min limit of the emission direction (up vector by default)
  12780. * @param direction2 the max limit of the emission direction (up vector by default)
  12781. */
  12782. constructor(radius?: number,
  12783. /**
  12784. * The min limit of the emission direction.
  12785. */
  12786. direction1?: Vector3,
  12787. /**
  12788. * The max limit of the emission direction.
  12789. */
  12790. direction2?: Vector3);
  12791. /**
  12792. * Called by the particle System when the direction is computed for the created particle.
  12793. * @param worldMatrix is the world matrix of the particle system
  12794. * @param directionToUpdate is the direction vector to update with the result
  12795. * @param particle is the particle we are computed the direction for
  12796. */
  12797. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12798. /**
  12799. * Clones the current emitter and returns a copy of it
  12800. * @returns the new emitter
  12801. */
  12802. clone(): SphereDirectedParticleEmitter;
  12803. /**
  12804. * Called by the GPUParticleSystem to setup the update shader
  12805. * @param effect defines the update shader
  12806. */
  12807. applyToShader(effect: Effect): void;
  12808. /**
  12809. * Returns a string to use to update the GPU particles update shader
  12810. * @returns a string containng the defines string
  12811. */
  12812. getEffectDefines(): string;
  12813. /**
  12814. * Returns the string "SphereDirectedParticleEmitter"
  12815. * @returns a string containing the class name
  12816. */
  12817. getClassName(): string;
  12818. /**
  12819. * Serializes the particle system to a JSON object.
  12820. * @returns the JSON object
  12821. */
  12822. serialize(): any;
  12823. /**
  12824. * Parse properties from a JSON object
  12825. * @param serializationObject defines the JSON object
  12826. */
  12827. parse(serializationObject: any): void;
  12828. }
  12829. }
  12830. declare module BABYLON {
  12831. /**
  12832. * Particle emitter emitting particles from a custom list of positions.
  12833. */
  12834. export class CustomParticleEmitter implements IParticleEmitterType {
  12835. /**
  12836. * Gets or sets the position generator that will create the inital position of each particle.
  12837. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12838. */
  12839. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  12840. /**
  12841. * Gets or sets the destination generator that will create the final destination of each particle.
  12842. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12843. */
  12844. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  12845. /**
  12846. * Creates a new instance CustomParticleEmitter
  12847. */
  12848. constructor();
  12849. /**
  12850. * Called by the particle System when the direction is computed for the created particle.
  12851. * @param worldMatrix is the world matrix of the particle system
  12852. * @param directionToUpdate is the direction vector to update with the result
  12853. * @param particle is the particle we are computed the direction for
  12854. * @param isLocal defines if the direction should be set in local space
  12855. */
  12856. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12857. /**
  12858. * Called by the particle System when the position is computed for the created particle.
  12859. * @param worldMatrix is the world matrix of the particle system
  12860. * @param positionToUpdate is the position vector to update with the result
  12861. * @param particle is the particle we are computed the position for
  12862. * @param isLocal defines if the position should be set in local space
  12863. */
  12864. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12865. /**
  12866. * Clones the current emitter and returns a copy of it
  12867. * @returns the new emitter
  12868. */
  12869. clone(): CustomParticleEmitter;
  12870. /**
  12871. * Called by the GPUParticleSystem to setup the update shader
  12872. * @param effect defines the update shader
  12873. */
  12874. applyToShader(effect: Effect): void;
  12875. /**
  12876. * Returns a string to use to update the GPU particles update shader
  12877. * @returns a string containng the defines string
  12878. */
  12879. getEffectDefines(): string;
  12880. /**
  12881. * Returns the string "PointParticleEmitter"
  12882. * @returns a string containing the class name
  12883. */
  12884. getClassName(): string;
  12885. /**
  12886. * Serializes the particle system to a JSON object.
  12887. * @returns the JSON object
  12888. */
  12889. serialize(): any;
  12890. /**
  12891. * Parse properties from a JSON object
  12892. * @param serializationObject defines the JSON object
  12893. */
  12894. parse(serializationObject: any): void;
  12895. }
  12896. }
  12897. declare module BABYLON {
  12898. /**
  12899. * Particle emitter emitting particles from the inside of a box.
  12900. * It emits the particles randomly between 2 given directions.
  12901. */
  12902. export class MeshParticleEmitter implements IParticleEmitterType {
  12903. private _indices;
  12904. private _positions;
  12905. private _normals;
  12906. private _storedNormal;
  12907. private _mesh;
  12908. /**
  12909. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12910. */
  12911. direction1: Vector3;
  12912. /**
  12913. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12914. */
  12915. direction2: Vector3;
  12916. /**
  12917. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  12918. */
  12919. useMeshNormalsForDirection: boolean;
  12920. /** Defines the mesh to use as source */
  12921. get mesh(): Nullable<AbstractMesh>;
  12922. set mesh(value: Nullable<AbstractMesh>);
  12923. /**
  12924. * Creates a new instance MeshParticleEmitter
  12925. * @param mesh defines the mesh to use as source
  12926. */
  12927. constructor(mesh?: Nullable<AbstractMesh>);
  12928. /**
  12929. * Called by the particle System when the direction is computed for the created particle.
  12930. * @param worldMatrix is the world matrix of the particle system
  12931. * @param directionToUpdate is the direction vector to update with the result
  12932. * @param particle is the particle we are computed the direction for
  12933. * @param isLocal defines if the direction should be set in local space
  12934. */
  12935. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12936. /**
  12937. * Called by the particle System when the position is computed for the created particle.
  12938. * @param worldMatrix is the world matrix of the particle system
  12939. * @param positionToUpdate is the position vector to update with the result
  12940. * @param particle is the particle we are computed the position for
  12941. * @param isLocal defines if the position should be set in local space
  12942. */
  12943. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12944. /**
  12945. * Clones the current emitter and returns a copy of it
  12946. * @returns the new emitter
  12947. */
  12948. clone(): MeshParticleEmitter;
  12949. /**
  12950. * Called by the GPUParticleSystem to setup the update shader
  12951. * @param effect defines the update shader
  12952. */
  12953. applyToShader(effect: Effect): void;
  12954. /**
  12955. * Returns a string to use to update the GPU particles update shader
  12956. * @returns a string containng the defines string
  12957. */
  12958. getEffectDefines(): string;
  12959. /**
  12960. * Returns the string "BoxParticleEmitter"
  12961. * @returns a string containing the class name
  12962. */
  12963. getClassName(): string;
  12964. /**
  12965. * Serializes the particle system to a JSON object.
  12966. * @returns the JSON object
  12967. */
  12968. serialize(): any;
  12969. /**
  12970. * Parse properties from a JSON object
  12971. * @param serializationObject defines the JSON object
  12972. * @param scene defines the hosting scene
  12973. */
  12974. parse(serializationObject: any, scene: Scene): void;
  12975. }
  12976. }
  12977. declare module BABYLON {
  12978. /**
  12979. * Interface representing a particle system in Babylon.js.
  12980. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  12981. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  12982. */
  12983. export interface IParticleSystem {
  12984. /**
  12985. * List of animations used by the particle system.
  12986. */
  12987. animations: Animation[];
  12988. /**
  12989. * The id of the Particle system.
  12990. */
  12991. id: string;
  12992. /**
  12993. * The name of the Particle system.
  12994. */
  12995. name: string;
  12996. /**
  12997. * The emitter represents the Mesh or position we are attaching the particle system to.
  12998. */
  12999. emitter: Nullable<AbstractMesh | Vector3>;
  13000. /**
  13001. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13002. */
  13003. isBillboardBased: boolean;
  13004. /**
  13005. * The rendering group used by the Particle system to chose when to render.
  13006. */
  13007. renderingGroupId: number;
  13008. /**
  13009. * The layer mask we are rendering the particles through.
  13010. */
  13011. layerMask: number;
  13012. /**
  13013. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13014. */
  13015. updateSpeed: number;
  13016. /**
  13017. * The amount of time the particle system is running (depends of the overall update speed).
  13018. */
  13019. targetStopDuration: number;
  13020. /**
  13021. * The texture used to render each particle. (this can be a spritesheet)
  13022. */
  13023. particleTexture: Nullable<Texture>;
  13024. /**
  13025. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13026. */
  13027. blendMode: number;
  13028. /**
  13029. * Minimum life time of emitting particles.
  13030. */
  13031. minLifeTime: number;
  13032. /**
  13033. * Maximum life time of emitting particles.
  13034. */
  13035. maxLifeTime: number;
  13036. /**
  13037. * Minimum Size of emitting particles.
  13038. */
  13039. minSize: number;
  13040. /**
  13041. * Maximum Size of emitting particles.
  13042. */
  13043. maxSize: number;
  13044. /**
  13045. * Minimum scale of emitting particles on X axis.
  13046. */
  13047. minScaleX: number;
  13048. /**
  13049. * Maximum scale of emitting particles on X axis.
  13050. */
  13051. maxScaleX: number;
  13052. /**
  13053. * Minimum scale of emitting particles on Y axis.
  13054. */
  13055. minScaleY: number;
  13056. /**
  13057. * Maximum scale of emitting particles on Y axis.
  13058. */
  13059. maxScaleY: number;
  13060. /**
  13061. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13062. */
  13063. color1: Color4;
  13064. /**
  13065. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13066. */
  13067. color2: Color4;
  13068. /**
  13069. * Color the particle will have at the end of its lifetime.
  13070. */
  13071. colorDead: Color4;
  13072. /**
  13073. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13074. */
  13075. emitRate: number;
  13076. /**
  13077. * You can use gravity if you want to give an orientation to your particles.
  13078. */
  13079. gravity: Vector3;
  13080. /**
  13081. * Minimum power of emitting particles.
  13082. */
  13083. minEmitPower: number;
  13084. /**
  13085. * Maximum power of emitting particles.
  13086. */
  13087. maxEmitPower: number;
  13088. /**
  13089. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13090. */
  13091. minAngularSpeed: number;
  13092. /**
  13093. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13094. */
  13095. maxAngularSpeed: number;
  13096. /**
  13097. * Gets or sets the minimal initial rotation in radians.
  13098. */
  13099. minInitialRotation: number;
  13100. /**
  13101. * Gets or sets the maximal initial rotation in radians.
  13102. */
  13103. maxInitialRotation: number;
  13104. /**
  13105. * The particle emitter type defines the emitter used by the particle system.
  13106. * It can be for example box, sphere, or cone...
  13107. */
  13108. particleEmitterType: Nullable<IParticleEmitterType>;
  13109. /**
  13110. * Defines the delay in milliseconds before starting the system (0 by default)
  13111. */
  13112. startDelay: number;
  13113. /**
  13114. * 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
  13115. */
  13116. preWarmCycles: number;
  13117. /**
  13118. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13119. */
  13120. preWarmStepOffset: number;
  13121. /**
  13122. * 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)
  13123. */
  13124. spriteCellChangeSpeed: number;
  13125. /**
  13126. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13127. */
  13128. startSpriteCellID: number;
  13129. /**
  13130. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13131. */
  13132. endSpriteCellID: number;
  13133. /**
  13134. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13135. */
  13136. spriteCellWidth: number;
  13137. /**
  13138. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13139. */
  13140. spriteCellHeight: number;
  13141. /**
  13142. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13143. */
  13144. spriteRandomStartCell: boolean;
  13145. /**
  13146. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13147. */
  13148. isAnimationSheetEnabled: boolean;
  13149. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13150. translationPivot: Vector2;
  13151. /**
  13152. * Gets or sets a texture used to add random noise to particle positions
  13153. */
  13154. noiseTexture: Nullable<BaseTexture>;
  13155. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13156. noiseStrength: Vector3;
  13157. /**
  13158. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13159. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13160. */
  13161. billboardMode: number;
  13162. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13163. limitVelocityDamping: number;
  13164. /**
  13165. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13166. */
  13167. beginAnimationOnStart: boolean;
  13168. /**
  13169. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13170. */
  13171. beginAnimationFrom: number;
  13172. /**
  13173. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13174. */
  13175. beginAnimationTo: number;
  13176. /**
  13177. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13178. */
  13179. beginAnimationLoop: boolean;
  13180. /**
  13181. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13182. */
  13183. disposeOnStop: boolean;
  13184. /**
  13185. * Specifies if the particles are updated in emitter local space or world space
  13186. */
  13187. isLocal: boolean;
  13188. /**
  13189. * Gets the maximum number of particles active at the same time.
  13190. * @returns The max number of active particles.
  13191. */
  13192. getCapacity(): number;
  13193. /**
  13194. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13195. * @returns True if it has been started, otherwise false.
  13196. */
  13197. isStarted(): boolean;
  13198. /**
  13199. * Animates the particle system for this frame.
  13200. */
  13201. animate(): void;
  13202. /**
  13203. * Renders the particle system in its current state.
  13204. * @returns the current number of particles
  13205. */
  13206. render(): number;
  13207. /**
  13208. * Dispose the particle system and frees its associated resources.
  13209. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13210. */
  13211. dispose(disposeTexture?: boolean): void;
  13212. /**
  13213. * Clones the particle system.
  13214. * @param name The name of the cloned object
  13215. * @param newEmitter The new emitter to use
  13216. * @returns the cloned particle system
  13217. */
  13218. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13219. /**
  13220. * Serializes the particle system to a JSON object.
  13221. * @returns the JSON object
  13222. */
  13223. serialize(): any;
  13224. /**
  13225. * Rebuild the particle system
  13226. */
  13227. rebuild(): void;
  13228. /**
  13229. * Starts the particle system and begins to emit
  13230. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13231. */
  13232. start(delay?: number): void;
  13233. /**
  13234. * Stops the particle system.
  13235. */
  13236. stop(): void;
  13237. /**
  13238. * Remove all active particles
  13239. */
  13240. reset(): void;
  13241. /**
  13242. * Is this system ready to be used/rendered
  13243. * @return true if the system is ready
  13244. */
  13245. isReady(): boolean;
  13246. /**
  13247. * Returns the string "ParticleSystem"
  13248. * @returns a string containing the class name
  13249. */
  13250. getClassName(): string;
  13251. /**
  13252. * Adds a new color gradient
  13253. * @param gradient defines the gradient to use (between 0 and 1)
  13254. * @param color1 defines the color to affect to the specified gradient
  13255. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13256. * @returns the current particle system
  13257. */
  13258. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13259. /**
  13260. * Remove a specific color gradient
  13261. * @param gradient defines the gradient to remove
  13262. * @returns the current particle system
  13263. */
  13264. removeColorGradient(gradient: number): IParticleSystem;
  13265. /**
  13266. * Adds a new size gradient
  13267. * @param gradient defines the gradient to use (between 0 and 1)
  13268. * @param factor defines the size factor to affect to the specified gradient
  13269. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13270. * @returns the current particle system
  13271. */
  13272. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13273. /**
  13274. * Remove a specific size gradient
  13275. * @param gradient defines the gradient to remove
  13276. * @returns the current particle system
  13277. */
  13278. removeSizeGradient(gradient: number): IParticleSystem;
  13279. /**
  13280. * Gets the current list of color gradients.
  13281. * You must use addColorGradient and removeColorGradient to udpate this list
  13282. * @returns the list of color gradients
  13283. */
  13284. getColorGradients(): Nullable<Array<ColorGradient>>;
  13285. /**
  13286. * Gets the current list of size gradients.
  13287. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13288. * @returns the list of size gradients
  13289. */
  13290. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13291. /**
  13292. * Gets the current list of angular speed gradients.
  13293. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13294. * @returns the list of angular speed gradients
  13295. */
  13296. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13297. /**
  13298. * Adds a new angular speed gradient
  13299. * @param gradient defines the gradient to use (between 0 and 1)
  13300. * @param factor defines the angular speed to affect to the specified gradient
  13301. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13302. * @returns the current particle system
  13303. */
  13304. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13305. /**
  13306. * Remove a specific angular speed gradient
  13307. * @param gradient defines the gradient to remove
  13308. * @returns the current particle system
  13309. */
  13310. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13311. /**
  13312. * Gets the current list of velocity gradients.
  13313. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13314. * @returns the list of velocity gradients
  13315. */
  13316. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13317. /**
  13318. * Adds a new velocity gradient
  13319. * @param gradient defines the gradient to use (between 0 and 1)
  13320. * @param factor defines the velocity to affect to the specified gradient
  13321. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13322. * @returns the current particle system
  13323. */
  13324. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13325. /**
  13326. * Remove a specific velocity gradient
  13327. * @param gradient defines the gradient to remove
  13328. * @returns the current particle system
  13329. */
  13330. removeVelocityGradient(gradient: number): IParticleSystem;
  13331. /**
  13332. * Gets the current list of limit velocity gradients.
  13333. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13334. * @returns the list of limit velocity gradients
  13335. */
  13336. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13337. /**
  13338. * Adds a new limit velocity gradient
  13339. * @param gradient defines the gradient to use (between 0 and 1)
  13340. * @param factor defines the limit velocity to affect to the specified gradient
  13341. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13342. * @returns the current particle system
  13343. */
  13344. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13345. /**
  13346. * Remove a specific limit velocity gradient
  13347. * @param gradient defines the gradient to remove
  13348. * @returns the current particle system
  13349. */
  13350. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13351. /**
  13352. * Adds a new drag gradient
  13353. * @param gradient defines the gradient to use (between 0 and 1)
  13354. * @param factor defines the drag to affect to the specified gradient
  13355. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13356. * @returns the current particle system
  13357. */
  13358. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13359. /**
  13360. * Remove a specific drag gradient
  13361. * @param gradient defines the gradient to remove
  13362. * @returns the current particle system
  13363. */
  13364. removeDragGradient(gradient: number): IParticleSystem;
  13365. /**
  13366. * Gets the current list of drag gradients.
  13367. * You must use addDragGradient and removeDragGradient to udpate this list
  13368. * @returns the list of drag gradients
  13369. */
  13370. getDragGradients(): Nullable<Array<FactorGradient>>;
  13371. /**
  13372. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13373. * @param gradient defines the gradient to use (between 0 and 1)
  13374. * @param factor defines the emit rate to affect to the specified gradient
  13375. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13376. * @returns the current particle system
  13377. */
  13378. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13379. /**
  13380. * Remove a specific emit rate gradient
  13381. * @param gradient defines the gradient to remove
  13382. * @returns the current particle system
  13383. */
  13384. removeEmitRateGradient(gradient: number): IParticleSystem;
  13385. /**
  13386. * Gets the current list of emit rate gradients.
  13387. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13388. * @returns the list of emit rate gradients
  13389. */
  13390. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13391. /**
  13392. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13393. * @param gradient defines the gradient to use (between 0 and 1)
  13394. * @param factor defines the start size to affect to the specified gradient
  13395. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13396. * @returns the current particle system
  13397. */
  13398. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13399. /**
  13400. * Remove a specific start size gradient
  13401. * @param gradient defines the gradient to remove
  13402. * @returns the current particle system
  13403. */
  13404. removeStartSizeGradient(gradient: number): IParticleSystem;
  13405. /**
  13406. * Gets the current list of start size gradients.
  13407. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13408. * @returns the list of start size gradients
  13409. */
  13410. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13411. /**
  13412. * Adds a new life time gradient
  13413. * @param gradient defines the gradient to use (between 0 and 1)
  13414. * @param factor defines the life time factor to affect to the specified gradient
  13415. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13416. * @returns the current particle system
  13417. */
  13418. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13419. /**
  13420. * Remove a specific life time gradient
  13421. * @param gradient defines the gradient to remove
  13422. * @returns the current particle system
  13423. */
  13424. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13425. /**
  13426. * Gets the current list of life time gradients.
  13427. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13428. * @returns the list of life time gradients
  13429. */
  13430. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13431. /**
  13432. * Gets the current list of color gradients.
  13433. * You must use addColorGradient and removeColorGradient to udpate this list
  13434. * @returns the list of color gradients
  13435. */
  13436. getColorGradients(): Nullable<Array<ColorGradient>>;
  13437. /**
  13438. * Adds a new ramp gradient used to remap particle colors
  13439. * @param gradient defines the gradient to use (between 0 and 1)
  13440. * @param color defines the color to affect to the specified gradient
  13441. * @returns the current particle system
  13442. */
  13443. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13444. /**
  13445. * Gets the current list of ramp gradients.
  13446. * You must use addRampGradient and removeRampGradient to udpate this list
  13447. * @returns the list of ramp gradients
  13448. */
  13449. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13450. /** Gets or sets a boolean indicating that ramp gradients must be used
  13451. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13452. */
  13453. useRampGradients: boolean;
  13454. /**
  13455. * Adds a new color remap gradient
  13456. * @param gradient defines the gradient to use (between 0 and 1)
  13457. * @param min defines the color remap minimal range
  13458. * @param max defines the color remap maximal range
  13459. * @returns the current particle system
  13460. */
  13461. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13462. /**
  13463. * Gets the current list of color remap gradients.
  13464. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13465. * @returns the list of color remap gradients
  13466. */
  13467. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13468. /**
  13469. * Adds a new alpha remap gradient
  13470. * @param gradient defines the gradient to use (between 0 and 1)
  13471. * @param min defines the alpha remap minimal range
  13472. * @param max defines the alpha remap maximal range
  13473. * @returns the current particle system
  13474. */
  13475. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13476. /**
  13477. * Gets the current list of alpha remap gradients.
  13478. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13479. * @returns the list of alpha remap gradients
  13480. */
  13481. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13482. /**
  13483. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13484. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13485. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13486. * @returns the emitter
  13487. */
  13488. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13489. /**
  13490. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13491. * @param radius The radius of the hemisphere to emit from
  13492. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13493. * @returns the emitter
  13494. */
  13495. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13496. /**
  13497. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13498. * @param radius The radius of the sphere to emit from
  13499. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13500. * @returns the emitter
  13501. */
  13502. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13503. /**
  13504. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13505. * @param radius The radius of the sphere to emit from
  13506. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13507. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13508. * @returns the emitter
  13509. */
  13510. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13511. /**
  13512. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13513. * @param radius The radius of the emission cylinder
  13514. * @param height The height of the emission cylinder
  13515. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13516. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13517. * @returns the emitter
  13518. */
  13519. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13520. /**
  13521. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13522. * @param radius The radius of the cylinder to emit from
  13523. * @param height The height of the emission cylinder
  13524. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13525. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13526. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13527. * @returns the emitter
  13528. */
  13529. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13530. /**
  13531. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13532. * @param radius The radius of the cone to emit from
  13533. * @param angle The base angle of the cone
  13534. * @returns the emitter
  13535. */
  13536. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13537. /**
  13538. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13539. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13540. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13541. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13542. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13543. * @returns the emitter
  13544. */
  13545. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13546. /**
  13547. * Get hosting scene
  13548. * @returns the scene
  13549. */
  13550. getScene(): Scene;
  13551. }
  13552. }
  13553. declare module BABYLON {
  13554. /**
  13555. * 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.
  13556. * @see https://doc.babylonjs.com/how_to/transformnode
  13557. */
  13558. export class TransformNode extends Node {
  13559. /**
  13560. * Object will not rotate to face the camera
  13561. */
  13562. static BILLBOARDMODE_NONE: number;
  13563. /**
  13564. * Object will rotate to face the camera but only on the x axis
  13565. */
  13566. static BILLBOARDMODE_X: number;
  13567. /**
  13568. * Object will rotate to face the camera but only on the y axis
  13569. */
  13570. static BILLBOARDMODE_Y: number;
  13571. /**
  13572. * Object will rotate to face the camera but only on the z axis
  13573. */
  13574. static BILLBOARDMODE_Z: number;
  13575. /**
  13576. * Object will rotate to face the camera
  13577. */
  13578. static BILLBOARDMODE_ALL: number;
  13579. /**
  13580. * Object will rotate to face the camera's position instead of orientation
  13581. */
  13582. static BILLBOARDMODE_USE_POSITION: number;
  13583. private _forward;
  13584. private _forwardInverted;
  13585. private _up;
  13586. private _right;
  13587. private _rightInverted;
  13588. private _position;
  13589. private _rotation;
  13590. private _rotationQuaternion;
  13591. protected _scaling: Vector3;
  13592. protected _isDirty: boolean;
  13593. private _transformToBoneReferal;
  13594. private _isAbsoluteSynced;
  13595. private _billboardMode;
  13596. /**
  13597. * Gets or sets the billboard mode. Default is 0.
  13598. *
  13599. * | Value | Type | Description |
  13600. * | --- | --- | --- |
  13601. * | 0 | BILLBOARDMODE_NONE | |
  13602. * | 1 | BILLBOARDMODE_X | |
  13603. * | 2 | BILLBOARDMODE_Y | |
  13604. * | 4 | BILLBOARDMODE_Z | |
  13605. * | 7 | BILLBOARDMODE_ALL | |
  13606. *
  13607. */
  13608. get billboardMode(): number;
  13609. set billboardMode(value: number);
  13610. private _preserveParentRotationForBillboard;
  13611. /**
  13612. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13613. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13614. */
  13615. get preserveParentRotationForBillboard(): boolean;
  13616. set preserveParentRotationForBillboard(value: boolean);
  13617. /**
  13618. * 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
  13619. */
  13620. scalingDeterminant: number;
  13621. private _infiniteDistance;
  13622. /**
  13623. * Gets or sets the distance of the object to max, often used by skybox
  13624. */
  13625. get infiniteDistance(): boolean;
  13626. set infiniteDistance(value: boolean);
  13627. /**
  13628. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13629. * By default the system will update normals to compensate
  13630. */
  13631. ignoreNonUniformScaling: boolean;
  13632. /**
  13633. * 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
  13634. */
  13635. reIntegrateRotationIntoRotationQuaternion: boolean;
  13636. /** @hidden */
  13637. _poseMatrix: Nullable<Matrix>;
  13638. /** @hidden */
  13639. _localMatrix: Matrix;
  13640. private _usePivotMatrix;
  13641. private _absolutePosition;
  13642. private _absoluteScaling;
  13643. private _absoluteRotationQuaternion;
  13644. private _pivotMatrix;
  13645. private _pivotMatrixInverse;
  13646. protected _postMultiplyPivotMatrix: boolean;
  13647. protected _isWorldMatrixFrozen: boolean;
  13648. /** @hidden */
  13649. _indexInSceneTransformNodesArray: number;
  13650. /**
  13651. * An event triggered after the world matrix is updated
  13652. */
  13653. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13654. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13655. /**
  13656. * Gets a string identifying the name of the class
  13657. * @returns "TransformNode" string
  13658. */
  13659. getClassName(): string;
  13660. /**
  13661. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13662. */
  13663. get position(): Vector3;
  13664. set position(newPosition: Vector3);
  13665. /**
  13666. * 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)).
  13667. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13668. */
  13669. get rotation(): Vector3;
  13670. set rotation(newRotation: Vector3);
  13671. /**
  13672. * 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)).
  13673. */
  13674. get scaling(): Vector3;
  13675. set scaling(newScaling: Vector3);
  13676. /**
  13677. * 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).
  13678. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13679. */
  13680. get rotationQuaternion(): Nullable<Quaternion>;
  13681. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13682. /**
  13683. * The forward direction of that transform in world space.
  13684. */
  13685. get forward(): Vector3;
  13686. /**
  13687. * The up direction of that transform in world space.
  13688. */
  13689. get up(): Vector3;
  13690. /**
  13691. * The right direction of that transform in world space.
  13692. */
  13693. get right(): Vector3;
  13694. /**
  13695. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13696. * @param matrix the matrix to copy the pose from
  13697. * @returns this TransformNode.
  13698. */
  13699. updatePoseMatrix(matrix: Matrix): TransformNode;
  13700. /**
  13701. * Returns the mesh Pose matrix.
  13702. * @returns the pose matrix
  13703. */
  13704. getPoseMatrix(): Matrix;
  13705. /** @hidden */
  13706. _isSynchronized(): boolean;
  13707. /** @hidden */
  13708. _initCache(): void;
  13709. /**
  13710. * Flag the transform node as dirty (Forcing it to update everything)
  13711. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13712. * @returns this transform node
  13713. */
  13714. markAsDirty(property: string): TransformNode;
  13715. /**
  13716. * Returns the current mesh absolute position.
  13717. * Returns a Vector3.
  13718. */
  13719. get absolutePosition(): Vector3;
  13720. /**
  13721. * Returns the current mesh absolute scaling.
  13722. * Returns a Vector3.
  13723. */
  13724. get absoluteScaling(): Vector3;
  13725. /**
  13726. * Returns the current mesh absolute rotation.
  13727. * Returns a Quaternion.
  13728. */
  13729. get absoluteRotationQuaternion(): Quaternion;
  13730. /**
  13731. * Sets a new matrix to apply before all other transformation
  13732. * @param matrix defines the transform matrix
  13733. * @returns the current TransformNode
  13734. */
  13735. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13736. /**
  13737. * Sets a new pivot matrix to the current node
  13738. * @param matrix defines the new pivot matrix to use
  13739. * @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
  13740. * @returns the current TransformNode
  13741. */
  13742. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13743. /**
  13744. * Returns the mesh pivot matrix.
  13745. * Default : Identity.
  13746. * @returns the matrix
  13747. */
  13748. getPivotMatrix(): Matrix;
  13749. /**
  13750. * Instantiate (when possible) or clone that node with its hierarchy
  13751. * @param newParent defines the new parent to use for the instance (or clone)
  13752. * @param options defines options to configure how copy is done
  13753. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13754. * @returns an instance (or a clone) of the current node with its hiearchy
  13755. */
  13756. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13757. doNotInstantiate: boolean;
  13758. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13759. /**
  13760. * Prevents the World matrix to be computed any longer
  13761. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13762. * @returns the TransformNode.
  13763. */
  13764. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13765. /**
  13766. * Allows back the World matrix computation.
  13767. * @returns the TransformNode.
  13768. */
  13769. unfreezeWorldMatrix(): this;
  13770. /**
  13771. * True if the World matrix has been frozen.
  13772. */
  13773. get isWorldMatrixFrozen(): boolean;
  13774. /**
  13775. * Retuns the mesh absolute position in the World.
  13776. * @returns a Vector3.
  13777. */
  13778. getAbsolutePosition(): Vector3;
  13779. /**
  13780. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13781. * @param absolutePosition the absolute position to set
  13782. * @returns the TransformNode.
  13783. */
  13784. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13785. /**
  13786. * Sets the mesh position in its local space.
  13787. * @param vector3 the position to set in localspace
  13788. * @returns the TransformNode.
  13789. */
  13790. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13791. /**
  13792. * Returns the mesh position in the local space from the current World matrix values.
  13793. * @returns a new Vector3.
  13794. */
  13795. getPositionExpressedInLocalSpace(): Vector3;
  13796. /**
  13797. * Translates the mesh along the passed Vector3 in its local space.
  13798. * @param vector3 the distance to translate in localspace
  13799. * @returns the TransformNode.
  13800. */
  13801. locallyTranslate(vector3: Vector3): TransformNode;
  13802. private static _lookAtVectorCache;
  13803. /**
  13804. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13805. * @param targetPoint the position (must be in same space as current mesh) to look at
  13806. * @param yawCor optional yaw (y-axis) correction in radians
  13807. * @param pitchCor optional pitch (x-axis) correction in radians
  13808. * @param rollCor optional roll (z-axis) correction in radians
  13809. * @param space the choosen space of the target
  13810. * @returns the TransformNode.
  13811. */
  13812. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13813. /**
  13814. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13815. * This Vector3 is expressed in the World space.
  13816. * @param localAxis axis to rotate
  13817. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13818. */
  13819. getDirection(localAxis: Vector3): Vector3;
  13820. /**
  13821. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13822. * localAxis is expressed in the mesh local space.
  13823. * result is computed in the Wordl space from the mesh World matrix.
  13824. * @param localAxis axis to rotate
  13825. * @param result the resulting transformnode
  13826. * @returns this TransformNode.
  13827. */
  13828. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13829. /**
  13830. * Sets this transform node rotation to the given local axis.
  13831. * @param localAxis the axis in local space
  13832. * @param yawCor optional yaw (y-axis) correction in radians
  13833. * @param pitchCor optional pitch (x-axis) correction in radians
  13834. * @param rollCor optional roll (z-axis) correction in radians
  13835. * @returns this TransformNode
  13836. */
  13837. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13838. /**
  13839. * Sets a new pivot point to the current node
  13840. * @param point defines the new pivot point to use
  13841. * @param space defines if the point is in world or local space (local by default)
  13842. * @returns the current TransformNode
  13843. */
  13844. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13845. /**
  13846. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13847. * @returns the pivot point
  13848. */
  13849. getPivotPoint(): Vector3;
  13850. /**
  13851. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13852. * @param result the vector3 to store the result
  13853. * @returns this TransformNode.
  13854. */
  13855. getPivotPointToRef(result: Vector3): TransformNode;
  13856. /**
  13857. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13858. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13859. */
  13860. getAbsolutePivotPoint(): Vector3;
  13861. /**
  13862. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13863. * @param result vector3 to store the result
  13864. * @returns this TransformNode.
  13865. */
  13866. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13867. /**
  13868. * Defines the passed node as the parent of the current node.
  13869. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13870. * @see https://doc.babylonjs.com/how_to/parenting
  13871. * @param node the node ot set as the parent
  13872. * @returns this TransformNode.
  13873. */
  13874. setParent(node: Nullable<Node>): TransformNode;
  13875. private _nonUniformScaling;
  13876. /**
  13877. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13878. */
  13879. get nonUniformScaling(): boolean;
  13880. /** @hidden */
  13881. _updateNonUniformScalingState(value: boolean): boolean;
  13882. /**
  13883. * Attach the current TransformNode to another TransformNode associated with a bone
  13884. * @param bone Bone affecting the TransformNode
  13885. * @param affectedTransformNode TransformNode associated with the bone
  13886. * @returns this object
  13887. */
  13888. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13889. /**
  13890. * Detach the transform node if its associated with a bone
  13891. * @returns this object
  13892. */
  13893. detachFromBone(): TransformNode;
  13894. private static _rotationAxisCache;
  13895. /**
  13896. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13897. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13898. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13899. * The passed axis is also normalized.
  13900. * @param axis the axis to rotate around
  13901. * @param amount the amount to rotate in radians
  13902. * @param space Space to rotate in (Default: local)
  13903. * @returns the TransformNode.
  13904. */
  13905. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13906. /**
  13907. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13908. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13909. * The passed axis is also normalized. .
  13910. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13911. * @param point the point to rotate around
  13912. * @param axis the axis to rotate around
  13913. * @param amount the amount to rotate in radians
  13914. * @returns the TransformNode
  13915. */
  13916. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13917. /**
  13918. * Translates the mesh along the axis vector for the passed distance in the given space.
  13919. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13920. * @param axis the axis to translate in
  13921. * @param distance the distance to translate
  13922. * @param space Space to rotate in (Default: local)
  13923. * @returns the TransformNode.
  13924. */
  13925. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13926. /**
  13927. * Adds a rotation step to the mesh current rotation.
  13928. * x, y, z are Euler angles expressed in radians.
  13929. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  13930. * This means this rotation is made in the mesh local space only.
  13931. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  13932. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  13933. * ```javascript
  13934. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  13935. * ```
  13936. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  13937. * 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.
  13938. * @param x Rotation to add
  13939. * @param y Rotation to add
  13940. * @param z Rotation to add
  13941. * @returns the TransformNode.
  13942. */
  13943. addRotation(x: number, y: number, z: number): TransformNode;
  13944. /**
  13945. * @hidden
  13946. */
  13947. protected _getEffectiveParent(): Nullable<Node>;
  13948. /**
  13949. * Computes the world matrix of the node
  13950. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13951. * @returns the world matrix
  13952. */
  13953. computeWorldMatrix(force?: boolean): Matrix;
  13954. /**
  13955. * Resets this nodeTransform's local matrix to Matrix.Identity().
  13956. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  13957. */
  13958. resetLocalMatrix(independentOfChildren?: boolean): void;
  13959. protected _afterComputeWorldMatrix(): void;
  13960. /**
  13961. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  13962. * @param func callback function to add
  13963. *
  13964. * @returns the TransformNode.
  13965. */
  13966. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13967. /**
  13968. * Removes a registered callback function.
  13969. * @param func callback function to remove
  13970. * @returns the TransformNode.
  13971. */
  13972. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13973. /**
  13974. * Gets the position of the current mesh in camera space
  13975. * @param camera defines the camera to use
  13976. * @returns a position
  13977. */
  13978. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  13979. /**
  13980. * Returns the distance from the mesh to the active camera
  13981. * @param camera defines the camera to use
  13982. * @returns the distance
  13983. */
  13984. getDistanceToCamera(camera?: Nullable<Camera>): number;
  13985. /**
  13986. * Clone the current transform node
  13987. * @param name Name of the new clone
  13988. * @param newParent New parent for the clone
  13989. * @param doNotCloneChildren Do not clone children hierarchy
  13990. * @returns the new transform node
  13991. */
  13992. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  13993. /**
  13994. * Serializes the objects information.
  13995. * @param currentSerializationObject defines the object to serialize in
  13996. * @returns the serialized object
  13997. */
  13998. serialize(currentSerializationObject?: any): any;
  13999. /**
  14000. * Returns a new TransformNode object parsed from the source provided.
  14001. * @param parsedTransformNode is the source.
  14002. * @param scene the scne the object belongs to
  14003. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14004. * @returns a new TransformNode object parsed from the source provided.
  14005. */
  14006. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14007. /**
  14008. * Get all child-transformNodes of this node
  14009. * @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
  14010. * @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
  14011. * @returns an array of TransformNode
  14012. */
  14013. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14014. /**
  14015. * Releases resources associated with this transform node.
  14016. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14017. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14018. */
  14019. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14020. /**
  14021. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14022. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14023. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14024. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14025. * @returns the current mesh
  14026. */
  14027. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14028. private _syncAbsoluteScalingAndRotation;
  14029. }
  14030. }
  14031. declare module BABYLON {
  14032. /**
  14033. * Class used to override all child animations of a given target
  14034. */
  14035. export class AnimationPropertiesOverride {
  14036. /**
  14037. * Gets or sets a value indicating if animation blending must be used
  14038. */
  14039. enableBlending: boolean;
  14040. /**
  14041. * Gets or sets the blending speed to use when enableBlending is true
  14042. */
  14043. blendingSpeed: number;
  14044. /**
  14045. * Gets or sets the default loop mode to use
  14046. */
  14047. loopMode: number;
  14048. }
  14049. }
  14050. declare module BABYLON {
  14051. /**
  14052. * Class used to store bone information
  14053. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14054. */
  14055. export class Bone extends Node {
  14056. /**
  14057. * defines the bone name
  14058. */
  14059. name: string;
  14060. private static _tmpVecs;
  14061. private static _tmpQuat;
  14062. private static _tmpMats;
  14063. /**
  14064. * Gets the list of child bones
  14065. */
  14066. children: Bone[];
  14067. /** Gets the animations associated with this bone */
  14068. animations: Animation[];
  14069. /**
  14070. * Gets or sets bone length
  14071. */
  14072. length: number;
  14073. /**
  14074. * @hidden Internal only
  14075. * Set this value to map this bone to a different index in the transform matrices
  14076. * Set this value to -1 to exclude the bone from the transform matrices
  14077. */
  14078. _index: Nullable<number>;
  14079. private _skeleton;
  14080. private _localMatrix;
  14081. private _restPose;
  14082. private _baseMatrix;
  14083. private _absoluteTransform;
  14084. private _invertedAbsoluteTransform;
  14085. private _parent;
  14086. private _scalingDeterminant;
  14087. private _worldTransform;
  14088. private _localScaling;
  14089. private _localRotation;
  14090. private _localPosition;
  14091. private _needToDecompose;
  14092. private _needToCompose;
  14093. /** @hidden */
  14094. _linkedTransformNode: Nullable<TransformNode>;
  14095. /** @hidden */
  14096. _waitingTransformNodeId: Nullable<string>;
  14097. /** @hidden */
  14098. get _matrix(): Matrix;
  14099. /** @hidden */
  14100. set _matrix(value: Matrix);
  14101. /**
  14102. * Create a new bone
  14103. * @param name defines the bone name
  14104. * @param skeleton defines the parent skeleton
  14105. * @param parentBone defines the parent (can be null if the bone is the root)
  14106. * @param localMatrix defines the local matrix
  14107. * @param restPose defines the rest pose matrix
  14108. * @param baseMatrix defines the base matrix
  14109. * @param index defines index of the bone in the hiearchy
  14110. */
  14111. constructor(
  14112. /**
  14113. * defines the bone name
  14114. */
  14115. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14116. /**
  14117. * Gets the current object class name.
  14118. * @return the class name
  14119. */
  14120. getClassName(): string;
  14121. /**
  14122. * Gets the parent skeleton
  14123. * @returns a skeleton
  14124. */
  14125. getSkeleton(): Skeleton;
  14126. /**
  14127. * Gets parent bone
  14128. * @returns a bone or null if the bone is the root of the bone hierarchy
  14129. */
  14130. getParent(): Nullable<Bone>;
  14131. /**
  14132. * Returns an array containing the root bones
  14133. * @returns an array containing the root bones
  14134. */
  14135. getChildren(): Array<Bone>;
  14136. /**
  14137. * Gets the node index in matrix array generated for rendering
  14138. * @returns the node index
  14139. */
  14140. getIndex(): number;
  14141. /**
  14142. * Sets the parent bone
  14143. * @param parent defines the parent (can be null if the bone is the root)
  14144. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14145. */
  14146. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14147. /**
  14148. * Gets the local matrix
  14149. * @returns a matrix
  14150. */
  14151. getLocalMatrix(): Matrix;
  14152. /**
  14153. * Gets the base matrix (initial matrix which remains unchanged)
  14154. * @returns a matrix
  14155. */
  14156. getBaseMatrix(): Matrix;
  14157. /**
  14158. * Gets the rest pose matrix
  14159. * @returns a matrix
  14160. */
  14161. getRestPose(): Matrix;
  14162. /**
  14163. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14164. */
  14165. getWorldMatrix(): Matrix;
  14166. /**
  14167. * Sets the local matrix to rest pose matrix
  14168. */
  14169. returnToRest(): void;
  14170. /**
  14171. * Gets the inverse of the absolute transform matrix.
  14172. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14173. * @returns a matrix
  14174. */
  14175. getInvertedAbsoluteTransform(): Matrix;
  14176. /**
  14177. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14178. * @returns a matrix
  14179. */
  14180. getAbsoluteTransform(): Matrix;
  14181. /**
  14182. * Links with the given transform node.
  14183. * The local matrix of this bone is copied from the transform node every frame.
  14184. * @param transformNode defines the transform node to link to
  14185. */
  14186. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14187. /**
  14188. * Gets the node used to drive the bone's transformation
  14189. * @returns a transform node or null
  14190. */
  14191. getTransformNode(): Nullable<TransformNode>;
  14192. /** Gets or sets current position (in local space) */
  14193. get position(): Vector3;
  14194. set position(newPosition: Vector3);
  14195. /** Gets or sets current rotation (in local space) */
  14196. get rotation(): Vector3;
  14197. set rotation(newRotation: Vector3);
  14198. /** Gets or sets current rotation quaternion (in local space) */
  14199. get rotationQuaternion(): Quaternion;
  14200. set rotationQuaternion(newRotation: Quaternion);
  14201. /** Gets or sets current scaling (in local space) */
  14202. get scaling(): Vector3;
  14203. set scaling(newScaling: Vector3);
  14204. /**
  14205. * Gets the animation properties override
  14206. */
  14207. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14208. private _decompose;
  14209. private _compose;
  14210. /**
  14211. * Update the base and local matrices
  14212. * @param matrix defines the new base or local matrix
  14213. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14214. * @param updateLocalMatrix defines if the local matrix should be updated
  14215. */
  14216. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14217. /** @hidden */
  14218. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14219. /**
  14220. * Flag the bone as dirty (Forcing it to update everything)
  14221. */
  14222. markAsDirty(): void;
  14223. /** @hidden */
  14224. _markAsDirtyAndCompose(): void;
  14225. private _markAsDirtyAndDecompose;
  14226. /**
  14227. * Translate the bone in local or world space
  14228. * @param vec The amount to translate the bone
  14229. * @param space The space that the translation is in
  14230. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14231. */
  14232. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14233. /**
  14234. * Set the postion of the bone in local or world space
  14235. * @param position The position to set the bone
  14236. * @param space The space that the position is in
  14237. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14238. */
  14239. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14240. /**
  14241. * Set the absolute position of the bone (world space)
  14242. * @param position The position to set the bone
  14243. * @param mesh The mesh that this bone is attached to
  14244. */
  14245. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14246. /**
  14247. * Scale the bone on the x, y and z axes (in local space)
  14248. * @param x The amount to scale the bone on the x axis
  14249. * @param y The amount to scale the bone on the y axis
  14250. * @param z The amount to scale the bone on the z axis
  14251. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14252. */
  14253. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14254. /**
  14255. * Set the bone scaling in local space
  14256. * @param scale defines the scaling vector
  14257. */
  14258. setScale(scale: Vector3): void;
  14259. /**
  14260. * Gets the current scaling in local space
  14261. * @returns the current scaling vector
  14262. */
  14263. getScale(): Vector3;
  14264. /**
  14265. * Gets the current scaling in local space and stores it in a target vector
  14266. * @param result defines the target vector
  14267. */
  14268. getScaleToRef(result: Vector3): void;
  14269. /**
  14270. * Set the yaw, pitch, and roll of the bone in local or world space
  14271. * @param yaw The rotation of the bone on the y axis
  14272. * @param pitch The rotation of the bone on the x axis
  14273. * @param roll The rotation of the bone on the z axis
  14274. * @param space The space that the axes of rotation are in
  14275. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14276. */
  14277. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14278. /**
  14279. * Add a rotation to the bone on an axis in local or world space
  14280. * @param axis The axis to rotate the bone on
  14281. * @param amount The amount to rotate the bone
  14282. * @param space The space that the axis is in
  14283. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14284. */
  14285. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14286. /**
  14287. * Set the rotation of the bone to a particular axis angle in local or world space
  14288. * @param axis The axis to rotate the bone on
  14289. * @param angle The angle that the bone should be rotated to
  14290. * @param space The space that the axis is in
  14291. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14292. */
  14293. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14294. /**
  14295. * Set the euler rotation of the bone in local of world space
  14296. * @param rotation The euler rotation that the bone should be set to
  14297. * @param space The space that the rotation is in
  14298. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14299. */
  14300. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14301. /**
  14302. * Set the quaternion rotation of the bone in local of world space
  14303. * @param quat The quaternion rotation that the bone should be set to
  14304. * @param space The space that the rotation is in
  14305. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14306. */
  14307. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14308. /**
  14309. * Set the rotation matrix of the bone in local of world space
  14310. * @param rotMat The rotation matrix that the bone should be set to
  14311. * @param space The space that the rotation is in
  14312. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14313. */
  14314. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14315. private _rotateWithMatrix;
  14316. private _getNegativeRotationToRef;
  14317. /**
  14318. * Get the position of the bone in local or world space
  14319. * @param space The space that the returned position is in
  14320. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14321. * @returns The position of the bone
  14322. */
  14323. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14324. /**
  14325. * Copy the position of the bone to a vector3 in local or world space
  14326. * @param space The space that the returned position is in
  14327. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14328. * @param result The vector3 to copy the position to
  14329. */
  14330. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14331. /**
  14332. * Get the absolute position of the bone (world space)
  14333. * @param mesh The mesh that this bone is attached to
  14334. * @returns The absolute position of the bone
  14335. */
  14336. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14337. /**
  14338. * Copy the absolute position of the bone (world space) to the result param
  14339. * @param mesh The mesh that this bone is attached to
  14340. * @param result The vector3 to copy the absolute position to
  14341. */
  14342. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14343. /**
  14344. * Compute the absolute transforms of this bone and its children
  14345. */
  14346. computeAbsoluteTransforms(): void;
  14347. /**
  14348. * Get the world direction from an axis that is in the local space of the bone
  14349. * @param localAxis The local direction that is used to compute the world direction
  14350. * @param mesh The mesh that this bone is attached to
  14351. * @returns The world direction
  14352. */
  14353. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14354. /**
  14355. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14356. * @param localAxis The local direction that is used to compute the world direction
  14357. * @param mesh The mesh that this bone is attached to
  14358. * @param result The vector3 that the world direction will be copied to
  14359. */
  14360. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14361. /**
  14362. * Get the euler rotation of the bone in local or world space
  14363. * @param space The space that the rotation should be in
  14364. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14365. * @returns The euler rotation
  14366. */
  14367. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14368. /**
  14369. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14370. * @param space The space that the rotation should be in
  14371. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14372. * @param result The vector3 that the rotation should be copied to
  14373. */
  14374. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14375. /**
  14376. * Get the quaternion rotation of the bone in either local or world space
  14377. * @param space The space that the rotation should be in
  14378. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14379. * @returns The quaternion rotation
  14380. */
  14381. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14382. /**
  14383. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14384. * @param space The space that the rotation should be in
  14385. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14386. * @param result The quaternion that the rotation should be copied to
  14387. */
  14388. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14389. /**
  14390. * Get the rotation matrix of the bone in local or world space
  14391. * @param space The space that the rotation should be in
  14392. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14393. * @returns The rotation matrix
  14394. */
  14395. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14396. /**
  14397. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14398. * @param space The space that the rotation should be in
  14399. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14400. * @param result The quaternion that the rotation should be copied to
  14401. */
  14402. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14403. /**
  14404. * Get the world position of a point that is in the local space of the bone
  14405. * @param position The local position
  14406. * @param mesh The mesh that this bone is attached to
  14407. * @returns The world position
  14408. */
  14409. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14410. /**
  14411. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14412. * @param position The local position
  14413. * @param mesh The mesh that this bone is attached to
  14414. * @param result The vector3 that the world position should be copied to
  14415. */
  14416. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14417. /**
  14418. * Get the local position of a point that is in world space
  14419. * @param position The world position
  14420. * @param mesh The mesh that this bone is attached to
  14421. * @returns The local position
  14422. */
  14423. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14424. /**
  14425. * Get the local position of a point that is in world space and copy it to the result param
  14426. * @param position The world position
  14427. * @param mesh The mesh that this bone is attached to
  14428. * @param result The vector3 that the local position should be copied to
  14429. */
  14430. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14431. }
  14432. }
  14433. declare module BABYLON {
  14434. /**
  14435. * Defines a runtime animation
  14436. */
  14437. export class RuntimeAnimation {
  14438. private _events;
  14439. /**
  14440. * The current frame of the runtime animation
  14441. */
  14442. private _currentFrame;
  14443. /**
  14444. * The animation used by the runtime animation
  14445. */
  14446. private _animation;
  14447. /**
  14448. * The target of the runtime animation
  14449. */
  14450. private _target;
  14451. /**
  14452. * The initiating animatable
  14453. */
  14454. private _host;
  14455. /**
  14456. * The original value of the runtime animation
  14457. */
  14458. private _originalValue;
  14459. /**
  14460. * The original blend value of the runtime animation
  14461. */
  14462. private _originalBlendValue;
  14463. /**
  14464. * The offsets cache of the runtime animation
  14465. */
  14466. private _offsetsCache;
  14467. /**
  14468. * The high limits cache of the runtime animation
  14469. */
  14470. private _highLimitsCache;
  14471. /**
  14472. * Specifies if the runtime animation has been stopped
  14473. */
  14474. private _stopped;
  14475. /**
  14476. * The blending factor of the runtime animation
  14477. */
  14478. private _blendingFactor;
  14479. /**
  14480. * The BabylonJS scene
  14481. */
  14482. private _scene;
  14483. /**
  14484. * The current value of the runtime animation
  14485. */
  14486. private _currentValue;
  14487. /** @hidden */
  14488. _animationState: _IAnimationState;
  14489. /**
  14490. * The active target of the runtime animation
  14491. */
  14492. private _activeTargets;
  14493. private _currentActiveTarget;
  14494. private _directTarget;
  14495. /**
  14496. * The target path of the runtime animation
  14497. */
  14498. private _targetPath;
  14499. /**
  14500. * The weight of the runtime animation
  14501. */
  14502. private _weight;
  14503. /**
  14504. * The ratio offset of the runtime animation
  14505. */
  14506. private _ratioOffset;
  14507. /**
  14508. * The previous delay of the runtime animation
  14509. */
  14510. private _previousDelay;
  14511. /**
  14512. * The previous ratio of the runtime animation
  14513. */
  14514. private _previousRatio;
  14515. private _enableBlending;
  14516. private _keys;
  14517. private _minFrame;
  14518. private _maxFrame;
  14519. private _minValue;
  14520. private _maxValue;
  14521. private _targetIsArray;
  14522. /**
  14523. * Gets the current frame of the runtime animation
  14524. */
  14525. get currentFrame(): number;
  14526. /**
  14527. * Gets the weight of the runtime animation
  14528. */
  14529. get weight(): number;
  14530. /**
  14531. * Gets the current value of the runtime animation
  14532. */
  14533. get currentValue(): any;
  14534. /**
  14535. * Gets the target path of the runtime animation
  14536. */
  14537. get targetPath(): string;
  14538. /**
  14539. * Gets the actual target of the runtime animation
  14540. */
  14541. get target(): any;
  14542. /**
  14543. * Gets the additive state of the runtime animation
  14544. */
  14545. get isAdditive(): boolean;
  14546. /** @hidden */
  14547. _onLoop: () => void;
  14548. /**
  14549. * Create a new RuntimeAnimation object
  14550. * @param target defines the target of the animation
  14551. * @param animation defines the source animation object
  14552. * @param scene defines the hosting scene
  14553. * @param host defines the initiating Animatable
  14554. */
  14555. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14556. private _preparePath;
  14557. /**
  14558. * Gets the animation from the runtime animation
  14559. */
  14560. get animation(): Animation;
  14561. /**
  14562. * Resets the runtime animation to the beginning
  14563. * @param restoreOriginal defines whether to restore the target property to the original value
  14564. */
  14565. reset(restoreOriginal?: boolean): void;
  14566. /**
  14567. * Specifies if the runtime animation is stopped
  14568. * @returns Boolean specifying if the runtime animation is stopped
  14569. */
  14570. isStopped(): boolean;
  14571. /**
  14572. * Disposes of the runtime animation
  14573. */
  14574. dispose(): void;
  14575. /**
  14576. * Apply the interpolated value to the target
  14577. * @param currentValue defines the value computed by the animation
  14578. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14579. */
  14580. setValue(currentValue: any, weight: number): void;
  14581. private _getOriginalValues;
  14582. private _setValue;
  14583. /**
  14584. * Gets the loop pmode of the runtime animation
  14585. * @returns Loop Mode
  14586. */
  14587. private _getCorrectLoopMode;
  14588. /**
  14589. * Move the current animation to a given frame
  14590. * @param frame defines the frame to move to
  14591. */
  14592. goToFrame(frame: number): void;
  14593. /**
  14594. * @hidden Internal use only
  14595. */
  14596. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14597. /**
  14598. * Execute the current animation
  14599. * @param delay defines the delay to add to the current frame
  14600. * @param from defines the lower bound of the animation range
  14601. * @param to defines the upper bound of the animation range
  14602. * @param loop defines if the current animation must loop
  14603. * @param speedRatio defines the current speed ratio
  14604. * @param weight defines the weight of the animation (default is -1 so no weight)
  14605. * @param onLoop optional callback called when animation loops
  14606. * @returns a boolean indicating if the animation is running
  14607. */
  14608. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14609. }
  14610. }
  14611. declare module BABYLON {
  14612. /**
  14613. * Class used to store an actual running animation
  14614. */
  14615. export class Animatable {
  14616. /** defines the target object */
  14617. target: any;
  14618. /** defines the starting frame number (default is 0) */
  14619. fromFrame: number;
  14620. /** defines the ending frame number (default is 100) */
  14621. toFrame: number;
  14622. /** defines if the animation must loop (default is false) */
  14623. loopAnimation: boolean;
  14624. /** defines a callback to call when animation ends if it is not looping */
  14625. onAnimationEnd?: (() => void) | null | undefined;
  14626. /** defines a callback to call when animation loops */
  14627. onAnimationLoop?: (() => void) | null | undefined;
  14628. /** defines whether the animation should be evaluated additively */
  14629. isAdditive: boolean;
  14630. private _localDelayOffset;
  14631. private _pausedDelay;
  14632. private _runtimeAnimations;
  14633. private _paused;
  14634. private _scene;
  14635. private _speedRatio;
  14636. private _weight;
  14637. private _syncRoot;
  14638. /**
  14639. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14640. * This will only apply for non looping animation (default is true)
  14641. */
  14642. disposeOnEnd: boolean;
  14643. /**
  14644. * Gets a boolean indicating if the animation has started
  14645. */
  14646. animationStarted: boolean;
  14647. /**
  14648. * Observer raised when the animation ends
  14649. */
  14650. onAnimationEndObservable: Observable<Animatable>;
  14651. /**
  14652. * Observer raised when the animation loops
  14653. */
  14654. onAnimationLoopObservable: Observable<Animatable>;
  14655. /**
  14656. * Gets the root Animatable used to synchronize and normalize animations
  14657. */
  14658. get syncRoot(): Nullable<Animatable>;
  14659. /**
  14660. * Gets the current frame of the first RuntimeAnimation
  14661. * Used to synchronize Animatables
  14662. */
  14663. get masterFrame(): number;
  14664. /**
  14665. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14666. */
  14667. get weight(): number;
  14668. set weight(value: number);
  14669. /**
  14670. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14671. */
  14672. get speedRatio(): number;
  14673. set speedRatio(value: number);
  14674. /**
  14675. * Creates a new Animatable
  14676. * @param scene defines the hosting scene
  14677. * @param target defines the target object
  14678. * @param fromFrame defines the starting frame number (default is 0)
  14679. * @param toFrame defines the ending frame number (default is 100)
  14680. * @param loopAnimation defines if the animation must loop (default is false)
  14681. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14682. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14683. * @param animations defines a group of animation to add to the new Animatable
  14684. * @param onAnimationLoop defines a callback to call when animation loops
  14685. * @param isAdditive defines whether the animation should be evaluated additively
  14686. */
  14687. constructor(scene: Scene,
  14688. /** defines the target object */
  14689. target: any,
  14690. /** defines the starting frame number (default is 0) */
  14691. fromFrame?: number,
  14692. /** defines the ending frame number (default is 100) */
  14693. toFrame?: number,
  14694. /** defines if the animation must loop (default is false) */
  14695. loopAnimation?: boolean, speedRatio?: number,
  14696. /** defines a callback to call when animation ends if it is not looping */
  14697. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14698. /** defines a callback to call when animation loops */
  14699. onAnimationLoop?: (() => void) | null | undefined,
  14700. /** defines whether the animation should be evaluated additively */
  14701. isAdditive?: boolean);
  14702. /**
  14703. * Synchronize and normalize current Animatable with a source Animatable
  14704. * This is useful when using animation weights and when animations are not of the same length
  14705. * @param root defines the root Animatable to synchronize with
  14706. * @returns the current Animatable
  14707. */
  14708. syncWith(root: Animatable): Animatable;
  14709. /**
  14710. * Gets the list of runtime animations
  14711. * @returns an array of RuntimeAnimation
  14712. */
  14713. getAnimations(): RuntimeAnimation[];
  14714. /**
  14715. * Adds more animations to the current animatable
  14716. * @param target defines the target of the animations
  14717. * @param animations defines the new animations to add
  14718. */
  14719. appendAnimations(target: any, animations: Animation[]): void;
  14720. /**
  14721. * Gets the source animation for a specific property
  14722. * @param property defines the propertyu to look for
  14723. * @returns null or the source animation for the given property
  14724. */
  14725. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14726. /**
  14727. * Gets the runtime animation for a specific property
  14728. * @param property defines the propertyu to look for
  14729. * @returns null or the runtime animation for the given property
  14730. */
  14731. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14732. /**
  14733. * Resets the animatable to its original state
  14734. */
  14735. reset(): void;
  14736. /**
  14737. * Allows the animatable to blend with current running animations
  14738. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14739. * @param blendingSpeed defines the blending speed to use
  14740. */
  14741. enableBlending(blendingSpeed: number): void;
  14742. /**
  14743. * Disable animation blending
  14744. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14745. */
  14746. disableBlending(): void;
  14747. /**
  14748. * Jump directly to a given frame
  14749. * @param frame defines the frame to jump to
  14750. */
  14751. goToFrame(frame: number): void;
  14752. /**
  14753. * Pause the animation
  14754. */
  14755. pause(): void;
  14756. /**
  14757. * Restart the animation
  14758. */
  14759. restart(): void;
  14760. private _raiseOnAnimationEnd;
  14761. /**
  14762. * Stop and delete the current animation
  14763. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14764. * @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)
  14765. */
  14766. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14767. /**
  14768. * Wait asynchronously for the animation to end
  14769. * @returns a promise which will be fullfilled when the animation ends
  14770. */
  14771. waitAsync(): Promise<Animatable>;
  14772. /** @hidden */
  14773. _animate(delay: number): boolean;
  14774. }
  14775. interface Scene {
  14776. /** @hidden */
  14777. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  14778. /** @hidden */
  14779. _processLateAnimationBindingsForMatrices(holder: {
  14780. totalWeight: number;
  14781. totalAdditiveWeight: number;
  14782. animations: RuntimeAnimation[];
  14783. additiveAnimations: RuntimeAnimation[];
  14784. originalValue: Matrix;
  14785. }): any;
  14786. /** @hidden */
  14787. _processLateAnimationBindingsForQuaternions(holder: {
  14788. totalWeight: number;
  14789. totalAdditiveWeight: number;
  14790. animations: RuntimeAnimation[];
  14791. additiveAnimations: RuntimeAnimation[];
  14792. originalValue: Quaternion;
  14793. }, refQuaternion: Quaternion): Quaternion;
  14794. /** @hidden */
  14795. _processLateAnimationBindings(): void;
  14796. /**
  14797. * Will start the animation sequence of a given target
  14798. * @param target defines the target
  14799. * @param from defines from which frame should animation start
  14800. * @param to defines until which frame should animation run.
  14801. * @param weight defines the weight to apply to the animation (1.0 by default)
  14802. * @param loop defines if the animation loops
  14803. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14804. * @param onAnimationEnd defines the function to be executed when the animation ends
  14805. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14806. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14807. * @param onAnimationLoop defines the callback to call when an animation loops
  14808. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14809. * @returns the animatable object created for this animation
  14810. */
  14811. 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;
  14812. /**
  14813. * Will start the animation sequence of a given target
  14814. * @param target defines the target
  14815. * @param from defines from which frame should animation start
  14816. * @param to defines until which frame should animation run.
  14817. * @param loop defines if the animation loops
  14818. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14819. * @param onAnimationEnd defines the function to be executed when the animation ends
  14820. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14821. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14822. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  14823. * @param onAnimationLoop defines the callback to call when an animation loops
  14824. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14825. * @returns the animatable object created for this animation
  14826. */
  14827. 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;
  14828. /**
  14829. * Will start the animation sequence of a given target and its hierarchy
  14830. * @param target defines the target
  14831. * @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.
  14832. * @param from defines from which frame should animation start
  14833. * @param to defines until which frame should animation run.
  14834. * @param loop defines if the animation loops
  14835. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14836. * @param onAnimationEnd defines the function to be executed when the animation ends
  14837. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14838. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14839. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14840. * @param onAnimationLoop defines the callback to call when an animation loops
  14841. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14842. * @returns the list of created animatables
  14843. */
  14844. 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[];
  14845. /**
  14846. * Begin a new animation on a given node
  14847. * @param target defines the target where the animation will take place
  14848. * @param animations defines the list of animations to start
  14849. * @param from defines the initial value
  14850. * @param to defines the final value
  14851. * @param loop defines if you want animation to loop (off by default)
  14852. * @param speedRatio defines the speed ratio to apply to all animations
  14853. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14854. * @param onAnimationLoop defines the callback to call when an animation loops
  14855. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14856. * @returns the list of created animatables
  14857. */
  14858. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  14859. /**
  14860. * Begin a new animation on a given node and its hierarchy
  14861. * @param target defines the root node where the animation will take place
  14862. * @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.
  14863. * @param animations defines the list of animations to start
  14864. * @param from defines the initial value
  14865. * @param to defines the final value
  14866. * @param loop defines if you want animation to loop (off by default)
  14867. * @param speedRatio defines the speed ratio to apply to all animations
  14868. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14869. * @param onAnimationLoop defines the callback to call when an animation loops
  14870. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14871. * @returns the list of animatables created for all nodes
  14872. */
  14873. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  14874. /**
  14875. * Gets the animatable associated with a specific target
  14876. * @param target defines the target of the animatable
  14877. * @returns the required animatable if found
  14878. */
  14879. getAnimatableByTarget(target: any): Nullable<Animatable>;
  14880. /**
  14881. * Gets all animatables associated with a given target
  14882. * @param target defines the target to look animatables for
  14883. * @returns an array of Animatables
  14884. */
  14885. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  14886. /**
  14887. * Stops and removes all animations that have been applied to the scene
  14888. */
  14889. stopAllAnimations(): void;
  14890. /**
  14891. * Gets the current delta time used by animation engine
  14892. */
  14893. deltaTime: number;
  14894. }
  14895. interface Bone {
  14896. /**
  14897. * Copy an animation range from another bone
  14898. * @param source defines the source bone
  14899. * @param rangeName defines the range name to copy
  14900. * @param frameOffset defines the frame offset
  14901. * @param rescaleAsRequired defines if rescaling must be applied if required
  14902. * @param skelDimensionsRatio defines the scaling ratio
  14903. * @returns true if operation was successful
  14904. */
  14905. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  14906. }
  14907. }
  14908. declare module BABYLON {
  14909. /**
  14910. * Class used to handle skinning animations
  14911. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14912. */
  14913. export class Skeleton implements IAnimatable {
  14914. /** defines the skeleton name */
  14915. name: string;
  14916. /** defines the skeleton Id */
  14917. id: string;
  14918. /**
  14919. * Defines the list of child bones
  14920. */
  14921. bones: Bone[];
  14922. /**
  14923. * Defines an estimate of the dimension of the skeleton at rest
  14924. */
  14925. dimensionsAtRest: Vector3;
  14926. /**
  14927. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  14928. */
  14929. needInitialSkinMatrix: boolean;
  14930. /**
  14931. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  14932. */
  14933. overrideMesh: Nullable<AbstractMesh>;
  14934. /**
  14935. * Gets the list of animations attached to this skeleton
  14936. */
  14937. animations: Array<Animation>;
  14938. private _scene;
  14939. private _isDirty;
  14940. private _transformMatrices;
  14941. private _transformMatrixTexture;
  14942. private _meshesWithPoseMatrix;
  14943. private _animatables;
  14944. private _identity;
  14945. private _synchronizedWithMesh;
  14946. private _ranges;
  14947. private _lastAbsoluteTransformsUpdateId;
  14948. private _canUseTextureForBones;
  14949. private _uniqueId;
  14950. /** @hidden */
  14951. _numBonesWithLinkedTransformNode: number;
  14952. /** @hidden */
  14953. _hasWaitingData: Nullable<boolean>;
  14954. /**
  14955. * Specifies if the skeleton should be serialized
  14956. */
  14957. doNotSerialize: boolean;
  14958. private _useTextureToStoreBoneMatrices;
  14959. /**
  14960. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  14961. * Please note that this option is not available if the hardware does not support it
  14962. */
  14963. get useTextureToStoreBoneMatrices(): boolean;
  14964. set useTextureToStoreBoneMatrices(value: boolean);
  14965. private _animationPropertiesOverride;
  14966. /**
  14967. * Gets or sets the animation properties override
  14968. */
  14969. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14970. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  14971. /**
  14972. * List of inspectable custom properties (used by the Inspector)
  14973. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  14974. */
  14975. inspectableCustomProperties: IInspectable[];
  14976. /**
  14977. * An observable triggered before computing the skeleton's matrices
  14978. */
  14979. onBeforeComputeObservable: Observable<Skeleton>;
  14980. /**
  14981. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  14982. */
  14983. get isUsingTextureForMatrices(): boolean;
  14984. /**
  14985. * Gets the unique ID of this skeleton
  14986. */
  14987. get uniqueId(): number;
  14988. /**
  14989. * Creates a new skeleton
  14990. * @param name defines the skeleton name
  14991. * @param id defines the skeleton Id
  14992. * @param scene defines the hosting scene
  14993. */
  14994. constructor(
  14995. /** defines the skeleton name */
  14996. name: string,
  14997. /** defines the skeleton Id */
  14998. id: string, scene: Scene);
  14999. /**
  15000. * Gets the current object class name.
  15001. * @return the class name
  15002. */
  15003. getClassName(): string;
  15004. /**
  15005. * Returns an array containing the root bones
  15006. * @returns an array containing the root bones
  15007. */
  15008. getChildren(): Array<Bone>;
  15009. /**
  15010. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15011. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15012. * @returns a Float32Array containing matrices data
  15013. */
  15014. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15015. /**
  15016. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15017. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15018. * @returns a raw texture containing the data
  15019. */
  15020. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15021. /**
  15022. * Gets the current hosting scene
  15023. * @returns a scene object
  15024. */
  15025. getScene(): Scene;
  15026. /**
  15027. * Gets a string representing the current skeleton data
  15028. * @param fullDetails defines a boolean indicating if we want a verbose version
  15029. * @returns a string representing the current skeleton data
  15030. */
  15031. toString(fullDetails?: boolean): string;
  15032. /**
  15033. * Get bone's index searching by name
  15034. * @param name defines bone's name to search for
  15035. * @return the indice of the bone. Returns -1 if not found
  15036. */
  15037. getBoneIndexByName(name: string): number;
  15038. /**
  15039. * Creater a new animation range
  15040. * @param name defines the name of the range
  15041. * @param from defines the start key
  15042. * @param to defines the end key
  15043. */
  15044. createAnimationRange(name: string, from: number, to: number): void;
  15045. /**
  15046. * Delete a specific animation range
  15047. * @param name defines the name of the range
  15048. * @param deleteFrames defines if frames must be removed as well
  15049. */
  15050. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15051. /**
  15052. * Gets a specific animation range
  15053. * @param name defines the name of the range to look for
  15054. * @returns the requested animation range or null if not found
  15055. */
  15056. getAnimationRange(name: string): Nullable<AnimationRange>;
  15057. /**
  15058. * Gets the list of all animation ranges defined on this skeleton
  15059. * @returns an array
  15060. */
  15061. getAnimationRanges(): Nullable<AnimationRange>[];
  15062. /**
  15063. * Copy animation range from a source skeleton.
  15064. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15065. * @param source defines the source skeleton
  15066. * @param name defines the name of the range to copy
  15067. * @param rescaleAsRequired defines if rescaling must be applied if required
  15068. * @returns true if operation was successful
  15069. */
  15070. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15071. /**
  15072. * Forces the skeleton to go to rest pose
  15073. */
  15074. returnToRest(): void;
  15075. private _getHighestAnimationFrame;
  15076. /**
  15077. * Begin a specific animation range
  15078. * @param name defines the name of the range to start
  15079. * @param loop defines if looping must be turned on (false by default)
  15080. * @param speedRatio defines the speed ratio to apply (1 by default)
  15081. * @param onAnimationEnd defines a callback which will be called when animation will end
  15082. * @returns a new animatable
  15083. */
  15084. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15085. /**
  15086. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  15087. * @param skeleton defines the Skeleton containing the animation range to convert
  15088. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  15089. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  15090. * @returns the original skeleton
  15091. */
  15092. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  15093. /** @hidden */
  15094. _markAsDirty(): void;
  15095. /** @hidden */
  15096. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15097. /** @hidden */
  15098. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15099. private _computeTransformMatrices;
  15100. /**
  15101. * Build all resources required to render a skeleton
  15102. */
  15103. prepare(): void;
  15104. /**
  15105. * Gets the list of animatables currently running for this skeleton
  15106. * @returns an array of animatables
  15107. */
  15108. getAnimatables(): IAnimatable[];
  15109. /**
  15110. * Clone the current skeleton
  15111. * @param name defines the name of the new skeleton
  15112. * @param id defines the id of the new skeleton
  15113. * @returns the new skeleton
  15114. */
  15115. clone(name: string, id?: string): Skeleton;
  15116. /**
  15117. * Enable animation blending for this skeleton
  15118. * @param blendingSpeed defines the blending speed to apply
  15119. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15120. */
  15121. enableBlending(blendingSpeed?: number): void;
  15122. /**
  15123. * Releases all resources associated with the current skeleton
  15124. */
  15125. dispose(): void;
  15126. /**
  15127. * Serialize the skeleton in a JSON object
  15128. * @returns a JSON object
  15129. */
  15130. serialize(): any;
  15131. /**
  15132. * Creates a new skeleton from serialized data
  15133. * @param parsedSkeleton defines the serialized data
  15134. * @param scene defines the hosting scene
  15135. * @returns a new skeleton
  15136. */
  15137. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15138. /**
  15139. * Compute all node absolute transforms
  15140. * @param forceUpdate defines if computation must be done even if cache is up to date
  15141. */
  15142. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15143. /**
  15144. * Gets the root pose matrix
  15145. * @returns a matrix
  15146. */
  15147. getPoseMatrix(): Nullable<Matrix>;
  15148. /**
  15149. * Sorts bones per internal index
  15150. */
  15151. sortBones(): void;
  15152. private _sortBones;
  15153. }
  15154. }
  15155. declare module BABYLON {
  15156. /**
  15157. * Creates an instance based on a source mesh.
  15158. */
  15159. export class InstancedMesh extends AbstractMesh {
  15160. private _sourceMesh;
  15161. private _currentLOD;
  15162. /** @hidden */
  15163. _indexInSourceMeshInstanceArray: number;
  15164. constructor(name: string, source: Mesh);
  15165. /**
  15166. * Returns the string "InstancedMesh".
  15167. */
  15168. getClassName(): string;
  15169. /** Gets the list of lights affecting that mesh */
  15170. get lightSources(): Light[];
  15171. _resyncLightSources(): void;
  15172. _resyncLightSource(light: Light): void;
  15173. _removeLightSource(light: Light, dispose: boolean): void;
  15174. /**
  15175. * If the source mesh receives shadows
  15176. */
  15177. get receiveShadows(): boolean;
  15178. /**
  15179. * The material of the source mesh
  15180. */
  15181. get material(): Nullable<Material>;
  15182. /**
  15183. * Visibility of the source mesh
  15184. */
  15185. get visibility(): number;
  15186. /**
  15187. * Skeleton of the source mesh
  15188. */
  15189. get skeleton(): Nullable<Skeleton>;
  15190. /**
  15191. * Rendering ground id of the source mesh
  15192. */
  15193. get renderingGroupId(): number;
  15194. set renderingGroupId(value: number);
  15195. /**
  15196. * Returns the total number of vertices (integer).
  15197. */
  15198. getTotalVertices(): number;
  15199. /**
  15200. * Returns a positive integer : the total number of indices in this mesh geometry.
  15201. * @returns the numner of indices or zero if the mesh has no geometry.
  15202. */
  15203. getTotalIndices(): number;
  15204. /**
  15205. * The source mesh of the instance
  15206. */
  15207. get sourceMesh(): Mesh;
  15208. /**
  15209. * Is this node ready to be used/rendered
  15210. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15211. * @return {boolean} is it ready
  15212. */
  15213. isReady(completeCheck?: boolean): boolean;
  15214. /**
  15215. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15216. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15217. * @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.
  15218. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15219. */
  15220. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15221. /**
  15222. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15223. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15224. * The `data` are either a numeric array either a Float32Array.
  15225. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15226. * 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).
  15227. * Note that a new underlying VertexBuffer object is created each call.
  15228. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15229. *
  15230. * Possible `kind` values :
  15231. * - VertexBuffer.PositionKind
  15232. * - VertexBuffer.UVKind
  15233. * - VertexBuffer.UV2Kind
  15234. * - VertexBuffer.UV3Kind
  15235. * - VertexBuffer.UV4Kind
  15236. * - VertexBuffer.UV5Kind
  15237. * - VertexBuffer.UV6Kind
  15238. * - VertexBuffer.ColorKind
  15239. * - VertexBuffer.MatricesIndicesKind
  15240. * - VertexBuffer.MatricesIndicesExtraKind
  15241. * - VertexBuffer.MatricesWeightsKind
  15242. * - VertexBuffer.MatricesWeightsExtraKind
  15243. *
  15244. * Returns the Mesh.
  15245. */
  15246. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15247. /**
  15248. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15249. * If the mesh has no geometry, it is simply returned as it is.
  15250. * The `data` are either a numeric array either a Float32Array.
  15251. * No new underlying VertexBuffer object is created.
  15252. * 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.
  15253. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15254. *
  15255. * Possible `kind` values :
  15256. * - VertexBuffer.PositionKind
  15257. * - VertexBuffer.UVKind
  15258. * - VertexBuffer.UV2Kind
  15259. * - VertexBuffer.UV3Kind
  15260. * - VertexBuffer.UV4Kind
  15261. * - VertexBuffer.UV5Kind
  15262. * - VertexBuffer.UV6Kind
  15263. * - VertexBuffer.ColorKind
  15264. * - VertexBuffer.MatricesIndicesKind
  15265. * - VertexBuffer.MatricesIndicesExtraKind
  15266. * - VertexBuffer.MatricesWeightsKind
  15267. * - VertexBuffer.MatricesWeightsExtraKind
  15268. *
  15269. * Returns the Mesh.
  15270. */
  15271. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15272. /**
  15273. * Sets the mesh indices.
  15274. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15275. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15276. * This method creates a new index buffer each call.
  15277. * Returns the Mesh.
  15278. */
  15279. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15280. /**
  15281. * Boolean : True if the mesh owns the requested kind of data.
  15282. */
  15283. isVerticesDataPresent(kind: string): boolean;
  15284. /**
  15285. * Returns an array of indices (IndicesArray).
  15286. */
  15287. getIndices(): Nullable<IndicesArray>;
  15288. get _positions(): Nullable<Vector3[]>;
  15289. /**
  15290. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15291. * This means the mesh underlying bounding box and sphere are recomputed.
  15292. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15293. * @returns the current mesh
  15294. */
  15295. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15296. /** @hidden */
  15297. _preActivate(): InstancedMesh;
  15298. /** @hidden */
  15299. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15300. /** @hidden */
  15301. _postActivate(): void;
  15302. getWorldMatrix(): Matrix;
  15303. get isAnInstance(): boolean;
  15304. /**
  15305. * Returns the current associated LOD AbstractMesh.
  15306. */
  15307. getLOD(camera: Camera): AbstractMesh;
  15308. /** @hidden */
  15309. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15310. /** @hidden */
  15311. _syncSubMeshes(): InstancedMesh;
  15312. /** @hidden */
  15313. _generatePointsArray(): boolean;
  15314. /**
  15315. * Creates a new InstancedMesh from the current mesh.
  15316. * - name (string) : the cloned mesh name
  15317. * - newParent (optional Node) : the optional Node to parent the clone to.
  15318. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15319. *
  15320. * Returns the clone.
  15321. */
  15322. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15323. /**
  15324. * Disposes the InstancedMesh.
  15325. * Returns nothing.
  15326. */
  15327. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15328. }
  15329. interface Mesh {
  15330. /**
  15331. * Register a custom buffer that will be instanced
  15332. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15333. * @param kind defines the buffer kind
  15334. * @param stride defines the stride in floats
  15335. */
  15336. registerInstancedBuffer(kind: string, stride: number): void;
  15337. /** @hidden */
  15338. _userInstancedBuffersStorage: {
  15339. data: {
  15340. [key: string]: Float32Array;
  15341. };
  15342. sizes: {
  15343. [key: string]: number;
  15344. };
  15345. vertexBuffers: {
  15346. [key: string]: Nullable<VertexBuffer>;
  15347. };
  15348. strides: {
  15349. [key: string]: number;
  15350. };
  15351. };
  15352. }
  15353. interface AbstractMesh {
  15354. /**
  15355. * Object used to store instanced buffers defined by user
  15356. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15357. */
  15358. instancedBuffers: {
  15359. [key: string]: any;
  15360. };
  15361. }
  15362. }
  15363. declare module BABYLON {
  15364. /**
  15365. * Defines the options associated with the creation of a shader material.
  15366. */
  15367. export interface IShaderMaterialOptions {
  15368. /**
  15369. * Does the material work in alpha blend mode
  15370. */
  15371. needAlphaBlending: boolean;
  15372. /**
  15373. * Does the material work in alpha test mode
  15374. */
  15375. needAlphaTesting: boolean;
  15376. /**
  15377. * The list of attribute names used in the shader
  15378. */
  15379. attributes: string[];
  15380. /**
  15381. * The list of unifrom names used in the shader
  15382. */
  15383. uniforms: string[];
  15384. /**
  15385. * The list of UBO names used in the shader
  15386. */
  15387. uniformBuffers: string[];
  15388. /**
  15389. * The list of sampler names used in the shader
  15390. */
  15391. samplers: string[];
  15392. /**
  15393. * The list of defines used in the shader
  15394. */
  15395. defines: string[];
  15396. }
  15397. /**
  15398. * 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.
  15399. *
  15400. * This returned material effects how the mesh will look based on the code in the shaders.
  15401. *
  15402. * @see http://doc.babylonjs.com/how_to/shader_material
  15403. */
  15404. export class ShaderMaterial extends Material {
  15405. private _shaderPath;
  15406. private _options;
  15407. private _textures;
  15408. private _textureArrays;
  15409. private _floats;
  15410. private _ints;
  15411. private _floatsArrays;
  15412. private _colors3;
  15413. private _colors3Arrays;
  15414. private _colors4;
  15415. private _colors4Arrays;
  15416. private _vectors2;
  15417. private _vectors3;
  15418. private _vectors4;
  15419. private _matrices;
  15420. private _matrixArrays;
  15421. private _matrices3x3;
  15422. private _matrices2x2;
  15423. private _vectors2Arrays;
  15424. private _vectors3Arrays;
  15425. private _vectors4Arrays;
  15426. private _cachedWorldViewMatrix;
  15427. private _cachedWorldViewProjectionMatrix;
  15428. private _renderId;
  15429. private _multiview;
  15430. /**
  15431. * Instantiate a new shader material.
  15432. * 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.
  15433. * This returned material effects how the mesh will look based on the code in the shaders.
  15434. * @see http://doc.babylonjs.com/how_to/shader_material
  15435. * @param name Define the name of the material in the scene
  15436. * @param scene Define the scene the material belongs to
  15437. * @param shaderPath Defines the route to the shader code in one of three ways:
  15438. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15439. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15440. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15441. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15442. * @param options Define the options used to create the shader
  15443. */
  15444. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15445. /**
  15446. * Gets the shader path used to define the shader code
  15447. * It can be modified to trigger a new compilation
  15448. */
  15449. get shaderPath(): any;
  15450. /**
  15451. * Sets the shader path used to define the shader code
  15452. * It can be modified to trigger a new compilation
  15453. */
  15454. set shaderPath(shaderPath: any);
  15455. /**
  15456. * Gets the options used to compile the shader.
  15457. * They can be modified to trigger a new compilation
  15458. */
  15459. get options(): IShaderMaterialOptions;
  15460. /**
  15461. * Gets the current class name of the material e.g. "ShaderMaterial"
  15462. * Mainly use in serialization.
  15463. * @returns the class name
  15464. */
  15465. getClassName(): string;
  15466. /**
  15467. * Specifies if the material will require alpha blending
  15468. * @returns a boolean specifying if alpha blending is needed
  15469. */
  15470. needAlphaBlending(): boolean;
  15471. /**
  15472. * Specifies if this material should be rendered in alpha test mode
  15473. * @returns a boolean specifying if an alpha test is needed.
  15474. */
  15475. needAlphaTesting(): boolean;
  15476. private _checkUniform;
  15477. /**
  15478. * Set a texture in the shader.
  15479. * @param name Define the name of the uniform samplers as defined in the shader
  15480. * @param texture Define the texture to bind to this sampler
  15481. * @return the material itself allowing "fluent" like uniform updates
  15482. */
  15483. setTexture(name: string, texture: Texture): ShaderMaterial;
  15484. /**
  15485. * Set a texture array in the shader.
  15486. * @param name Define the name of the uniform sampler array as defined in the shader
  15487. * @param textures Define the list of textures to bind to this sampler
  15488. * @return the material itself allowing "fluent" like uniform updates
  15489. */
  15490. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15491. /**
  15492. * Set a float in the shader.
  15493. * @param name Define the name of the uniform as defined in the shader
  15494. * @param value Define the value to give to the uniform
  15495. * @return the material itself allowing "fluent" like uniform updates
  15496. */
  15497. setFloat(name: string, value: number): ShaderMaterial;
  15498. /**
  15499. * Set a int in the shader.
  15500. * @param name Define the name of the uniform as defined in the shader
  15501. * @param value Define the value to give to the uniform
  15502. * @return the material itself allowing "fluent" like uniform updates
  15503. */
  15504. setInt(name: string, value: number): ShaderMaterial;
  15505. /**
  15506. * Set an array of floats in the shader.
  15507. * @param name Define the name of the uniform as defined in the shader
  15508. * @param value Define the value to give to the uniform
  15509. * @return the material itself allowing "fluent" like uniform updates
  15510. */
  15511. setFloats(name: string, value: number[]): ShaderMaterial;
  15512. /**
  15513. * Set a vec3 in the shader from a Color3.
  15514. * @param name Define the name of the uniform as defined in the shader
  15515. * @param value Define the value to give to the uniform
  15516. * @return the material itself allowing "fluent" like uniform updates
  15517. */
  15518. setColor3(name: string, value: Color3): ShaderMaterial;
  15519. /**
  15520. * Set a vec3 array in the shader from a Color3 array.
  15521. * @param name Define the name of the uniform as defined in the shader
  15522. * @param value Define the value to give to the uniform
  15523. * @return the material itself allowing "fluent" like uniform updates
  15524. */
  15525. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15526. /**
  15527. * Set a vec4 in the shader from a Color4.
  15528. * @param name Define the name of the uniform as defined in the shader
  15529. * @param value Define the value to give to the uniform
  15530. * @return the material itself allowing "fluent" like uniform updates
  15531. */
  15532. setColor4(name: string, value: Color4): ShaderMaterial;
  15533. /**
  15534. * Set a vec4 array in the shader from a Color4 array.
  15535. * @param name Define the name of the uniform as defined in the shader
  15536. * @param value Define the value to give to the uniform
  15537. * @return the material itself allowing "fluent" like uniform updates
  15538. */
  15539. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15540. /**
  15541. * Set a vec2 in the shader from a Vector2.
  15542. * @param name Define the name of the uniform as defined in the shader
  15543. * @param value Define the value to give to the uniform
  15544. * @return the material itself allowing "fluent" like uniform updates
  15545. */
  15546. setVector2(name: string, value: Vector2): ShaderMaterial;
  15547. /**
  15548. * Set a vec3 in the shader from a Vector3.
  15549. * @param name Define the name of the uniform as defined in the shader
  15550. * @param value Define the value to give to the uniform
  15551. * @return the material itself allowing "fluent" like uniform updates
  15552. */
  15553. setVector3(name: string, value: Vector3): ShaderMaterial;
  15554. /**
  15555. * Set a vec4 in the shader from a Vector4.
  15556. * @param name Define the name of the uniform as defined in the shader
  15557. * @param value Define the value to give to the uniform
  15558. * @return the material itself allowing "fluent" like uniform updates
  15559. */
  15560. setVector4(name: string, value: Vector4): ShaderMaterial;
  15561. /**
  15562. * Set a mat4 in the shader from a Matrix.
  15563. * @param name Define the name of the uniform as defined in the shader
  15564. * @param value Define the value to give to the uniform
  15565. * @return the material itself allowing "fluent" like uniform updates
  15566. */
  15567. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15568. /**
  15569. * Set a float32Array in the shader from a matrix array.
  15570. * @param name Define the name of the uniform as defined in the shader
  15571. * @param value Define the value to give to the uniform
  15572. * @return the material itself allowing "fluent" like uniform updates
  15573. */
  15574. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15575. /**
  15576. * Set a mat3 in the shader from a Float32Array.
  15577. * @param name Define the name of the uniform as defined in the shader
  15578. * @param value Define the value to give to the uniform
  15579. * @return the material itself allowing "fluent" like uniform updates
  15580. */
  15581. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15582. /**
  15583. * Set a mat2 in the shader from a Float32Array.
  15584. * @param name Define the name of the uniform as defined in the shader
  15585. * @param value Define the value to give to the uniform
  15586. * @return the material itself allowing "fluent" like uniform updates
  15587. */
  15588. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15589. /**
  15590. * Set a vec2 array in the shader from a number array.
  15591. * @param name Define the name of the uniform as defined in the shader
  15592. * @param value Define the value to give to the uniform
  15593. * @return the material itself allowing "fluent" like uniform updates
  15594. */
  15595. setArray2(name: string, value: number[]): ShaderMaterial;
  15596. /**
  15597. * Set a vec3 array in the shader from a number array.
  15598. * @param name Define the name of the uniform as defined in the shader
  15599. * @param value Define the value to give to the uniform
  15600. * @return the material itself allowing "fluent" like uniform updates
  15601. */
  15602. setArray3(name: string, value: number[]): ShaderMaterial;
  15603. /**
  15604. * Set a vec4 array in the shader from a number array.
  15605. * @param name Define the name of the uniform as defined in the shader
  15606. * @param value Define the value to give to the uniform
  15607. * @return the material itself allowing "fluent" like uniform updates
  15608. */
  15609. setArray4(name: string, value: number[]): ShaderMaterial;
  15610. private _checkCache;
  15611. /**
  15612. * Specifies that the submesh is ready to be used
  15613. * @param mesh defines the mesh to check
  15614. * @param subMesh defines which submesh to check
  15615. * @param useInstances specifies that instances should be used
  15616. * @returns a boolean indicating that the submesh is ready or not
  15617. */
  15618. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15619. /**
  15620. * Checks if the material is ready to render the requested mesh
  15621. * @param mesh Define the mesh to render
  15622. * @param useInstances Define whether or not the material is used with instances
  15623. * @returns true if ready, otherwise false
  15624. */
  15625. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15626. /**
  15627. * Binds the world matrix to the material
  15628. * @param world defines the world transformation matrix
  15629. */
  15630. bindOnlyWorldMatrix(world: Matrix): void;
  15631. /**
  15632. * Binds the material to the mesh
  15633. * @param world defines the world transformation matrix
  15634. * @param mesh defines the mesh to bind the material to
  15635. */
  15636. bind(world: Matrix, mesh?: Mesh): void;
  15637. /**
  15638. * Gets the active textures from the material
  15639. * @returns an array of textures
  15640. */
  15641. getActiveTextures(): BaseTexture[];
  15642. /**
  15643. * Specifies if the material uses a texture
  15644. * @param texture defines the texture to check against the material
  15645. * @returns a boolean specifying if the material uses the texture
  15646. */
  15647. hasTexture(texture: BaseTexture): boolean;
  15648. /**
  15649. * Makes a duplicate of the material, and gives it a new name
  15650. * @param name defines the new name for the duplicated material
  15651. * @returns the cloned material
  15652. */
  15653. clone(name: string): ShaderMaterial;
  15654. /**
  15655. * Disposes the material
  15656. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15657. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15658. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15659. */
  15660. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15661. /**
  15662. * Serializes this material in a JSON representation
  15663. * @returns the serialized material object
  15664. */
  15665. serialize(): any;
  15666. /**
  15667. * Creates a shader material from parsed shader material data
  15668. * @param source defines the JSON represnetation of the material
  15669. * @param scene defines the hosting scene
  15670. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15671. * @returns a new material
  15672. */
  15673. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15674. }
  15675. }
  15676. declare module BABYLON {
  15677. /** @hidden */
  15678. export var colorPixelShader: {
  15679. name: string;
  15680. shader: string;
  15681. };
  15682. }
  15683. declare module BABYLON {
  15684. /** @hidden */
  15685. export var colorVertexShader: {
  15686. name: string;
  15687. shader: string;
  15688. };
  15689. }
  15690. declare module BABYLON {
  15691. /**
  15692. * Line mesh
  15693. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15694. */
  15695. export class LinesMesh extends Mesh {
  15696. /**
  15697. * If vertex color should be applied to the mesh
  15698. */
  15699. readonly useVertexColor?: boolean | undefined;
  15700. /**
  15701. * If vertex alpha should be applied to the mesh
  15702. */
  15703. readonly useVertexAlpha?: boolean | undefined;
  15704. /**
  15705. * Color of the line (Default: White)
  15706. */
  15707. color: Color3;
  15708. /**
  15709. * Alpha of the line (Default: 1)
  15710. */
  15711. alpha: number;
  15712. /**
  15713. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15714. * This margin is expressed in world space coordinates, so its value may vary.
  15715. * Default value is 0.1
  15716. */
  15717. intersectionThreshold: number;
  15718. private _colorShader;
  15719. private color4;
  15720. /**
  15721. * Creates a new LinesMesh
  15722. * @param name defines the name
  15723. * @param scene defines the hosting scene
  15724. * @param parent defines the parent mesh if any
  15725. * @param source defines the optional source LinesMesh used to clone data from
  15726. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15727. * When false, achieved by calling a clone(), also passing False.
  15728. * This will make creation of children, recursive.
  15729. * @param useVertexColor defines if this LinesMesh supports vertex color
  15730. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  15731. */
  15732. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  15733. /**
  15734. * If vertex color should be applied to the mesh
  15735. */
  15736. useVertexColor?: boolean | undefined,
  15737. /**
  15738. * If vertex alpha should be applied to the mesh
  15739. */
  15740. useVertexAlpha?: boolean | undefined);
  15741. private _addClipPlaneDefine;
  15742. private _removeClipPlaneDefine;
  15743. isReady(): boolean;
  15744. /**
  15745. * Returns the string "LineMesh"
  15746. */
  15747. getClassName(): string;
  15748. /**
  15749. * @hidden
  15750. */
  15751. get material(): Material;
  15752. /**
  15753. * @hidden
  15754. */
  15755. set material(value: Material);
  15756. /**
  15757. * @hidden
  15758. */
  15759. get checkCollisions(): boolean;
  15760. /** @hidden */
  15761. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  15762. /** @hidden */
  15763. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  15764. /**
  15765. * Disposes of the line mesh
  15766. * @param doNotRecurse If children should be disposed
  15767. */
  15768. dispose(doNotRecurse?: boolean): void;
  15769. /**
  15770. * Returns a new LineMesh object cloned from the current one.
  15771. */
  15772. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  15773. /**
  15774. * Creates a new InstancedLinesMesh object from the mesh model.
  15775. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  15776. * @param name defines the name of the new instance
  15777. * @returns a new InstancedLinesMesh
  15778. */
  15779. createInstance(name: string): InstancedLinesMesh;
  15780. }
  15781. /**
  15782. * Creates an instance based on a source LinesMesh
  15783. */
  15784. export class InstancedLinesMesh extends InstancedMesh {
  15785. /**
  15786. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15787. * This margin is expressed in world space coordinates, so its value may vary.
  15788. * Initilized with the intersectionThreshold value of the source LinesMesh
  15789. */
  15790. intersectionThreshold: number;
  15791. constructor(name: string, source: LinesMesh);
  15792. /**
  15793. * Returns the string "InstancedLinesMesh".
  15794. */
  15795. getClassName(): string;
  15796. }
  15797. }
  15798. declare module BABYLON {
  15799. /** @hidden */
  15800. export var linePixelShader: {
  15801. name: string;
  15802. shader: string;
  15803. };
  15804. }
  15805. declare module BABYLON {
  15806. /** @hidden */
  15807. export var lineVertexShader: {
  15808. name: string;
  15809. shader: string;
  15810. };
  15811. }
  15812. declare module BABYLON {
  15813. interface AbstractMesh {
  15814. /**
  15815. * Gets the edgesRenderer associated with the mesh
  15816. */
  15817. edgesRenderer: Nullable<EdgesRenderer>;
  15818. }
  15819. interface LinesMesh {
  15820. /**
  15821. * Enables the edge rendering mode on the mesh.
  15822. * This mode makes the mesh edges visible
  15823. * @param epsilon defines the maximal distance between two angles to detect a face
  15824. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15825. * @returns the currentAbstractMesh
  15826. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15827. */
  15828. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  15829. }
  15830. interface InstancedLinesMesh {
  15831. /**
  15832. * Enables the edge rendering mode on the mesh.
  15833. * This mode makes the mesh edges visible
  15834. * @param epsilon defines the maximal distance between two angles to detect a face
  15835. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15836. * @returns the current InstancedLinesMesh
  15837. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15838. */
  15839. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  15840. }
  15841. /**
  15842. * Defines the minimum contract an Edges renderer should follow.
  15843. */
  15844. export interface IEdgesRenderer extends IDisposable {
  15845. /**
  15846. * Gets or sets a boolean indicating if the edgesRenderer is active
  15847. */
  15848. isEnabled: boolean;
  15849. /**
  15850. * Renders the edges of the attached mesh,
  15851. */
  15852. render(): void;
  15853. /**
  15854. * Checks wether or not the edges renderer is ready to render.
  15855. * @return true if ready, otherwise false.
  15856. */
  15857. isReady(): boolean;
  15858. }
  15859. /**
  15860. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  15861. */
  15862. export class EdgesRenderer implements IEdgesRenderer {
  15863. /**
  15864. * Define the size of the edges with an orthographic camera
  15865. */
  15866. edgesWidthScalerForOrthographic: number;
  15867. /**
  15868. * Define the size of the edges with a perspective camera
  15869. */
  15870. edgesWidthScalerForPerspective: number;
  15871. protected _source: AbstractMesh;
  15872. protected _linesPositions: number[];
  15873. protected _linesNormals: number[];
  15874. protected _linesIndices: number[];
  15875. protected _epsilon: number;
  15876. protected _indicesCount: number;
  15877. protected _lineShader: ShaderMaterial;
  15878. protected _ib: DataBuffer;
  15879. protected _buffers: {
  15880. [key: string]: Nullable<VertexBuffer>;
  15881. };
  15882. protected _checkVerticesInsteadOfIndices: boolean;
  15883. private _meshRebuildObserver;
  15884. private _meshDisposeObserver;
  15885. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  15886. isEnabled: boolean;
  15887. /**
  15888. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  15889. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  15890. * @param source Mesh used to create edges
  15891. * @param epsilon sum of angles in adjacency to check for edge
  15892. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  15893. * @param generateEdgesLines - should generate Lines or only prepare resources.
  15894. */
  15895. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  15896. protected _prepareRessources(): void;
  15897. /** @hidden */
  15898. _rebuild(): void;
  15899. /**
  15900. * Releases the required resources for the edges renderer
  15901. */
  15902. dispose(): void;
  15903. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  15904. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  15905. /**
  15906. * Checks if the pair of p0 and p1 is en edge
  15907. * @param faceIndex
  15908. * @param edge
  15909. * @param faceNormals
  15910. * @param p0
  15911. * @param p1
  15912. * @private
  15913. */
  15914. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  15915. /**
  15916. * push line into the position, normal and index buffer
  15917. * @protected
  15918. */
  15919. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  15920. /**
  15921. * Generates lines edges from adjacencjes
  15922. * @private
  15923. */
  15924. _generateEdgesLines(): void;
  15925. /**
  15926. * Checks wether or not the edges renderer is ready to render.
  15927. * @return true if ready, otherwise false.
  15928. */
  15929. isReady(): boolean;
  15930. /**
  15931. * Renders the edges of the attached mesh,
  15932. */
  15933. render(): void;
  15934. }
  15935. /**
  15936. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  15937. */
  15938. export class LineEdgesRenderer extends EdgesRenderer {
  15939. /**
  15940. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  15941. * @param source LineMesh used to generate edges
  15942. * @param epsilon not important (specified angle for edge detection)
  15943. * @param checkVerticesInsteadOfIndices not important for LineMesh
  15944. */
  15945. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  15946. /**
  15947. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  15948. */
  15949. _generateEdgesLines(): void;
  15950. }
  15951. }
  15952. declare module BABYLON {
  15953. /**
  15954. * This represents the object necessary to create a rendering group.
  15955. * This is exclusively used and created by the rendering manager.
  15956. * To modify the behavior, you use the available helpers in your scene or meshes.
  15957. * @hidden
  15958. */
  15959. export class RenderingGroup {
  15960. index: number;
  15961. private static _zeroVector;
  15962. private _scene;
  15963. private _opaqueSubMeshes;
  15964. private _transparentSubMeshes;
  15965. private _alphaTestSubMeshes;
  15966. private _depthOnlySubMeshes;
  15967. private _particleSystems;
  15968. private _spriteManagers;
  15969. private _opaqueSortCompareFn;
  15970. private _alphaTestSortCompareFn;
  15971. private _transparentSortCompareFn;
  15972. private _renderOpaque;
  15973. private _renderAlphaTest;
  15974. private _renderTransparent;
  15975. /** @hidden */
  15976. _edgesRenderers: SmartArray<IEdgesRenderer>;
  15977. onBeforeTransparentRendering: () => void;
  15978. /**
  15979. * Set the opaque sort comparison function.
  15980. * If null the sub meshes will be render in the order they were created
  15981. */
  15982. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15983. /**
  15984. * Set the alpha test sort comparison function.
  15985. * If null the sub meshes will be render in the order they were created
  15986. */
  15987. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15988. /**
  15989. * Set the transparent sort comparison function.
  15990. * If null the sub meshes will be render in the order they were created
  15991. */
  15992. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15993. /**
  15994. * Creates a new rendering group.
  15995. * @param index The rendering group index
  15996. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  15997. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  15998. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  15999. */
  16000. 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>);
  16001. /**
  16002. * Render all the sub meshes contained in the group.
  16003. * @param customRenderFunction Used to override the default render behaviour of the group.
  16004. * @returns true if rendered some submeshes.
  16005. */
  16006. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16007. /**
  16008. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16009. * @param subMeshes The submeshes to render
  16010. */
  16011. private renderOpaqueSorted;
  16012. /**
  16013. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16014. * @param subMeshes The submeshes to render
  16015. */
  16016. private renderAlphaTestSorted;
  16017. /**
  16018. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16019. * @param subMeshes The submeshes to render
  16020. */
  16021. private renderTransparentSorted;
  16022. /**
  16023. * Renders the submeshes in a specified order.
  16024. * @param subMeshes The submeshes to sort before render
  16025. * @param sortCompareFn The comparison function use to sort
  16026. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16027. * @param transparent Specifies to activate blending if true
  16028. */
  16029. private static renderSorted;
  16030. /**
  16031. * Renders the submeshes in the order they were dispatched (no sort applied).
  16032. * @param subMeshes The submeshes to render
  16033. */
  16034. private static renderUnsorted;
  16035. /**
  16036. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16037. * are rendered back to front if in the same alpha index.
  16038. *
  16039. * @param a The first submesh
  16040. * @param b The second submesh
  16041. * @returns The result of the comparison
  16042. */
  16043. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16044. /**
  16045. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16046. * are rendered back to front.
  16047. *
  16048. * @param a The first submesh
  16049. * @param b The second submesh
  16050. * @returns The result of the comparison
  16051. */
  16052. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16053. /**
  16054. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16055. * are rendered front to back (prevent overdraw).
  16056. *
  16057. * @param a The first submesh
  16058. * @param b The second submesh
  16059. * @returns The result of the comparison
  16060. */
  16061. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16062. /**
  16063. * Resets the different lists of submeshes to prepare a new frame.
  16064. */
  16065. prepare(): void;
  16066. dispose(): void;
  16067. /**
  16068. * Inserts the submesh in its correct queue depending on its material.
  16069. * @param subMesh The submesh to dispatch
  16070. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16071. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16072. */
  16073. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16074. dispatchSprites(spriteManager: ISpriteManager): void;
  16075. dispatchParticles(particleSystem: IParticleSystem): void;
  16076. private _renderParticles;
  16077. private _renderSprites;
  16078. }
  16079. }
  16080. declare module BABYLON {
  16081. /**
  16082. * Interface describing the different options available in the rendering manager
  16083. * regarding Auto Clear between groups.
  16084. */
  16085. export interface IRenderingManagerAutoClearSetup {
  16086. /**
  16087. * Defines whether or not autoclear is enable.
  16088. */
  16089. autoClear: boolean;
  16090. /**
  16091. * Defines whether or not to autoclear the depth buffer.
  16092. */
  16093. depth: boolean;
  16094. /**
  16095. * Defines whether or not to autoclear the stencil buffer.
  16096. */
  16097. stencil: boolean;
  16098. }
  16099. /**
  16100. * This class is used by the onRenderingGroupObservable
  16101. */
  16102. export class RenderingGroupInfo {
  16103. /**
  16104. * The Scene that being rendered
  16105. */
  16106. scene: Scene;
  16107. /**
  16108. * The camera currently used for the rendering pass
  16109. */
  16110. camera: Nullable<Camera>;
  16111. /**
  16112. * The ID of the renderingGroup being processed
  16113. */
  16114. renderingGroupId: number;
  16115. }
  16116. /**
  16117. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16118. * It is enable to manage the different groups as well as the different necessary sort functions.
  16119. * This should not be used directly aside of the few static configurations
  16120. */
  16121. export class RenderingManager {
  16122. /**
  16123. * The max id used for rendering groups (not included)
  16124. */
  16125. static MAX_RENDERINGGROUPS: number;
  16126. /**
  16127. * The min id used for rendering groups (included)
  16128. */
  16129. static MIN_RENDERINGGROUPS: number;
  16130. /**
  16131. * Used to globally prevent autoclearing scenes.
  16132. */
  16133. static AUTOCLEAR: boolean;
  16134. /**
  16135. * @hidden
  16136. */
  16137. _useSceneAutoClearSetup: boolean;
  16138. private _scene;
  16139. private _renderingGroups;
  16140. private _depthStencilBufferAlreadyCleaned;
  16141. private _autoClearDepthStencil;
  16142. private _customOpaqueSortCompareFn;
  16143. private _customAlphaTestSortCompareFn;
  16144. private _customTransparentSortCompareFn;
  16145. private _renderingGroupInfo;
  16146. /**
  16147. * Instantiates a new rendering group for a particular scene
  16148. * @param scene Defines the scene the groups belongs to
  16149. */
  16150. constructor(scene: Scene);
  16151. private _clearDepthStencilBuffer;
  16152. /**
  16153. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16154. * @hidden
  16155. */
  16156. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16157. /**
  16158. * Resets the different information of the group to prepare a new frame
  16159. * @hidden
  16160. */
  16161. reset(): void;
  16162. /**
  16163. * Dispose and release the group and its associated resources.
  16164. * @hidden
  16165. */
  16166. dispose(): void;
  16167. /**
  16168. * Clear the info related to rendering groups preventing retention points during dispose.
  16169. */
  16170. freeRenderingGroups(): void;
  16171. private _prepareRenderingGroup;
  16172. /**
  16173. * Add a sprite manager to the rendering manager in order to render it this frame.
  16174. * @param spriteManager Define the sprite manager to render
  16175. */
  16176. dispatchSprites(spriteManager: ISpriteManager): void;
  16177. /**
  16178. * Add a particle system to the rendering manager in order to render it this frame.
  16179. * @param particleSystem Define the particle system to render
  16180. */
  16181. dispatchParticles(particleSystem: IParticleSystem): void;
  16182. /**
  16183. * Add a submesh to the manager in order to render it this frame
  16184. * @param subMesh The submesh to dispatch
  16185. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16186. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16187. */
  16188. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16189. /**
  16190. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16191. * This allowed control for front to back rendering or reversly depending of the special needs.
  16192. *
  16193. * @param renderingGroupId The rendering group id corresponding to its index
  16194. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16195. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16196. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16197. */
  16198. 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;
  16199. /**
  16200. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16201. *
  16202. * @param renderingGroupId The rendering group id corresponding to its index
  16203. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16204. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16205. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16206. */
  16207. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16208. /**
  16209. * Gets the current auto clear configuration for one rendering group of the rendering
  16210. * manager.
  16211. * @param index the rendering group index to get the information for
  16212. * @returns The auto clear setup for the requested rendering group
  16213. */
  16214. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16215. }
  16216. }
  16217. declare module BABYLON {
  16218. /**
  16219. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16220. */
  16221. export interface ICustomShaderOptions {
  16222. /**
  16223. * Gets or sets the custom shader name to use
  16224. */
  16225. shaderName: string;
  16226. /**
  16227. * The list of attribute names used in the shader
  16228. */
  16229. attributes?: string[];
  16230. /**
  16231. * The list of unifrom names used in the shader
  16232. */
  16233. uniforms?: string[];
  16234. /**
  16235. * The list of sampler names used in the shader
  16236. */
  16237. samplers?: string[];
  16238. /**
  16239. * The list of defines used in the shader
  16240. */
  16241. defines?: string[];
  16242. }
  16243. /**
  16244. * Interface to implement to create a shadow generator compatible with BJS.
  16245. */
  16246. export interface IShadowGenerator {
  16247. /**
  16248. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16249. * @returns The render target texture if present otherwise, null
  16250. */
  16251. getShadowMap(): Nullable<RenderTargetTexture>;
  16252. /**
  16253. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16254. * @param subMesh The submesh we want to render in the shadow map
  16255. * @param useInstances Defines wether will draw in the map using instances
  16256. * @returns true if ready otherwise, false
  16257. */
  16258. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16259. /**
  16260. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16261. * @param defines Defines of the material we want to update
  16262. * @param lightIndex Index of the light in the enabled light list of the material
  16263. */
  16264. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16265. /**
  16266. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16267. * defined in the generator but impacting the effect).
  16268. * It implies the unifroms available on the materials are the standard BJS ones.
  16269. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16270. * @param effect The effect we are binfing the information for
  16271. */
  16272. bindShadowLight(lightIndex: string, effect: Effect): void;
  16273. /**
  16274. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16275. * (eq to shadow prjection matrix * light transform matrix)
  16276. * @returns The transform matrix used to create the shadow map
  16277. */
  16278. getTransformMatrix(): Matrix;
  16279. /**
  16280. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16281. * Cube and 2D textures for instance.
  16282. */
  16283. recreateShadowMap(): void;
  16284. /**
  16285. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16286. * @param onCompiled Callback triggered at the and of the effects compilation
  16287. * @param options Sets of optional options forcing the compilation with different modes
  16288. */
  16289. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16290. useInstances: boolean;
  16291. }>): void;
  16292. /**
  16293. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16294. * @param options Sets of optional options forcing the compilation with different modes
  16295. * @returns A promise that resolves when the compilation completes
  16296. */
  16297. forceCompilationAsync(options?: Partial<{
  16298. useInstances: boolean;
  16299. }>): Promise<void>;
  16300. /**
  16301. * Serializes the shadow generator setup to a json object.
  16302. * @returns The serialized JSON object
  16303. */
  16304. serialize(): any;
  16305. /**
  16306. * Disposes the Shadow map and related Textures and effects.
  16307. */
  16308. dispose(): void;
  16309. }
  16310. /**
  16311. * Default implementation IShadowGenerator.
  16312. * This is the main object responsible of generating shadows in the framework.
  16313. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16314. */
  16315. export class ShadowGenerator implements IShadowGenerator {
  16316. /**
  16317. * Name of the shadow generator class
  16318. */
  16319. static CLASSNAME: string;
  16320. /**
  16321. * Shadow generator mode None: no filtering applied.
  16322. */
  16323. static readonly FILTER_NONE: number;
  16324. /**
  16325. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16326. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16327. */
  16328. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16329. /**
  16330. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16331. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16332. */
  16333. static readonly FILTER_POISSONSAMPLING: number;
  16334. /**
  16335. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16336. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16337. */
  16338. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16339. /**
  16340. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16341. * edge artifacts on steep falloff.
  16342. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16343. */
  16344. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16345. /**
  16346. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16347. * edge artifacts on steep falloff.
  16348. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16349. */
  16350. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16351. /**
  16352. * Shadow generator mode PCF: Percentage Closer Filtering
  16353. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16354. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16355. */
  16356. static readonly FILTER_PCF: number;
  16357. /**
  16358. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16359. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16360. * Contact Hardening
  16361. */
  16362. static readonly FILTER_PCSS: number;
  16363. /**
  16364. * Reserved for PCF and PCSS
  16365. * Highest Quality.
  16366. *
  16367. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16368. *
  16369. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16370. */
  16371. static readonly QUALITY_HIGH: number;
  16372. /**
  16373. * Reserved for PCF and PCSS
  16374. * Good tradeoff for quality/perf cross devices
  16375. *
  16376. * Execute PCF on a 3*3 kernel.
  16377. *
  16378. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16379. */
  16380. static readonly QUALITY_MEDIUM: number;
  16381. /**
  16382. * Reserved for PCF and PCSS
  16383. * The lowest quality but the fastest.
  16384. *
  16385. * Execute PCF on a 1*1 kernel.
  16386. *
  16387. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16388. */
  16389. static readonly QUALITY_LOW: number;
  16390. /** Gets or sets the custom shader name to use */
  16391. customShaderOptions: ICustomShaderOptions;
  16392. /**
  16393. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16394. */
  16395. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16396. /**
  16397. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16398. */
  16399. onAfterShadowMapRenderObservable: Observable<Effect>;
  16400. /**
  16401. * Observable triggered before a mesh is rendered in the shadow map.
  16402. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16403. */
  16404. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16405. /**
  16406. * Observable triggered after a mesh is rendered in the shadow map.
  16407. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16408. */
  16409. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16410. protected _bias: number;
  16411. /**
  16412. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16413. */
  16414. get bias(): number;
  16415. /**
  16416. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16417. */
  16418. set bias(bias: number);
  16419. protected _normalBias: number;
  16420. /**
  16421. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16422. */
  16423. get normalBias(): number;
  16424. /**
  16425. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16426. */
  16427. set normalBias(normalBias: number);
  16428. protected _blurBoxOffset: number;
  16429. /**
  16430. * Gets the blur box offset: offset applied during the blur pass.
  16431. * Only useful if useKernelBlur = false
  16432. */
  16433. get blurBoxOffset(): number;
  16434. /**
  16435. * Sets the blur box offset: offset applied during the blur pass.
  16436. * Only useful if useKernelBlur = false
  16437. */
  16438. set blurBoxOffset(value: number);
  16439. protected _blurScale: number;
  16440. /**
  16441. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16442. * 2 means half of the size.
  16443. */
  16444. get blurScale(): number;
  16445. /**
  16446. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16447. * 2 means half of the size.
  16448. */
  16449. set blurScale(value: number);
  16450. protected _blurKernel: number;
  16451. /**
  16452. * Gets the blur kernel: kernel size of the blur pass.
  16453. * Only useful if useKernelBlur = true
  16454. */
  16455. get blurKernel(): number;
  16456. /**
  16457. * Sets the blur kernel: kernel size of the blur pass.
  16458. * Only useful if useKernelBlur = true
  16459. */
  16460. set blurKernel(value: number);
  16461. protected _useKernelBlur: boolean;
  16462. /**
  16463. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16464. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16465. */
  16466. get useKernelBlur(): boolean;
  16467. /**
  16468. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16469. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16470. */
  16471. set useKernelBlur(value: boolean);
  16472. protected _depthScale: number;
  16473. /**
  16474. * Gets the depth scale used in ESM mode.
  16475. */
  16476. get depthScale(): number;
  16477. /**
  16478. * Sets the depth scale used in ESM mode.
  16479. * This can override the scale stored on the light.
  16480. */
  16481. set depthScale(value: number);
  16482. protected _validateFilter(filter: number): number;
  16483. protected _filter: number;
  16484. /**
  16485. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16486. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16487. */
  16488. get filter(): number;
  16489. /**
  16490. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16491. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16492. */
  16493. set filter(value: number);
  16494. /**
  16495. * Gets if the current filter is set to Poisson Sampling.
  16496. */
  16497. get usePoissonSampling(): boolean;
  16498. /**
  16499. * Sets the current filter to Poisson Sampling.
  16500. */
  16501. set usePoissonSampling(value: boolean);
  16502. /**
  16503. * Gets if the current filter is set to ESM.
  16504. */
  16505. get useExponentialShadowMap(): boolean;
  16506. /**
  16507. * Sets the current filter is to ESM.
  16508. */
  16509. set useExponentialShadowMap(value: boolean);
  16510. /**
  16511. * Gets if the current filter is set to filtered ESM.
  16512. */
  16513. get useBlurExponentialShadowMap(): boolean;
  16514. /**
  16515. * Gets if the current filter is set to filtered ESM.
  16516. */
  16517. set useBlurExponentialShadowMap(value: boolean);
  16518. /**
  16519. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16520. * exponential to prevent steep falloff artifacts).
  16521. */
  16522. get useCloseExponentialShadowMap(): boolean;
  16523. /**
  16524. * Sets the current filter to "close ESM" (using the inverse of the
  16525. * exponential to prevent steep falloff artifacts).
  16526. */
  16527. set useCloseExponentialShadowMap(value: boolean);
  16528. /**
  16529. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16530. * exponential to prevent steep falloff artifacts).
  16531. */
  16532. get useBlurCloseExponentialShadowMap(): boolean;
  16533. /**
  16534. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16535. * exponential to prevent steep falloff artifacts).
  16536. */
  16537. set useBlurCloseExponentialShadowMap(value: boolean);
  16538. /**
  16539. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16540. */
  16541. get usePercentageCloserFiltering(): boolean;
  16542. /**
  16543. * Sets the current filter to "PCF" (percentage closer filtering).
  16544. */
  16545. set usePercentageCloserFiltering(value: boolean);
  16546. protected _filteringQuality: number;
  16547. /**
  16548. * Gets the PCF or PCSS Quality.
  16549. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16550. */
  16551. get filteringQuality(): number;
  16552. /**
  16553. * Sets the PCF or PCSS Quality.
  16554. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16555. */
  16556. set filteringQuality(filteringQuality: number);
  16557. /**
  16558. * Gets if the current filter is set to "PCSS" (contact hardening).
  16559. */
  16560. get useContactHardeningShadow(): boolean;
  16561. /**
  16562. * Sets the current filter to "PCSS" (contact hardening).
  16563. */
  16564. set useContactHardeningShadow(value: boolean);
  16565. protected _contactHardeningLightSizeUVRatio: number;
  16566. /**
  16567. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16568. * Using a ratio helps keeping shape stability independently of the map size.
  16569. *
  16570. * It does not account for the light projection as it was having too much
  16571. * instability during the light setup or during light position changes.
  16572. *
  16573. * Only valid if useContactHardeningShadow is true.
  16574. */
  16575. get contactHardeningLightSizeUVRatio(): number;
  16576. /**
  16577. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16578. * Using a ratio helps keeping shape stability independently of the map size.
  16579. *
  16580. * It does not account for the light projection as it was having too much
  16581. * instability during the light setup or during light position changes.
  16582. *
  16583. * Only valid if useContactHardeningShadow is true.
  16584. */
  16585. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16586. protected _darkness: number;
  16587. /** Gets or sets the actual darkness of a shadow */
  16588. get darkness(): number;
  16589. set darkness(value: number);
  16590. /**
  16591. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16592. * 0 means strongest and 1 would means no shadow.
  16593. * @returns the darkness.
  16594. */
  16595. getDarkness(): number;
  16596. /**
  16597. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16598. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16599. * @returns the shadow generator allowing fluent coding.
  16600. */
  16601. setDarkness(darkness: number): ShadowGenerator;
  16602. protected _transparencyShadow: boolean;
  16603. /** Gets or sets the ability to have transparent shadow */
  16604. get transparencyShadow(): boolean;
  16605. set transparencyShadow(value: boolean);
  16606. /**
  16607. * Sets the ability to have transparent shadow (boolean).
  16608. * @param transparent True if transparent else False
  16609. * @returns the shadow generator allowing fluent coding
  16610. */
  16611. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16612. protected _shadowMap: Nullable<RenderTargetTexture>;
  16613. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16614. /**
  16615. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16616. * @returns The render target texture if present otherwise, null
  16617. */
  16618. getShadowMap(): Nullable<RenderTargetTexture>;
  16619. /**
  16620. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16621. * @returns The render target texture if the shadow map is present otherwise, null
  16622. */
  16623. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16624. /**
  16625. * Gets the class name of that object
  16626. * @returns "ShadowGenerator"
  16627. */
  16628. getClassName(): string;
  16629. /**
  16630. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16631. * @param mesh Mesh to add
  16632. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16633. * @returns the Shadow Generator itself
  16634. */
  16635. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16636. /**
  16637. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16638. * @param mesh Mesh to remove
  16639. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16640. * @returns the Shadow Generator itself
  16641. */
  16642. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16643. /**
  16644. * Controls the extent to which the shadows fade out at the edge of the frustum
  16645. */
  16646. frustumEdgeFalloff: number;
  16647. protected _light: IShadowLight;
  16648. /**
  16649. * Returns the associated light object.
  16650. * @returns the light generating the shadow
  16651. */
  16652. getLight(): IShadowLight;
  16653. /**
  16654. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16655. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16656. * It might on the other hand introduce peter panning.
  16657. */
  16658. forceBackFacesOnly: boolean;
  16659. protected _scene: Scene;
  16660. protected _lightDirection: Vector3;
  16661. protected _effect: Effect;
  16662. protected _viewMatrix: Matrix;
  16663. protected _projectionMatrix: Matrix;
  16664. protected _transformMatrix: Matrix;
  16665. protected _cachedPosition: Vector3;
  16666. protected _cachedDirection: Vector3;
  16667. protected _cachedDefines: string;
  16668. protected _currentRenderID: number;
  16669. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16670. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16671. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16672. protected _blurPostProcesses: PostProcess[];
  16673. protected _mapSize: number;
  16674. protected _currentFaceIndex: number;
  16675. protected _currentFaceIndexCache: number;
  16676. protected _textureType: number;
  16677. protected _defaultTextureMatrix: Matrix;
  16678. protected _storedUniqueId: Nullable<number>;
  16679. /** @hidden */
  16680. static _SceneComponentInitialization: (scene: Scene) => void;
  16681. /**
  16682. * Creates a ShadowGenerator object.
  16683. * A ShadowGenerator is the required tool to use the shadows.
  16684. * Each light casting shadows needs to use its own ShadowGenerator.
  16685. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  16686. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  16687. * @param light The light object generating the shadows.
  16688. * @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.
  16689. */
  16690. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  16691. protected _initializeGenerator(): void;
  16692. protected _createTargetRenderTexture(): void;
  16693. protected _initializeShadowMap(): void;
  16694. protected _initializeBlurRTTAndPostProcesses(): void;
  16695. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  16696. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  16697. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  16698. protected _applyFilterValues(): void;
  16699. /**
  16700. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16701. * @param onCompiled Callback triggered at the and of the effects compilation
  16702. * @param options Sets of optional options forcing the compilation with different modes
  16703. */
  16704. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16705. useInstances: boolean;
  16706. }>): void;
  16707. /**
  16708. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16709. * @param options Sets of optional options forcing the compilation with different modes
  16710. * @returns A promise that resolves when the compilation completes
  16711. */
  16712. forceCompilationAsync(options?: Partial<{
  16713. useInstances: boolean;
  16714. }>): Promise<void>;
  16715. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  16716. /**
  16717. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16718. * @param subMesh The submesh we want to render in the shadow map
  16719. * @param useInstances Defines wether will draw in the map using instances
  16720. * @returns true if ready otherwise, false
  16721. */
  16722. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16723. /**
  16724. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16725. * @param defines Defines of the material we want to update
  16726. * @param lightIndex Index of the light in the enabled light list of the material
  16727. */
  16728. prepareDefines(defines: any, lightIndex: number): void;
  16729. /**
  16730. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16731. * defined in the generator but impacting the effect).
  16732. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16733. * @param effect The effect we are binfing the information for
  16734. */
  16735. bindShadowLight(lightIndex: string, effect: Effect): void;
  16736. /**
  16737. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16738. * (eq to shadow prjection matrix * light transform matrix)
  16739. * @returns The transform matrix used to create the shadow map
  16740. */
  16741. getTransformMatrix(): Matrix;
  16742. /**
  16743. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16744. * Cube and 2D textures for instance.
  16745. */
  16746. recreateShadowMap(): void;
  16747. protected _disposeBlurPostProcesses(): void;
  16748. protected _disposeRTTandPostProcesses(): void;
  16749. /**
  16750. * Disposes the ShadowGenerator.
  16751. * Returns nothing.
  16752. */
  16753. dispose(): void;
  16754. /**
  16755. * Serializes the shadow generator setup to a json object.
  16756. * @returns The serialized JSON object
  16757. */
  16758. serialize(): any;
  16759. /**
  16760. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  16761. * @param parsedShadowGenerator The JSON object to parse
  16762. * @param scene The scene to create the shadow map for
  16763. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  16764. * @returns The parsed shadow generator
  16765. */
  16766. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  16767. }
  16768. }
  16769. declare module BABYLON {
  16770. /**
  16771. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  16772. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  16773. * 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.
  16774. */
  16775. export abstract class Light extends Node {
  16776. /**
  16777. * Falloff Default: light is falling off following the material specification:
  16778. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  16779. */
  16780. static readonly FALLOFF_DEFAULT: number;
  16781. /**
  16782. * Falloff Physical: light is falling off following the inverse squared distance law.
  16783. */
  16784. static readonly FALLOFF_PHYSICAL: number;
  16785. /**
  16786. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  16787. * to enhance interoperability with other engines.
  16788. */
  16789. static readonly FALLOFF_GLTF: number;
  16790. /**
  16791. * Falloff Standard: light is falling off like in the standard material
  16792. * to enhance interoperability with other materials.
  16793. */
  16794. static readonly FALLOFF_STANDARD: number;
  16795. /**
  16796. * If every light affecting the material is in this lightmapMode,
  16797. * material.lightmapTexture adds or multiplies
  16798. * (depends on material.useLightmapAsShadowmap)
  16799. * after every other light calculations.
  16800. */
  16801. static readonly LIGHTMAP_DEFAULT: number;
  16802. /**
  16803. * material.lightmapTexture as only diffuse lighting from this light
  16804. * adds only specular lighting from this light
  16805. * adds dynamic shadows
  16806. */
  16807. static readonly LIGHTMAP_SPECULAR: number;
  16808. /**
  16809. * material.lightmapTexture as only lighting
  16810. * no light calculation from this light
  16811. * only adds dynamic shadows from this light
  16812. */
  16813. static readonly LIGHTMAP_SHADOWSONLY: number;
  16814. /**
  16815. * Each light type uses the default quantity according to its type:
  16816. * point/spot lights use luminous intensity
  16817. * directional lights use illuminance
  16818. */
  16819. static readonly INTENSITYMODE_AUTOMATIC: number;
  16820. /**
  16821. * lumen (lm)
  16822. */
  16823. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  16824. /**
  16825. * candela (lm/sr)
  16826. */
  16827. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  16828. /**
  16829. * lux (lm/m^2)
  16830. */
  16831. static readonly INTENSITYMODE_ILLUMINANCE: number;
  16832. /**
  16833. * nit (cd/m^2)
  16834. */
  16835. static readonly INTENSITYMODE_LUMINANCE: number;
  16836. /**
  16837. * Light type const id of the point light.
  16838. */
  16839. static readonly LIGHTTYPEID_POINTLIGHT: number;
  16840. /**
  16841. * Light type const id of the directional light.
  16842. */
  16843. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  16844. /**
  16845. * Light type const id of the spot light.
  16846. */
  16847. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  16848. /**
  16849. * Light type const id of the hemispheric light.
  16850. */
  16851. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  16852. /**
  16853. * Diffuse gives the basic color to an object.
  16854. */
  16855. diffuse: Color3;
  16856. /**
  16857. * Specular produces a highlight color on an object.
  16858. * Note: This is note affecting PBR materials.
  16859. */
  16860. specular: Color3;
  16861. /**
  16862. * Defines the falloff type for this light. This lets overrriding how punctual light are
  16863. * falling off base on range or angle.
  16864. * This can be set to any values in Light.FALLOFF_x.
  16865. *
  16866. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  16867. * other types of materials.
  16868. */
  16869. falloffType: number;
  16870. /**
  16871. * Strength of the light.
  16872. * Note: By default it is define in the framework own unit.
  16873. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  16874. */
  16875. intensity: number;
  16876. private _range;
  16877. protected _inverseSquaredRange: number;
  16878. /**
  16879. * Defines how far from the source the light is impacting in scene units.
  16880. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16881. */
  16882. get range(): number;
  16883. /**
  16884. * Defines how far from the source the light is impacting in scene units.
  16885. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16886. */
  16887. set range(value: number);
  16888. /**
  16889. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  16890. * of light.
  16891. */
  16892. private _photometricScale;
  16893. private _intensityMode;
  16894. /**
  16895. * Gets the photometric scale used to interpret the intensity.
  16896. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16897. */
  16898. get intensityMode(): number;
  16899. /**
  16900. * Sets the photometric scale used to interpret the intensity.
  16901. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16902. */
  16903. set intensityMode(value: number);
  16904. private _radius;
  16905. /**
  16906. * Gets the light radius used by PBR Materials to simulate soft area lights.
  16907. */
  16908. get radius(): number;
  16909. /**
  16910. * sets the light radius used by PBR Materials to simulate soft area lights.
  16911. */
  16912. set radius(value: number);
  16913. private _renderPriority;
  16914. /**
  16915. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  16916. * exceeding the number allowed of the materials.
  16917. */
  16918. renderPriority: number;
  16919. private _shadowEnabled;
  16920. /**
  16921. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16922. * the current shadow generator.
  16923. */
  16924. get shadowEnabled(): boolean;
  16925. /**
  16926. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16927. * the current shadow generator.
  16928. */
  16929. set shadowEnabled(value: boolean);
  16930. private _includedOnlyMeshes;
  16931. /**
  16932. * Gets the only meshes impacted by this light.
  16933. */
  16934. get includedOnlyMeshes(): AbstractMesh[];
  16935. /**
  16936. * Sets the only meshes impacted by this light.
  16937. */
  16938. set includedOnlyMeshes(value: AbstractMesh[]);
  16939. private _excludedMeshes;
  16940. /**
  16941. * Gets the meshes not impacted by this light.
  16942. */
  16943. get excludedMeshes(): AbstractMesh[];
  16944. /**
  16945. * Sets the meshes not impacted by this light.
  16946. */
  16947. set excludedMeshes(value: AbstractMesh[]);
  16948. private _excludeWithLayerMask;
  16949. /**
  16950. * Gets the layer id use to find what meshes are not impacted by the light.
  16951. * Inactive if 0
  16952. */
  16953. get excludeWithLayerMask(): number;
  16954. /**
  16955. * Sets the layer id use to find what meshes are not impacted by the light.
  16956. * Inactive if 0
  16957. */
  16958. set excludeWithLayerMask(value: number);
  16959. private _includeOnlyWithLayerMask;
  16960. /**
  16961. * Gets the layer id use to find what meshes are impacted by the light.
  16962. * Inactive if 0
  16963. */
  16964. get includeOnlyWithLayerMask(): number;
  16965. /**
  16966. * Sets the layer id use to find what meshes are impacted by the light.
  16967. * Inactive if 0
  16968. */
  16969. set includeOnlyWithLayerMask(value: number);
  16970. private _lightmapMode;
  16971. /**
  16972. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  16973. */
  16974. get lightmapMode(): number;
  16975. /**
  16976. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  16977. */
  16978. set lightmapMode(value: number);
  16979. /**
  16980. * Shadow generator associted to the light.
  16981. * @hidden Internal use only.
  16982. */
  16983. _shadowGenerator: Nullable<IShadowGenerator>;
  16984. /**
  16985. * @hidden Internal use only.
  16986. */
  16987. _excludedMeshesIds: string[];
  16988. /**
  16989. * @hidden Internal use only.
  16990. */
  16991. _includedOnlyMeshesIds: string[];
  16992. /**
  16993. * The current light unifom buffer.
  16994. * @hidden Internal use only.
  16995. */
  16996. _uniformBuffer: UniformBuffer;
  16997. /** @hidden */
  16998. _renderId: number;
  16999. /**
  17000. * Creates a Light object in the scene.
  17001. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17002. * @param name The firendly name of the light
  17003. * @param scene The scene the light belongs too
  17004. */
  17005. constructor(name: string, scene: Scene);
  17006. protected abstract _buildUniformLayout(): void;
  17007. /**
  17008. * Sets the passed Effect "effect" with the Light information.
  17009. * @param effect The effect to update
  17010. * @param lightIndex The index of the light in the effect to update
  17011. * @returns The light
  17012. */
  17013. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17014. /**
  17015. * Sets the passed Effect "effect" with the Light textures.
  17016. * @param effect The effect to update
  17017. * @param lightIndex The index of the light in the effect to update
  17018. * @returns The light
  17019. */
  17020. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17021. /**
  17022. * Binds the lights information from the scene to the effect for the given mesh.
  17023. * @param lightIndex Light index
  17024. * @param scene The scene where the light belongs to
  17025. * @param effect The effect we are binding the data to
  17026. * @param useSpecular Defines if specular is supported
  17027. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17028. */
  17029. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17030. /**
  17031. * Sets the passed Effect "effect" with the Light information.
  17032. * @param effect The effect to update
  17033. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17034. * @returns The light
  17035. */
  17036. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17037. /**
  17038. * Returns the string "Light".
  17039. * @returns the class name
  17040. */
  17041. getClassName(): string;
  17042. /** @hidden */
  17043. readonly _isLight: boolean;
  17044. /**
  17045. * Converts the light information to a readable string for debug purpose.
  17046. * @param fullDetails Supports for multiple levels of logging within scene loading
  17047. * @returns the human readable light info
  17048. */
  17049. toString(fullDetails?: boolean): string;
  17050. /** @hidden */
  17051. protected _syncParentEnabledState(): void;
  17052. /**
  17053. * Set the enabled state of this node.
  17054. * @param value - the new enabled state
  17055. */
  17056. setEnabled(value: boolean): void;
  17057. /**
  17058. * Returns the Light associated shadow generator if any.
  17059. * @return the associated shadow generator.
  17060. */
  17061. getShadowGenerator(): Nullable<IShadowGenerator>;
  17062. /**
  17063. * Returns a Vector3, the absolute light position in the World.
  17064. * @returns the world space position of the light
  17065. */
  17066. getAbsolutePosition(): Vector3;
  17067. /**
  17068. * Specifies if the light will affect the passed mesh.
  17069. * @param mesh The mesh to test against the light
  17070. * @return true the mesh is affected otherwise, false.
  17071. */
  17072. canAffectMesh(mesh: AbstractMesh): boolean;
  17073. /**
  17074. * Sort function to order lights for rendering.
  17075. * @param a First Light object to compare to second.
  17076. * @param b Second Light object to compare first.
  17077. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17078. */
  17079. static CompareLightsPriority(a: Light, b: Light): number;
  17080. /**
  17081. * Releases resources associated with this node.
  17082. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17083. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17084. */
  17085. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17086. /**
  17087. * Returns the light type ID (integer).
  17088. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17089. */
  17090. getTypeID(): number;
  17091. /**
  17092. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17093. * @returns the scaled intensity in intensity mode unit
  17094. */
  17095. getScaledIntensity(): number;
  17096. /**
  17097. * Returns a new Light object, named "name", from the current one.
  17098. * @param name The name of the cloned light
  17099. * @returns the new created light
  17100. */
  17101. clone(name: string): Nullable<Light>;
  17102. /**
  17103. * Serializes the current light into a Serialization object.
  17104. * @returns the serialized object.
  17105. */
  17106. serialize(): any;
  17107. /**
  17108. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17109. * This new light is named "name" and added to the passed scene.
  17110. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17111. * @param name The friendly name of the light
  17112. * @param scene The scene the new light will belong to
  17113. * @returns the constructor function
  17114. */
  17115. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17116. /**
  17117. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17118. * @param parsedLight The JSON representation of the light
  17119. * @param scene The scene to create the parsed light in
  17120. * @returns the created light after parsing
  17121. */
  17122. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17123. private _hookArrayForExcluded;
  17124. private _hookArrayForIncludedOnly;
  17125. private _resyncMeshes;
  17126. /**
  17127. * Forces the meshes to update their light related information in their rendering used effects
  17128. * @hidden Internal Use Only
  17129. */
  17130. _markMeshesAsLightDirty(): void;
  17131. /**
  17132. * Recomputes the cached photometric scale if needed.
  17133. */
  17134. private _computePhotometricScale;
  17135. /**
  17136. * Returns the Photometric Scale according to the light type and intensity mode.
  17137. */
  17138. private _getPhotometricScale;
  17139. /**
  17140. * Reorder the light in the scene according to their defined priority.
  17141. * @hidden Internal Use Only
  17142. */
  17143. _reorderLightsInScene(): void;
  17144. /**
  17145. * Prepares the list of defines specific to the light type.
  17146. * @param defines the list of defines
  17147. * @param lightIndex defines the index of the light for the effect
  17148. */
  17149. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17150. }
  17151. }
  17152. declare module BABYLON {
  17153. /**
  17154. * Interface used to define Action
  17155. */
  17156. export interface IAction {
  17157. /**
  17158. * Trigger for the action
  17159. */
  17160. trigger: number;
  17161. /** Options of the trigger */
  17162. triggerOptions: any;
  17163. /**
  17164. * Gets the trigger parameters
  17165. * @returns the trigger parameters
  17166. */
  17167. getTriggerParameter(): any;
  17168. /**
  17169. * Internal only - executes current action event
  17170. * @hidden
  17171. */
  17172. _executeCurrent(evt?: ActionEvent): void;
  17173. /**
  17174. * Serialize placeholder for child classes
  17175. * @param parent of child
  17176. * @returns the serialized object
  17177. */
  17178. serialize(parent: any): any;
  17179. /**
  17180. * Internal only
  17181. * @hidden
  17182. */
  17183. _prepare(): void;
  17184. /**
  17185. * Internal only - manager for action
  17186. * @hidden
  17187. */
  17188. _actionManager: AbstractActionManager;
  17189. /**
  17190. * Adds action to chain of actions, may be a DoNothingAction
  17191. * @param action defines the next action to execute
  17192. * @returns The action passed in
  17193. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17194. */
  17195. then(action: IAction): IAction;
  17196. }
  17197. /**
  17198. * The action to be carried out following a trigger
  17199. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17200. */
  17201. export class Action implements IAction {
  17202. /** the trigger, with or without parameters, for the action */
  17203. triggerOptions: any;
  17204. /**
  17205. * Trigger for the action
  17206. */
  17207. trigger: number;
  17208. /**
  17209. * Internal only - manager for action
  17210. * @hidden
  17211. */
  17212. _actionManager: ActionManager;
  17213. private _nextActiveAction;
  17214. private _child;
  17215. private _condition?;
  17216. private _triggerParameter;
  17217. /**
  17218. * An event triggered prior to action being executed.
  17219. */
  17220. onBeforeExecuteObservable: Observable<Action>;
  17221. /**
  17222. * Creates a new Action
  17223. * @param triggerOptions the trigger, with or without parameters, for the action
  17224. * @param condition an optional determinant of action
  17225. */
  17226. constructor(
  17227. /** the trigger, with or without parameters, for the action */
  17228. triggerOptions: any, condition?: Condition);
  17229. /**
  17230. * Internal only
  17231. * @hidden
  17232. */
  17233. _prepare(): void;
  17234. /**
  17235. * Gets the trigger parameters
  17236. * @returns the trigger parameters
  17237. */
  17238. getTriggerParameter(): any;
  17239. /**
  17240. * Internal only - executes current action event
  17241. * @hidden
  17242. */
  17243. _executeCurrent(evt?: ActionEvent): void;
  17244. /**
  17245. * Execute placeholder for child classes
  17246. * @param evt optional action event
  17247. */
  17248. execute(evt?: ActionEvent): void;
  17249. /**
  17250. * Skips to next active action
  17251. */
  17252. skipToNextActiveAction(): void;
  17253. /**
  17254. * Adds action to chain of actions, may be a DoNothingAction
  17255. * @param action defines the next action to execute
  17256. * @returns The action passed in
  17257. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17258. */
  17259. then(action: Action): Action;
  17260. /**
  17261. * Internal only
  17262. * @hidden
  17263. */
  17264. _getProperty(propertyPath: string): string;
  17265. /**
  17266. * Internal only
  17267. * @hidden
  17268. */
  17269. _getEffectiveTarget(target: any, propertyPath: string): any;
  17270. /**
  17271. * Serialize placeholder for child classes
  17272. * @param parent of child
  17273. * @returns the serialized object
  17274. */
  17275. serialize(parent: any): any;
  17276. /**
  17277. * Internal only called by serialize
  17278. * @hidden
  17279. */
  17280. protected _serialize(serializedAction: any, parent?: any): any;
  17281. /**
  17282. * Internal only
  17283. * @hidden
  17284. */
  17285. static _SerializeValueAsString: (value: any) => string;
  17286. /**
  17287. * Internal only
  17288. * @hidden
  17289. */
  17290. static _GetTargetProperty: (target: Node | Scene) => {
  17291. name: string;
  17292. targetType: string;
  17293. value: string;
  17294. };
  17295. }
  17296. }
  17297. declare module BABYLON {
  17298. /**
  17299. * A Condition applied to an Action
  17300. */
  17301. export class Condition {
  17302. /**
  17303. * Internal only - manager for action
  17304. * @hidden
  17305. */
  17306. _actionManager: ActionManager;
  17307. /**
  17308. * Internal only
  17309. * @hidden
  17310. */
  17311. _evaluationId: number;
  17312. /**
  17313. * Internal only
  17314. * @hidden
  17315. */
  17316. _currentResult: boolean;
  17317. /**
  17318. * Creates a new Condition
  17319. * @param actionManager the manager of the action the condition is applied to
  17320. */
  17321. constructor(actionManager: ActionManager);
  17322. /**
  17323. * Check if the current condition is valid
  17324. * @returns a boolean
  17325. */
  17326. isValid(): boolean;
  17327. /**
  17328. * Internal only
  17329. * @hidden
  17330. */
  17331. _getProperty(propertyPath: string): string;
  17332. /**
  17333. * Internal only
  17334. * @hidden
  17335. */
  17336. _getEffectiveTarget(target: any, propertyPath: string): any;
  17337. /**
  17338. * Serialize placeholder for child classes
  17339. * @returns the serialized object
  17340. */
  17341. serialize(): any;
  17342. /**
  17343. * Internal only
  17344. * @hidden
  17345. */
  17346. protected _serialize(serializedCondition: any): any;
  17347. }
  17348. /**
  17349. * Defines specific conditional operators as extensions of Condition
  17350. */
  17351. export class ValueCondition extends Condition {
  17352. /** path to specify the property of the target the conditional operator uses */
  17353. propertyPath: string;
  17354. /** the value compared by the conditional operator against the current value of the property */
  17355. value: any;
  17356. /** the conditional operator, default ValueCondition.IsEqual */
  17357. operator: number;
  17358. /**
  17359. * Internal only
  17360. * @hidden
  17361. */
  17362. private static _IsEqual;
  17363. /**
  17364. * Internal only
  17365. * @hidden
  17366. */
  17367. private static _IsDifferent;
  17368. /**
  17369. * Internal only
  17370. * @hidden
  17371. */
  17372. private static _IsGreater;
  17373. /**
  17374. * Internal only
  17375. * @hidden
  17376. */
  17377. private static _IsLesser;
  17378. /**
  17379. * returns the number for IsEqual
  17380. */
  17381. static get IsEqual(): number;
  17382. /**
  17383. * Returns the number for IsDifferent
  17384. */
  17385. static get IsDifferent(): number;
  17386. /**
  17387. * Returns the number for IsGreater
  17388. */
  17389. static get IsGreater(): number;
  17390. /**
  17391. * Returns the number for IsLesser
  17392. */
  17393. static get IsLesser(): number;
  17394. /**
  17395. * Internal only The action manager for the condition
  17396. * @hidden
  17397. */
  17398. _actionManager: ActionManager;
  17399. /**
  17400. * Internal only
  17401. * @hidden
  17402. */
  17403. private _target;
  17404. /**
  17405. * Internal only
  17406. * @hidden
  17407. */
  17408. private _effectiveTarget;
  17409. /**
  17410. * Internal only
  17411. * @hidden
  17412. */
  17413. private _property;
  17414. /**
  17415. * Creates a new ValueCondition
  17416. * @param actionManager manager for the action the condition applies to
  17417. * @param target for the action
  17418. * @param propertyPath path to specify the property of the target the conditional operator uses
  17419. * @param value the value compared by the conditional operator against the current value of the property
  17420. * @param operator the conditional operator, default ValueCondition.IsEqual
  17421. */
  17422. constructor(actionManager: ActionManager, target: any,
  17423. /** path to specify the property of the target the conditional operator uses */
  17424. propertyPath: string,
  17425. /** the value compared by the conditional operator against the current value of the property */
  17426. value: any,
  17427. /** the conditional operator, default ValueCondition.IsEqual */
  17428. operator?: number);
  17429. /**
  17430. * Compares the given value with the property value for the specified conditional operator
  17431. * @returns the result of the comparison
  17432. */
  17433. isValid(): boolean;
  17434. /**
  17435. * Serialize the ValueCondition into a JSON compatible object
  17436. * @returns serialization object
  17437. */
  17438. serialize(): any;
  17439. /**
  17440. * Gets the name of the conditional operator for the ValueCondition
  17441. * @param operator the conditional operator
  17442. * @returns the name
  17443. */
  17444. static GetOperatorName(operator: number): string;
  17445. }
  17446. /**
  17447. * Defines a predicate condition as an extension of Condition
  17448. */
  17449. export class PredicateCondition extends Condition {
  17450. /** defines the predicate function used to validate the condition */
  17451. predicate: () => boolean;
  17452. /**
  17453. * Internal only - manager for action
  17454. * @hidden
  17455. */
  17456. _actionManager: ActionManager;
  17457. /**
  17458. * Creates a new PredicateCondition
  17459. * @param actionManager manager for the action the condition applies to
  17460. * @param predicate defines the predicate function used to validate the condition
  17461. */
  17462. constructor(actionManager: ActionManager,
  17463. /** defines the predicate function used to validate the condition */
  17464. predicate: () => boolean);
  17465. /**
  17466. * @returns the validity of the predicate condition
  17467. */
  17468. isValid(): boolean;
  17469. }
  17470. /**
  17471. * Defines a state condition as an extension of Condition
  17472. */
  17473. export class StateCondition extends Condition {
  17474. /** Value to compare with target state */
  17475. value: string;
  17476. /**
  17477. * Internal only - manager for action
  17478. * @hidden
  17479. */
  17480. _actionManager: ActionManager;
  17481. /**
  17482. * Internal only
  17483. * @hidden
  17484. */
  17485. private _target;
  17486. /**
  17487. * Creates a new StateCondition
  17488. * @param actionManager manager for the action the condition applies to
  17489. * @param target of the condition
  17490. * @param value to compare with target state
  17491. */
  17492. constructor(actionManager: ActionManager, target: any,
  17493. /** Value to compare with target state */
  17494. value: string);
  17495. /**
  17496. * Gets a boolean indicating if the current condition is met
  17497. * @returns the validity of the state
  17498. */
  17499. isValid(): boolean;
  17500. /**
  17501. * Serialize the StateCondition into a JSON compatible object
  17502. * @returns serialization object
  17503. */
  17504. serialize(): any;
  17505. }
  17506. }
  17507. declare module BABYLON {
  17508. /**
  17509. * This defines an action responsible to toggle a boolean once triggered.
  17510. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17511. */
  17512. export class SwitchBooleanAction extends Action {
  17513. /**
  17514. * The path to the boolean property in the target object
  17515. */
  17516. propertyPath: string;
  17517. private _target;
  17518. private _effectiveTarget;
  17519. private _property;
  17520. /**
  17521. * Instantiate the action
  17522. * @param triggerOptions defines the trigger options
  17523. * @param target defines the object containing the boolean
  17524. * @param propertyPath defines the path to the boolean property in the target object
  17525. * @param condition defines the trigger related conditions
  17526. */
  17527. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17528. /** @hidden */
  17529. _prepare(): void;
  17530. /**
  17531. * Execute the action toggle the boolean value.
  17532. */
  17533. execute(): void;
  17534. /**
  17535. * Serializes the actions and its related information.
  17536. * @param parent defines the object to serialize in
  17537. * @returns the serialized object
  17538. */
  17539. serialize(parent: any): any;
  17540. }
  17541. /**
  17542. * This defines an action responsible to set a the state field of the target
  17543. * to a desired value once triggered.
  17544. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17545. */
  17546. export class SetStateAction extends Action {
  17547. /**
  17548. * The value to store in the state field.
  17549. */
  17550. value: string;
  17551. private _target;
  17552. /**
  17553. * Instantiate the action
  17554. * @param triggerOptions defines the trigger options
  17555. * @param target defines the object containing the state property
  17556. * @param value defines the value to store in the state field
  17557. * @param condition defines the trigger related conditions
  17558. */
  17559. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17560. /**
  17561. * Execute the action and store the value on the target state property.
  17562. */
  17563. execute(): void;
  17564. /**
  17565. * Serializes the actions and its related information.
  17566. * @param parent defines the object to serialize in
  17567. * @returns the serialized object
  17568. */
  17569. serialize(parent: any): any;
  17570. }
  17571. /**
  17572. * This defines an action responsible to set a property of the target
  17573. * to a desired value once triggered.
  17574. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17575. */
  17576. export class SetValueAction extends Action {
  17577. /**
  17578. * The path of the property to set in the target.
  17579. */
  17580. propertyPath: string;
  17581. /**
  17582. * The value to set in the property
  17583. */
  17584. value: any;
  17585. private _target;
  17586. private _effectiveTarget;
  17587. private _property;
  17588. /**
  17589. * Instantiate the action
  17590. * @param triggerOptions defines the trigger options
  17591. * @param target defines the object containing the property
  17592. * @param propertyPath defines the path of the property to set in the target
  17593. * @param value defines the value to set in the property
  17594. * @param condition defines the trigger related conditions
  17595. */
  17596. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17597. /** @hidden */
  17598. _prepare(): void;
  17599. /**
  17600. * Execute the action and set the targetted property to the desired value.
  17601. */
  17602. execute(): void;
  17603. /**
  17604. * Serializes the actions and its related information.
  17605. * @param parent defines the object to serialize in
  17606. * @returns the serialized object
  17607. */
  17608. serialize(parent: any): any;
  17609. }
  17610. /**
  17611. * This defines an action responsible to increment the target value
  17612. * to a desired value once triggered.
  17613. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17614. */
  17615. export class IncrementValueAction extends Action {
  17616. /**
  17617. * The path of the property to increment in the target.
  17618. */
  17619. propertyPath: string;
  17620. /**
  17621. * The value we should increment the property by.
  17622. */
  17623. value: any;
  17624. private _target;
  17625. private _effectiveTarget;
  17626. private _property;
  17627. /**
  17628. * Instantiate the action
  17629. * @param triggerOptions defines the trigger options
  17630. * @param target defines the object containing the property
  17631. * @param propertyPath defines the path of the property to increment in the target
  17632. * @param value defines the value value we should increment the property by
  17633. * @param condition defines the trigger related conditions
  17634. */
  17635. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17636. /** @hidden */
  17637. _prepare(): void;
  17638. /**
  17639. * Execute the action and increment the target of the value amount.
  17640. */
  17641. execute(): void;
  17642. /**
  17643. * Serializes the actions and its related information.
  17644. * @param parent defines the object to serialize in
  17645. * @returns the serialized object
  17646. */
  17647. serialize(parent: any): any;
  17648. }
  17649. /**
  17650. * This defines an action responsible to start an animation once triggered.
  17651. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17652. */
  17653. export class PlayAnimationAction extends Action {
  17654. /**
  17655. * Where the animation should start (animation frame)
  17656. */
  17657. from: number;
  17658. /**
  17659. * Where the animation should stop (animation frame)
  17660. */
  17661. to: number;
  17662. /**
  17663. * Define if the animation should loop or stop after the first play.
  17664. */
  17665. loop?: boolean;
  17666. private _target;
  17667. /**
  17668. * Instantiate the action
  17669. * @param triggerOptions defines the trigger options
  17670. * @param target defines the target animation or animation name
  17671. * @param from defines from where the animation should start (animation frame)
  17672. * @param end defines where the animation should stop (animation frame)
  17673. * @param loop defines if the animation should loop or stop after the first play
  17674. * @param condition defines the trigger related conditions
  17675. */
  17676. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  17677. /** @hidden */
  17678. _prepare(): void;
  17679. /**
  17680. * Execute the action and play the animation.
  17681. */
  17682. execute(): void;
  17683. /**
  17684. * Serializes the actions and its related information.
  17685. * @param parent defines the object to serialize in
  17686. * @returns the serialized object
  17687. */
  17688. serialize(parent: any): any;
  17689. }
  17690. /**
  17691. * This defines an action responsible to stop an animation once triggered.
  17692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17693. */
  17694. export class StopAnimationAction extends Action {
  17695. private _target;
  17696. /**
  17697. * Instantiate the action
  17698. * @param triggerOptions defines the trigger options
  17699. * @param target defines the target animation or animation name
  17700. * @param condition defines the trigger related conditions
  17701. */
  17702. constructor(triggerOptions: any, target: any, condition?: Condition);
  17703. /** @hidden */
  17704. _prepare(): void;
  17705. /**
  17706. * Execute the action and stop the animation.
  17707. */
  17708. execute(): void;
  17709. /**
  17710. * Serializes the actions and its related information.
  17711. * @param parent defines the object to serialize in
  17712. * @returns the serialized object
  17713. */
  17714. serialize(parent: any): any;
  17715. }
  17716. /**
  17717. * This defines an action responsible that does nothing once triggered.
  17718. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17719. */
  17720. export class DoNothingAction extends Action {
  17721. /**
  17722. * Instantiate the action
  17723. * @param triggerOptions defines the trigger options
  17724. * @param condition defines the trigger related conditions
  17725. */
  17726. constructor(triggerOptions?: any, condition?: Condition);
  17727. /**
  17728. * Execute the action and do nothing.
  17729. */
  17730. execute(): void;
  17731. /**
  17732. * Serializes the actions and its related information.
  17733. * @param parent defines the object to serialize in
  17734. * @returns the serialized object
  17735. */
  17736. serialize(parent: any): any;
  17737. }
  17738. /**
  17739. * This defines an action responsible to trigger several actions once triggered.
  17740. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17741. */
  17742. export class CombineAction extends Action {
  17743. /**
  17744. * The list of aggregated animations to run.
  17745. */
  17746. children: Action[];
  17747. /**
  17748. * Instantiate the action
  17749. * @param triggerOptions defines the trigger options
  17750. * @param children defines the list of aggregated animations to run
  17751. * @param condition defines the trigger related conditions
  17752. */
  17753. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  17754. /** @hidden */
  17755. _prepare(): void;
  17756. /**
  17757. * Execute the action and executes all the aggregated actions.
  17758. */
  17759. execute(evt: ActionEvent): void;
  17760. /**
  17761. * Serializes the actions and its related information.
  17762. * @param parent defines the object to serialize in
  17763. * @returns the serialized object
  17764. */
  17765. serialize(parent: any): any;
  17766. }
  17767. /**
  17768. * This defines an action responsible to run code (external event) once triggered.
  17769. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17770. */
  17771. export class ExecuteCodeAction extends Action {
  17772. /**
  17773. * The callback function to run.
  17774. */
  17775. func: (evt: ActionEvent) => void;
  17776. /**
  17777. * Instantiate the action
  17778. * @param triggerOptions defines the trigger options
  17779. * @param func defines the callback function to run
  17780. * @param condition defines the trigger related conditions
  17781. */
  17782. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  17783. /**
  17784. * Execute the action and run the attached code.
  17785. */
  17786. execute(evt: ActionEvent): void;
  17787. }
  17788. /**
  17789. * This defines an action responsible to set the parent property of the target once triggered.
  17790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17791. */
  17792. export class SetParentAction extends Action {
  17793. private _parent;
  17794. private _target;
  17795. /**
  17796. * Instantiate the action
  17797. * @param triggerOptions defines the trigger options
  17798. * @param target defines the target containing the parent property
  17799. * @param parent defines from where the animation should start (animation frame)
  17800. * @param condition defines the trigger related conditions
  17801. */
  17802. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  17803. /** @hidden */
  17804. _prepare(): void;
  17805. /**
  17806. * Execute the action and set the parent property.
  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. declare module BABYLON {
  17818. /**
  17819. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  17820. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  17821. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17822. */
  17823. export class ActionManager extends AbstractActionManager {
  17824. /**
  17825. * Nothing
  17826. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17827. */
  17828. static readonly NothingTrigger: number;
  17829. /**
  17830. * On pick
  17831. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17832. */
  17833. static readonly OnPickTrigger: number;
  17834. /**
  17835. * On left pick
  17836. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17837. */
  17838. static readonly OnLeftPickTrigger: number;
  17839. /**
  17840. * On right pick
  17841. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17842. */
  17843. static readonly OnRightPickTrigger: number;
  17844. /**
  17845. * On center pick
  17846. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17847. */
  17848. static readonly OnCenterPickTrigger: number;
  17849. /**
  17850. * On pick down
  17851. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17852. */
  17853. static readonly OnPickDownTrigger: number;
  17854. /**
  17855. * On double pick
  17856. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17857. */
  17858. static readonly OnDoublePickTrigger: number;
  17859. /**
  17860. * On pick up
  17861. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17862. */
  17863. static readonly OnPickUpTrigger: number;
  17864. /**
  17865. * On pick out.
  17866. * This trigger will only be raised if you also declared a OnPickDown
  17867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17868. */
  17869. static readonly OnPickOutTrigger: number;
  17870. /**
  17871. * On long press
  17872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17873. */
  17874. static readonly OnLongPressTrigger: number;
  17875. /**
  17876. * On pointer over
  17877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17878. */
  17879. static readonly OnPointerOverTrigger: number;
  17880. /**
  17881. * On pointer out
  17882. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17883. */
  17884. static readonly OnPointerOutTrigger: number;
  17885. /**
  17886. * On every frame
  17887. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17888. */
  17889. static readonly OnEveryFrameTrigger: number;
  17890. /**
  17891. * On intersection enter
  17892. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17893. */
  17894. static readonly OnIntersectionEnterTrigger: number;
  17895. /**
  17896. * On intersection exit
  17897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17898. */
  17899. static readonly OnIntersectionExitTrigger: number;
  17900. /**
  17901. * On key down
  17902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17903. */
  17904. static readonly OnKeyDownTrigger: number;
  17905. /**
  17906. * On key up
  17907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17908. */
  17909. static readonly OnKeyUpTrigger: number;
  17910. private _scene;
  17911. /**
  17912. * Creates a new action manager
  17913. * @param scene defines the hosting scene
  17914. */
  17915. constructor(scene: Scene);
  17916. /**
  17917. * Releases all associated resources
  17918. */
  17919. dispose(): void;
  17920. /**
  17921. * Gets hosting scene
  17922. * @returns the hosting scene
  17923. */
  17924. getScene(): Scene;
  17925. /**
  17926. * Does this action manager handles actions of any of the given triggers
  17927. * @param triggers defines the triggers to be tested
  17928. * @return a boolean indicating whether one (or more) of the triggers is handled
  17929. */
  17930. hasSpecificTriggers(triggers: number[]): boolean;
  17931. /**
  17932. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  17933. * speed.
  17934. * @param triggerA defines the trigger to be tested
  17935. * @param triggerB defines the trigger to be tested
  17936. * @return a boolean indicating whether one (or more) of the triggers is handled
  17937. */
  17938. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  17939. /**
  17940. * Does this action manager handles actions of a given trigger
  17941. * @param trigger defines the trigger to be tested
  17942. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  17943. * @return whether the trigger is handled
  17944. */
  17945. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  17946. /**
  17947. * Does this action manager has pointer triggers
  17948. */
  17949. get hasPointerTriggers(): boolean;
  17950. /**
  17951. * Does this action manager has pick triggers
  17952. */
  17953. get hasPickTriggers(): boolean;
  17954. /**
  17955. * Registers an action to this action manager
  17956. * @param action defines the action to be registered
  17957. * @return the action amended (prepared) after registration
  17958. */
  17959. registerAction(action: IAction): Nullable<IAction>;
  17960. /**
  17961. * Unregisters an action to this action manager
  17962. * @param action defines the action to be unregistered
  17963. * @return a boolean indicating whether the action has been unregistered
  17964. */
  17965. unregisterAction(action: IAction): Boolean;
  17966. /**
  17967. * Process a specific trigger
  17968. * @param trigger defines the trigger to process
  17969. * @param evt defines the event details to be processed
  17970. */
  17971. processTrigger(trigger: number, evt?: IActionEvent): void;
  17972. /** @hidden */
  17973. _getEffectiveTarget(target: any, propertyPath: string): any;
  17974. /** @hidden */
  17975. _getProperty(propertyPath: string): string;
  17976. /**
  17977. * Serialize this manager to a JSON object
  17978. * @param name defines the property name to store this manager
  17979. * @returns a JSON representation of this manager
  17980. */
  17981. serialize(name: string): any;
  17982. /**
  17983. * Creates a new ActionManager from a JSON data
  17984. * @param parsedActions defines the JSON data to read from
  17985. * @param object defines the hosting mesh
  17986. * @param scene defines the hosting scene
  17987. */
  17988. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  17989. /**
  17990. * Get a trigger name by index
  17991. * @param trigger defines the trigger index
  17992. * @returns a trigger name
  17993. */
  17994. static GetTriggerName(trigger: number): string;
  17995. }
  17996. }
  17997. declare module BABYLON {
  17998. /**
  17999. * Class used to represent a sprite
  18000. * @see http://doc.babylonjs.com/babylon101/sprites
  18001. */
  18002. export class Sprite {
  18003. /** defines the name */
  18004. name: string;
  18005. /** Gets or sets the current world position */
  18006. position: Vector3;
  18007. /** Gets or sets the main color */
  18008. color: Color4;
  18009. /** Gets or sets the width */
  18010. width: number;
  18011. /** Gets or sets the height */
  18012. height: number;
  18013. /** Gets or sets rotation angle */
  18014. angle: number;
  18015. /** Gets or sets the cell index in the sprite sheet */
  18016. cellIndex: number;
  18017. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18018. cellRef: string;
  18019. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18020. invertU: number;
  18021. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18022. invertV: number;
  18023. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18024. disposeWhenFinishedAnimating: boolean;
  18025. /** Gets the list of attached animations */
  18026. animations: Animation[];
  18027. /** Gets or sets a boolean indicating if the sprite can be picked */
  18028. isPickable: boolean;
  18029. /**
  18030. * Gets or sets the associated action manager
  18031. */
  18032. actionManager: Nullable<ActionManager>;
  18033. private _animationStarted;
  18034. private _loopAnimation;
  18035. private _fromIndex;
  18036. private _toIndex;
  18037. private _delay;
  18038. private _direction;
  18039. private _manager;
  18040. private _time;
  18041. private _onAnimationEnd;
  18042. /**
  18043. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18044. */
  18045. isVisible: boolean;
  18046. /**
  18047. * Gets or sets the sprite size
  18048. */
  18049. get size(): number;
  18050. set size(value: number);
  18051. /**
  18052. * Creates a new Sprite
  18053. * @param name defines the name
  18054. * @param manager defines the manager
  18055. */
  18056. constructor(
  18057. /** defines the name */
  18058. name: string, manager: ISpriteManager);
  18059. /**
  18060. * Starts an animation
  18061. * @param from defines the initial key
  18062. * @param to defines the end key
  18063. * @param loop defines if the animation must loop
  18064. * @param delay defines the start delay (in ms)
  18065. * @param onAnimationEnd defines a callback to call when animation ends
  18066. */
  18067. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18068. /** Stops current animation (if any) */
  18069. stopAnimation(): void;
  18070. /** @hidden */
  18071. _animate(deltaTime: number): void;
  18072. /** Release associated resources */
  18073. dispose(): void;
  18074. }
  18075. }
  18076. declare module BABYLON {
  18077. /**
  18078. * Information about the result of picking within a scene
  18079. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18080. */
  18081. export class PickingInfo {
  18082. /** @hidden */
  18083. _pickingUnavailable: boolean;
  18084. /**
  18085. * If the pick collided with an object
  18086. */
  18087. hit: boolean;
  18088. /**
  18089. * Distance away where the pick collided
  18090. */
  18091. distance: number;
  18092. /**
  18093. * The location of pick collision
  18094. */
  18095. pickedPoint: Nullable<Vector3>;
  18096. /**
  18097. * The mesh corresponding the the pick collision
  18098. */
  18099. pickedMesh: Nullable<AbstractMesh>;
  18100. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18101. bu: number;
  18102. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18103. bv: number;
  18104. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18105. faceId: number;
  18106. /** Id of the the submesh that was picked */
  18107. subMeshId: number;
  18108. /** If a sprite was picked, this will be the sprite the pick collided with */
  18109. pickedSprite: Nullable<Sprite>;
  18110. /**
  18111. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18112. */
  18113. originMesh: Nullable<AbstractMesh>;
  18114. /**
  18115. * The ray that was used to perform the picking.
  18116. */
  18117. ray: Nullable<Ray>;
  18118. /**
  18119. * Gets the normal correspodning to the face the pick collided with
  18120. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18121. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18122. * @returns The normal correspodning to the face the pick collided with
  18123. */
  18124. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18125. /**
  18126. * Gets the texture coordinates of where the pick occured
  18127. * @returns the vector containing the coordnates of the texture
  18128. */
  18129. getTextureCoordinates(): Nullable<Vector2>;
  18130. }
  18131. }
  18132. declare module BABYLON {
  18133. /**
  18134. * Gather the list of pointer event types as constants.
  18135. */
  18136. export class PointerEventTypes {
  18137. /**
  18138. * 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.
  18139. */
  18140. static readonly POINTERDOWN: number;
  18141. /**
  18142. * The pointerup event is fired when a pointer is no longer active.
  18143. */
  18144. static readonly POINTERUP: number;
  18145. /**
  18146. * The pointermove event is fired when a pointer changes coordinates.
  18147. */
  18148. static readonly POINTERMOVE: number;
  18149. /**
  18150. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18151. */
  18152. static readonly POINTERWHEEL: number;
  18153. /**
  18154. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18155. */
  18156. static readonly POINTERPICK: number;
  18157. /**
  18158. * The pointertap event is fired when a the object has been touched and released without drag.
  18159. */
  18160. static readonly POINTERTAP: number;
  18161. /**
  18162. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18163. */
  18164. static readonly POINTERDOUBLETAP: number;
  18165. }
  18166. /**
  18167. * Base class of pointer info types.
  18168. */
  18169. export class PointerInfoBase {
  18170. /**
  18171. * Defines the type of event (PointerEventTypes)
  18172. */
  18173. type: number;
  18174. /**
  18175. * Defines the related dom event
  18176. */
  18177. event: PointerEvent | MouseWheelEvent;
  18178. /**
  18179. * Instantiates the base class of pointers info.
  18180. * @param type Defines the type of event (PointerEventTypes)
  18181. * @param event Defines the related dom event
  18182. */
  18183. constructor(
  18184. /**
  18185. * Defines the type of event (PointerEventTypes)
  18186. */
  18187. type: number,
  18188. /**
  18189. * Defines the related dom event
  18190. */
  18191. event: PointerEvent | MouseWheelEvent);
  18192. }
  18193. /**
  18194. * This class is used to store pointer related info for the onPrePointerObservable event.
  18195. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18196. */
  18197. export class PointerInfoPre extends PointerInfoBase {
  18198. /**
  18199. * Ray from a pointer if availible (eg. 6dof controller)
  18200. */
  18201. ray: Nullable<Ray>;
  18202. /**
  18203. * Defines the local position of the pointer on the canvas.
  18204. */
  18205. localPosition: Vector2;
  18206. /**
  18207. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18208. */
  18209. skipOnPointerObservable: boolean;
  18210. /**
  18211. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18212. * @param type Defines the type of event (PointerEventTypes)
  18213. * @param event Defines the related dom event
  18214. * @param localX Defines the local x coordinates of the pointer when the event occured
  18215. * @param localY Defines the local y coordinates of the pointer when the event occured
  18216. */
  18217. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18218. }
  18219. /**
  18220. * This type contains all the data related to a pointer event in Babylon.js.
  18221. * 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.
  18222. */
  18223. export class PointerInfo extends PointerInfoBase {
  18224. /**
  18225. * Defines the picking info associated to the info (if any)\
  18226. */
  18227. pickInfo: Nullable<PickingInfo>;
  18228. /**
  18229. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18230. * @param type Defines the type of event (PointerEventTypes)
  18231. * @param event Defines the related dom event
  18232. * @param pickInfo Defines the picking info associated to the info (if any)\
  18233. */
  18234. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18235. /**
  18236. * Defines the picking info associated to the info (if any)\
  18237. */
  18238. pickInfo: Nullable<PickingInfo>);
  18239. }
  18240. /**
  18241. * Data relating to a touch event on the screen.
  18242. */
  18243. export interface PointerTouch {
  18244. /**
  18245. * X coordinate of touch.
  18246. */
  18247. x: number;
  18248. /**
  18249. * Y coordinate of touch.
  18250. */
  18251. y: number;
  18252. /**
  18253. * Id of touch. Unique for each finger.
  18254. */
  18255. pointerId: number;
  18256. /**
  18257. * Event type passed from DOM.
  18258. */
  18259. type: any;
  18260. }
  18261. }
  18262. declare module BABYLON {
  18263. /**
  18264. * Manage the mouse inputs to control the movement of a free camera.
  18265. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18266. */
  18267. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18268. /**
  18269. * Define if touch is enabled in the mouse input
  18270. */
  18271. touchEnabled: boolean;
  18272. /**
  18273. * Defines the camera the input is attached to.
  18274. */
  18275. camera: FreeCamera;
  18276. /**
  18277. * Defines the buttons associated with the input to handle camera move.
  18278. */
  18279. buttons: number[];
  18280. /**
  18281. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18282. */
  18283. angularSensibility: number;
  18284. private _pointerInput;
  18285. private _onMouseMove;
  18286. private _observer;
  18287. private previousPosition;
  18288. /**
  18289. * Observable for when a pointer move event occurs containing the move offset
  18290. */
  18291. onPointerMovedObservable: Observable<{
  18292. offsetX: number;
  18293. offsetY: number;
  18294. }>;
  18295. /**
  18296. * @hidden
  18297. * If the camera should be rotated automatically based on pointer movement
  18298. */
  18299. _allowCameraRotation: boolean;
  18300. /**
  18301. * Manage the mouse inputs to control the movement of a free camera.
  18302. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18303. * @param touchEnabled Defines if touch is enabled or not
  18304. */
  18305. constructor(
  18306. /**
  18307. * Define if touch is enabled in the mouse input
  18308. */
  18309. touchEnabled?: boolean);
  18310. /**
  18311. * Attach the input controls to a specific dom element to get the input from.
  18312. * @param element Defines the element the controls should be listened from
  18313. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18314. */
  18315. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18316. /**
  18317. * Called on JS contextmenu event.
  18318. * Override this method to provide functionality.
  18319. */
  18320. protected onContextMenu(evt: PointerEvent): void;
  18321. /**
  18322. * Detach the current controls from the specified dom element.
  18323. * @param element Defines the element to stop listening the inputs from
  18324. */
  18325. detachControl(element: Nullable<HTMLElement>): void;
  18326. /**
  18327. * Gets the class name of the current intput.
  18328. * @returns the class name
  18329. */
  18330. getClassName(): string;
  18331. /**
  18332. * Get the friendly name associated with the input class.
  18333. * @returns the input friendly name
  18334. */
  18335. getSimpleName(): string;
  18336. }
  18337. }
  18338. declare module BABYLON {
  18339. /**
  18340. * Manage the touch inputs to control the movement of a free camera.
  18341. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18342. */
  18343. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18344. /**
  18345. * Defines the camera the input is attached to.
  18346. */
  18347. camera: FreeCamera;
  18348. /**
  18349. * Defines the touch sensibility for rotation.
  18350. * The higher the faster.
  18351. */
  18352. touchAngularSensibility: number;
  18353. /**
  18354. * Defines the touch sensibility for move.
  18355. * The higher the faster.
  18356. */
  18357. touchMoveSensibility: number;
  18358. private _offsetX;
  18359. private _offsetY;
  18360. private _pointerPressed;
  18361. private _pointerInput;
  18362. private _observer;
  18363. private _onLostFocus;
  18364. /**
  18365. * Attach the input controls to a specific dom element to get the input from.
  18366. * @param element Defines the element the controls should be listened from
  18367. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18368. */
  18369. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18370. /**
  18371. * Detach the current controls from the specified dom element.
  18372. * @param element Defines the element to stop listening the inputs from
  18373. */
  18374. detachControl(element: Nullable<HTMLElement>): void;
  18375. /**
  18376. * Update the current camera state depending on the inputs that have been used this frame.
  18377. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18378. */
  18379. checkInputs(): void;
  18380. /**
  18381. * Gets the class name of the current intput.
  18382. * @returns the class name
  18383. */
  18384. getClassName(): string;
  18385. /**
  18386. * Get the friendly name associated with the input class.
  18387. * @returns the input friendly name
  18388. */
  18389. getSimpleName(): string;
  18390. }
  18391. }
  18392. declare module BABYLON {
  18393. /**
  18394. * Default Inputs manager for the FreeCamera.
  18395. * It groups all the default supported inputs for ease of use.
  18396. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18397. */
  18398. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18399. /**
  18400. * @hidden
  18401. */
  18402. _mouseInput: Nullable<FreeCameraMouseInput>;
  18403. /**
  18404. * Instantiates a new FreeCameraInputsManager.
  18405. * @param camera Defines the camera the inputs belong to
  18406. */
  18407. constructor(camera: FreeCamera);
  18408. /**
  18409. * Add keyboard input support to the input manager.
  18410. * @returns the current input manager
  18411. */
  18412. addKeyboard(): FreeCameraInputsManager;
  18413. /**
  18414. * Add mouse input support to the input manager.
  18415. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18416. * @returns the current input manager
  18417. */
  18418. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18419. /**
  18420. * Removes the mouse input support from the manager
  18421. * @returns the current input manager
  18422. */
  18423. removeMouse(): FreeCameraInputsManager;
  18424. /**
  18425. * Add touch input support to the input manager.
  18426. * @returns the current input manager
  18427. */
  18428. addTouch(): FreeCameraInputsManager;
  18429. /**
  18430. * Remove all attached input methods from a camera
  18431. */
  18432. clear(): void;
  18433. }
  18434. }
  18435. declare module BABYLON {
  18436. /**
  18437. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18438. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18439. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18440. */
  18441. export class FreeCamera extends TargetCamera {
  18442. /**
  18443. * Define the collision ellipsoid of the camera.
  18444. * This is helpful to simulate a camera body like the player body around the camera
  18445. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18446. */
  18447. ellipsoid: Vector3;
  18448. /**
  18449. * Define an offset for the position of the ellipsoid around the camera.
  18450. * This can be helpful to determine the center of the body near the gravity center of the body
  18451. * instead of its head.
  18452. */
  18453. ellipsoidOffset: Vector3;
  18454. /**
  18455. * Enable or disable collisions of the camera with the rest of the scene objects.
  18456. */
  18457. checkCollisions: boolean;
  18458. /**
  18459. * Enable or disable gravity on the camera.
  18460. */
  18461. applyGravity: boolean;
  18462. /**
  18463. * Define the input manager associated to the camera.
  18464. */
  18465. inputs: FreeCameraInputsManager;
  18466. /**
  18467. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18468. * Higher values reduce sensitivity.
  18469. */
  18470. get angularSensibility(): number;
  18471. /**
  18472. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18473. * Higher values reduce sensitivity.
  18474. */
  18475. set angularSensibility(value: number);
  18476. /**
  18477. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18478. */
  18479. get keysUp(): number[];
  18480. set keysUp(value: number[]);
  18481. /**
  18482. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18483. */
  18484. get keysUpward(): number[];
  18485. set keysUpward(value: number[]);
  18486. /**
  18487. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18488. */
  18489. get keysDown(): number[];
  18490. set keysDown(value: number[]);
  18491. /**
  18492. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18493. */
  18494. get keysDownward(): number[];
  18495. set keysDownward(value: number[]);
  18496. /**
  18497. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18498. */
  18499. get keysLeft(): number[];
  18500. set keysLeft(value: number[]);
  18501. /**
  18502. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18503. */
  18504. get keysRight(): number[];
  18505. set keysRight(value: number[]);
  18506. /**
  18507. * Event raised when the camera collide with a mesh in the scene.
  18508. */
  18509. onCollide: (collidedMesh: AbstractMesh) => void;
  18510. private _collider;
  18511. private _needMoveForGravity;
  18512. private _oldPosition;
  18513. private _diffPosition;
  18514. private _newPosition;
  18515. /** @hidden */
  18516. _localDirection: Vector3;
  18517. /** @hidden */
  18518. _transformedDirection: Vector3;
  18519. /**
  18520. * Instantiates a Free Camera.
  18521. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18522. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18523. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18524. * @param name Define the name of the camera in the scene
  18525. * @param position Define the start position of the camera in the scene
  18526. * @param scene Define the scene the camera belongs to
  18527. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18528. */
  18529. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18530. /**
  18531. * Attached controls to the current camera.
  18532. * @param element Defines the element the controls should be listened from
  18533. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18534. */
  18535. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18536. /**
  18537. * Detach the current controls from the camera.
  18538. * The camera will stop reacting to inputs.
  18539. * @param element Defines the element to stop listening the inputs from
  18540. */
  18541. detachControl(element: HTMLElement): void;
  18542. private _collisionMask;
  18543. /**
  18544. * Define a collision mask to limit the list of object the camera can collide with
  18545. */
  18546. get collisionMask(): number;
  18547. set collisionMask(mask: number);
  18548. /** @hidden */
  18549. _collideWithWorld(displacement: Vector3): void;
  18550. private _onCollisionPositionChange;
  18551. /** @hidden */
  18552. _checkInputs(): void;
  18553. /** @hidden */
  18554. _decideIfNeedsToMove(): boolean;
  18555. /** @hidden */
  18556. _updatePosition(): void;
  18557. /**
  18558. * Destroy the camera and release the current resources hold by it.
  18559. */
  18560. dispose(): void;
  18561. /**
  18562. * Gets the current object class name.
  18563. * @return the class name
  18564. */
  18565. getClassName(): string;
  18566. }
  18567. }
  18568. declare module BABYLON {
  18569. /**
  18570. * Represents a gamepad control stick position
  18571. */
  18572. export class StickValues {
  18573. /**
  18574. * The x component of the control stick
  18575. */
  18576. x: number;
  18577. /**
  18578. * The y component of the control stick
  18579. */
  18580. y: number;
  18581. /**
  18582. * Initializes the gamepad x and y control stick values
  18583. * @param x The x component of the gamepad control stick value
  18584. * @param y The y component of the gamepad control stick value
  18585. */
  18586. constructor(
  18587. /**
  18588. * The x component of the control stick
  18589. */
  18590. x: number,
  18591. /**
  18592. * The y component of the control stick
  18593. */
  18594. y: number);
  18595. }
  18596. /**
  18597. * An interface which manages callbacks for gamepad button changes
  18598. */
  18599. export interface GamepadButtonChanges {
  18600. /**
  18601. * Called when a gamepad has been changed
  18602. */
  18603. changed: boolean;
  18604. /**
  18605. * Called when a gamepad press event has been triggered
  18606. */
  18607. pressChanged: boolean;
  18608. /**
  18609. * Called when a touch event has been triggered
  18610. */
  18611. touchChanged: boolean;
  18612. /**
  18613. * Called when a value has changed
  18614. */
  18615. valueChanged: boolean;
  18616. }
  18617. /**
  18618. * Represents a gamepad
  18619. */
  18620. export class Gamepad {
  18621. /**
  18622. * The id of the gamepad
  18623. */
  18624. id: string;
  18625. /**
  18626. * The index of the gamepad
  18627. */
  18628. index: number;
  18629. /**
  18630. * The browser gamepad
  18631. */
  18632. browserGamepad: any;
  18633. /**
  18634. * Specifies what type of gamepad this represents
  18635. */
  18636. type: number;
  18637. private _leftStick;
  18638. private _rightStick;
  18639. /** @hidden */
  18640. _isConnected: boolean;
  18641. private _leftStickAxisX;
  18642. private _leftStickAxisY;
  18643. private _rightStickAxisX;
  18644. private _rightStickAxisY;
  18645. /**
  18646. * Triggered when the left control stick has been changed
  18647. */
  18648. private _onleftstickchanged;
  18649. /**
  18650. * Triggered when the right control stick has been changed
  18651. */
  18652. private _onrightstickchanged;
  18653. /**
  18654. * Represents a gamepad controller
  18655. */
  18656. static GAMEPAD: number;
  18657. /**
  18658. * Represents a generic controller
  18659. */
  18660. static GENERIC: number;
  18661. /**
  18662. * Represents an XBox controller
  18663. */
  18664. static XBOX: number;
  18665. /**
  18666. * Represents a pose-enabled controller
  18667. */
  18668. static POSE_ENABLED: number;
  18669. /**
  18670. * Represents an Dual Shock controller
  18671. */
  18672. static DUALSHOCK: number;
  18673. /**
  18674. * Specifies whether the left control stick should be Y-inverted
  18675. */
  18676. protected _invertLeftStickY: boolean;
  18677. /**
  18678. * Specifies if the gamepad has been connected
  18679. */
  18680. get isConnected(): boolean;
  18681. /**
  18682. * Initializes the gamepad
  18683. * @param id The id of the gamepad
  18684. * @param index The index of the gamepad
  18685. * @param browserGamepad The browser gamepad
  18686. * @param leftStickX The x component of the left joystick
  18687. * @param leftStickY The y component of the left joystick
  18688. * @param rightStickX The x component of the right joystick
  18689. * @param rightStickY The y component of the right joystick
  18690. */
  18691. constructor(
  18692. /**
  18693. * The id of the gamepad
  18694. */
  18695. id: string,
  18696. /**
  18697. * The index of the gamepad
  18698. */
  18699. index: number,
  18700. /**
  18701. * The browser gamepad
  18702. */
  18703. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18704. /**
  18705. * Callback triggered when the left joystick has changed
  18706. * @param callback
  18707. */
  18708. onleftstickchanged(callback: (values: StickValues) => void): void;
  18709. /**
  18710. * Callback triggered when the right joystick has changed
  18711. * @param callback
  18712. */
  18713. onrightstickchanged(callback: (values: StickValues) => void): void;
  18714. /**
  18715. * Gets the left joystick
  18716. */
  18717. get leftStick(): StickValues;
  18718. /**
  18719. * Sets the left joystick values
  18720. */
  18721. set leftStick(newValues: StickValues);
  18722. /**
  18723. * Gets the right joystick
  18724. */
  18725. get rightStick(): StickValues;
  18726. /**
  18727. * Sets the right joystick value
  18728. */
  18729. set rightStick(newValues: StickValues);
  18730. /**
  18731. * Updates the gamepad joystick positions
  18732. */
  18733. update(): void;
  18734. /**
  18735. * Disposes the gamepad
  18736. */
  18737. dispose(): void;
  18738. }
  18739. /**
  18740. * Represents a generic gamepad
  18741. */
  18742. export class GenericPad extends Gamepad {
  18743. private _buttons;
  18744. private _onbuttondown;
  18745. private _onbuttonup;
  18746. /**
  18747. * Observable triggered when a button has been pressed
  18748. */
  18749. onButtonDownObservable: Observable<number>;
  18750. /**
  18751. * Observable triggered when a button has been released
  18752. */
  18753. onButtonUpObservable: Observable<number>;
  18754. /**
  18755. * Callback triggered when a button has been pressed
  18756. * @param callback Called when a button has been pressed
  18757. */
  18758. onbuttondown(callback: (buttonPressed: number) => void): void;
  18759. /**
  18760. * Callback triggered when a button has been released
  18761. * @param callback Called when a button has been released
  18762. */
  18763. onbuttonup(callback: (buttonReleased: number) => void): void;
  18764. /**
  18765. * Initializes the generic gamepad
  18766. * @param id The id of the generic gamepad
  18767. * @param index The index of the generic gamepad
  18768. * @param browserGamepad The browser gamepad
  18769. */
  18770. constructor(id: string, index: number, browserGamepad: any);
  18771. private _setButtonValue;
  18772. /**
  18773. * Updates the generic gamepad
  18774. */
  18775. update(): void;
  18776. /**
  18777. * Disposes the generic gamepad
  18778. */
  18779. dispose(): void;
  18780. }
  18781. }
  18782. declare module BABYLON {
  18783. /**
  18784. * Defines the types of pose enabled controllers that are supported
  18785. */
  18786. export enum PoseEnabledControllerType {
  18787. /**
  18788. * HTC Vive
  18789. */
  18790. VIVE = 0,
  18791. /**
  18792. * Oculus Rift
  18793. */
  18794. OCULUS = 1,
  18795. /**
  18796. * Windows mixed reality
  18797. */
  18798. WINDOWS = 2,
  18799. /**
  18800. * Samsung gear VR
  18801. */
  18802. GEAR_VR = 3,
  18803. /**
  18804. * Google Daydream
  18805. */
  18806. DAYDREAM = 4,
  18807. /**
  18808. * Generic
  18809. */
  18810. GENERIC = 5
  18811. }
  18812. /**
  18813. * Defines the MutableGamepadButton interface for the state of a gamepad button
  18814. */
  18815. export interface MutableGamepadButton {
  18816. /**
  18817. * Value of the button/trigger
  18818. */
  18819. value: number;
  18820. /**
  18821. * If the button/trigger is currently touched
  18822. */
  18823. touched: boolean;
  18824. /**
  18825. * If the button/trigger is currently pressed
  18826. */
  18827. pressed: boolean;
  18828. }
  18829. /**
  18830. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  18831. * @hidden
  18832. */
  18833. export interface ExtendedGamepadButton extends GamepadButton {
  18834. /**
  18835. * If the button/trigger is currently pressed
  18836. */
  18837. readonly pressed: boolean;
  18838. /**
  18839. * If the button/trigger is currently touched
  18840. */
  18841. readonly touched: boolean;
  18842. /**
  18843. * Value of the button/trigger
  18844. */
  18845. readonly value: number;
  18846. }
  18847. /** @hidden */
  18848. export interface _GamePadFactory {
  18849. /**
  18850. * Returns whether or not the current gamepad can be created for this type of controller.
  18851. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18852. * @returns true if it can be created, otherwise false
  18853. */
  18854. canCreate(gamepadInfo: any): boolean;
  18855. /**
  18856. * Creates a new instance of the Gamepad.
  18857. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18858. * @returns the new gamepad instance
  18859. */
  18860. create(gamepadInfo: any): Gamepad;
  18861. }
  18862. /**
  18863. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18864. */
  18865. export class PoseEnabledControllerHelper {
  18866. /** @hidden */
  18867. static _ControllerFactories: _GamePadFactory[];
  18868. /** @hidden */
  18869. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  18870. /**
  18871. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18872. * @param vrGamepad the gamepad to initialized
  18873. * @returns a vr controller of the type the gamepad identified as
  18874. */
  18875. static InitiateController(vrGamepad: any): Gamepad;
  18876. }
  18877. /**
  18878. * Defines the PoseEnabledController object that contains state of a vr capable controller
  18879. */
  18880. export class PoseEnabledController extends Gamepad implements PoseControlled {
  18881. /**
  18882. * If the controller is used in a webXR session
  18883. */
  18884. isXR: boolean;
  18885. private _deviceRoomPosition;
  18886. private _deviceRoomRotationQuaternion;
  18887. /**
  18888. * The device position in babylon space
  18889. */
  18890. devicePosition: Vector3;
  18891. /**
  18892. * The device rotation in babylon space
  18893. */
  18894. deviceRotationQuaternion: Quaternion;
  18895. /**
  18896. * The scale factor of the device in babylon space
  18897. */
  18898. deviceScaleFactor: number;
  18899. /**
  18900. * (Likely devicePosition should be used instead) The device position in its room space
  18901. */
  18902. position: Vector3;
  18903. /**
  18904. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  18905. */
  18906. rotationQuaternion: Quaternion;
  18907. /**
  18908. * The type of controller (Eg. Windows mixed reality)
  18909. */
  18910. controllerType: PoseEnabledControllerType;
  18911. protected _calculatedPosition: Vector3;
  18912. private _calculatedRotation;
  18913. /**
  18914. * The raw pose from the device
  18915. */
  18916. rawPose: DevicePose;
  18917. private _trackPosition;
  18918. private _maxRotationDistFromHeadset;
  18919. private _draggedRoomRotation;
  18920. /**
  18921. * @hidden
  18922. */
  18923. _disableTrackPosition(fixedPosition: Vector3): void;
  18924. /**
  18925. * Internal, the mesh attached to the controller
  18926. * @hidden
  18927. */
  18928. _mesh: Nullable<AbstractMesh>;
  18929. private _poseControlledCamera;
  18930. private _leftHandSystemQuaternion;
  18931. /**
  18932. * Internal, matrix used to convert room space to babylon space
  18933. * @hidden
  18934. */
  18935. _deviceToWorld: Matrix;
  18936. /**
  18937. * Node to be used when casting a ray from the controller
  18938. * @hidden
  18939. */
  18940. _pointingPoseNode: Nullable<TransformNode>;
  18941. /**
  18942. * Name of the child mesh that can be used to cast a ray from the controller
  18943. */
  18944. static readonly POINTING_POSE: string;
  18945. /**
  18946. * Creates a new PoseEnabledController from a gamepad
  18947. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  18948. */
  18949. constructor(browserGamepad: any);
  18950. private _workingMatrix;
  18951. /**
  18952. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  18953. */
  18954. update(): void;
  18955. /**
  18956. * Updates only the pose device and mesh without doing any button event checking
  18957. */
  18958. protected _updatePoseAndMesh(): void;
  18959. /**
  18960. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  18961. * @param poseData raw pose fromthe device
  18962. */
  18963. updateFromDevice(poseData: DevicePose): void;
  18964. /**
  18965. * @hidden
  18966. */
  18967. _meshAttachedObservable: Observable<AbstractMesh>;
  18968. /**
  18969. * Attaches a mesh to the controller
  18970. * @param mesh the mesh to be attached
  18971. */
  18972. attachToMesh(mesh: AbstractMesh): void;
  18973. /**
  18974. * Attaches the controllers mesh to a camera
  18975. * @param camera the camera the mesh should be attached to
  18976. */
  18977. attachToPoseControlledCamera(camera: TargetCamera): void;
  18978. /**
  18979. * Disposes of the controller
  18980. */
  18981. dispose(): void;
  18982. /**
  18983. * The mesh that is attached to the controller
  18984. */
  18985. get mesh(): Nullable<AbstractMesh>;
  18986. /**
  18987. * Gets the ray of the controller in the direction the controller is pointing
  18988. * @param length the length the resulting ray should be
  18989. * @returns a ray in the direction the controller is pointing
  18990. */
  18991. getForwardRay(length?: number): Ray;
  18992. }
  18993. }
  18994. declare module BABYLON {
  18995. /**
  18996. * Defines the WebVRController object that represents controllers tracked in 3D space
  18997. */
  18998. export abstract class WebVRController extends PoseEnabledController {
  18999. /**
  19000. * Internal, the default controller model for the controller
  19001. */
  19002. protected _defaultModel: Nullable<AbstractMesh>;
  19003. /**
  19004. * Fired when the trigger state has changed
  19005. */
  19006. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19007. /**
  19008. * Fired when the main button state has changed
  19009. */
  19010. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19011. /**
  19012. * Fired when the secondary button state has changed
  19013. */
  19014. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19015. /**
  19016. * Fired when the pad state has changed
  19017. */
  19018. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19019. /**
  19020. * Fired when controllers stick values have changed
  19021. */
  19022. onPadValuesChangedObservable: Observable<StickValues>;
  19023. /**
  19024. * Array of button availible on the controller
  19025. */
  19026. protected _buttons: Array<MutableGamepadButton>;
  19027. private _onButtonStateChange;
  19028. /**
  19029. * Fired when a controller button's state has changed
  19030. * @param callback the callback containing the button that was modified
  19031. */
  19032. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19033. /**
  19034. * X and Y axis corresponding to the controllers joystick
  19035. */
  19036. pad: StickValues;
  19037. /**
  19038. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19039. */
  19040. hand: string;
  19041. /**
  19042. * The default controller model for the controller
  19043. */
  19044. get defaultModel(): Nullable<AbstractMesh>;
  19045. /**
  19046. * Creates a new WebVRController from a gamepad
  19047. * @param vrGamepad the gamepad that the WebVRController should be created from
  19048. */
  19049. constructor(vrGamepad: any);
  19050. /**
  19051. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19052. */
  19053. update(): void;
  19054. /**
  19055. * Function to be called when a button is modified
  19056. */
  19057. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19058. /**
  19059. * Loads a mesh and attaches it to the controller
  19060. * @param scene the scene the mesh should be added to
  19061. * @param meshLoaded callback for when the mesh has been loaded
  19062. */
  19063. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19064. private _setButtonValue;
  19065. private _changes;
  19066. private _checkChanges;
  19067. /**
  19068. * Disposes of th webVRCOntroller
  19069. */
  19070. dispose(): void;
  19071. }
  19072. }
  19073. declare module BABYLON {
  19074. /**
  19075. * The HemisphericLight simulates the ambient environment light,
  19076. * so the passed direction is the light reflection direction, not the incoming direction.
  19077. */
  19078. export class HemisphericLight extends Light {
  19079. /**
  19080. * The groundColor is the light in the opposite direction to the one specified during creation.
  19081. * 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.
  19082. */
  19083. groundColor: Color3;
  19084. /**
  19085. * The light reflection direction, not the incoming direction.
  19086. */
  19087. direction: Vector3;
  19088. /**
  19089. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19090. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19091. * The HemisphericLight can't cast shadows.
  19092. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19093. * @param name The friendly name of the light
  19094. * @param direction The direction of the light reflection
  19095. * @param scene The scene the light belongs to
  19096. */
  19097. constructor(name: string, direction: Vector3, scene: Scene);
  19098. protected _buildUniformLayout(): void;
  19099. /**
  19100. * Returns the string "HemisphericLight".
  19101. * @return The class name
  19102. */
  19103. getClassName(): string;
  19104. /**
  19105. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19106. * Returns the updated direction.
  19107. * @param target The target the direction should point to
  19108. * @return The computed direction
  19109. */
  19110. setDirectionToTarget(target: Vector3): Vector3;
  19111. /**
  19112. * Returns the shadow generator associated to the light.
  19113. * @returns Always null for hemispheric lights because it does not support shadows.
  19114. */
  19115. getShadowGenerator(): Nullable<IShadowGenerator>;
  19116. /**
  19117. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19118. * @param effect The effect to update
  19119. * @param lightIndex The index of the light in the effect to update
  19120. * @returns The hemispheric light
  19121. */
  19122. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19123. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19124. /**
  19125. * Computes the world matrix of the node
  19126. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19127. * @param useWasUpdatedFlag defines a reserved property
  19128. * @returns the world matrix
  19129. */
  19130. computeWorldMatrix(): Matrix;
  19131. /**
  19132. * Returns the integer 3.
  19133. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19134. */
  19135. getTypeID(): number;
  19136. /**
  19137. * Prepares the list of defines specific to the light type.
  19138. * @param defines the list of defines
  19139. * @param lightIndex defines the index of the light for the effect
  19140. */
  19141. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19142. }
  19143. }
  19144. declare module BABYLON {
  19145. /** @hidden */
  19146. export var vrMultiviewToSingleviewPixelShader: {
  19147. name: string;
  19148. shader: string;
  19149. };
  19150. }
  19151. declare module BABYLON {
  19152. /**
  19153. * Renders to multiple views with a single draw call
  19154. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19155. */
  19156. export class MultiviewRenderTarget extends RenderTargetTexture {
  19157. /**
  19158. * Creates a multiview render target
  19159. * @param scene scene used with the render target
  19160. * @param size the size of the render target (used for each view)
  19161. */
  19162. constructor(scene: Scene, size?: number | {
  19163. width: number;
  19164. height: number;
  19165. } | {
  19166. ratio: number;
  19167. });
  19168. /**
  19169. * @hidden
  19170. * @param faceIndex the face index, if its a cube texture
  19171. */
  19172. _bindFrameBuffer(faceIndex?: number): void;
  19173. /**
  19174. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19175. * @returns the view count
  19176. */
  19177. getViewCount(): number;
  19178. }
  19179. }
  19180. declare module BABYLON {
  19181. /**
  19182. * Represents a camera frustum
  19183. */
  19184. export class Frustum {
  19185. /**
  19186. * Gets the planes representing the frustum
  19187. * @param transform matrix to be applied to the returned planes
  19188. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19189. */
  19190. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19191. /**
  19192. * Gets the near frustum plane transformed by the transform matrix
  19193. * @param transform transformation matrix to be applied to the resulting frustum plane
  19194. * @param frustumPlane the resuling frustum plane
  19195. */
  19196. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19197. /**
  19198. * Gets the far frustum plane transformed by the transform matrix
  19199. * @param transform transformation matrix to be applied to the resulting frustum plane
  19200. * @param frustumPlane the resuling frustum plane
  19201. */
  19202. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19203. /**
  19204. * Gets the left frustum plane transformed by the transform matrix
  19205. * @param transform transformation matrix to be applied to the resulting frustum plane
  19206. * @param frustumPlane the resuling frustum plane
  19207. */
  19208. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19209. /**
  19210. * Gets the right frustum plane transformed by the transform matrix
  19211. * @param transform transformation matrix to be applied to the resulting frustum plane
  19212. * @param frustumPlane the resuling frustum plane
  19213. */
  19214. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19215. /**
  19216. * Gets the top frustum plane transformed by the transform matrix
  19217. * @param transform transformation matrix to be applied to the resulting frustum plane
  19218. * @param frustumPlane the resuling frustum plane
  19219. */
  19220. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19221. /**
  19222. * Gets the bottom frustum plane transformed by the transform matrix
  19223. * @param transform transformation matrix to be applied to the resulting frustum plane
  19224. * @param frustumPlane the resuling frustum plane
  19225. */
  19226. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19227. /**
  19228. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19229. * @param transform transformation matrix to be applied to the resulting frustum planes
  19230. * @param frustumPlanes the resuling frustum planes
  19231. */
  19232. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19233. }
  19234. }
  19235. declare module BABYLON {
  19236. interface Engine {
  19237. /**
  19238. * Creates a new multiview render target
  19239. * @param width defines the width of the texture
  19240. * @param height defines the height of the texture
  19241. * @returns the created multiview texture
  19242. */
  19243. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19244. /**
  19245. * Binds a multiview framebuffer to be drawn to
  19246. * @param multiviewTexture texture to bind
  19247. */
  19248. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19249. }
  19250. interface Camera {
  19251. /**
  19252. * @hidden
  19253. * 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)
  19254. */
  19255. _useMultiviewToSingleView: boolean;
  19256. /**
  19257. * @hidden
  19258. * 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)
  19259. */
  19260. _multiviewTexture: Nullable<RenderTargetTexture>;
  19261. /**
  19262. * @hidden
  19263. * ensures the multiview texture of the camera exists and has the specified width/height
  19264. * @param width height to set on the multiview texture
  19265. * @param height width to set on the multiview texture
  19266. */
  19267. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19268. }
  19269. interface Scene {
  19270. /** @hidden */
  19271. _transformMatrixR: Matrix;
  19272. /** @hidden */
  19273. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19274. /** @hidden */
  19275. _createMultiviewUbo(): void;
  19276. /** @hidden */
  19277. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19278. /** @hidden */
  19279. _renderMultiviewToSingleView(camera: Camera): void;
  19280. }
  19281. }
  19282. declare module BABYLON {
  19283. /**
  19284. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19285. * This will not be used for webXR as it supports displaying texture arrays directly
  19286. */
  19287. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19288. /**
  19289. * Initializes a VRMultiviewToSingleview
  19290. * @param name name of the post process
  19291. * @param camera camera to be applied to
  19292. * @param scaleFactor scaling factor to the size of the output texture
  19293. */
  19294. constructor(name: string, camera: Camera, scaleFactor: number);
  19295. }
  19296. }
  19297. declare module BABYLON {
  19298. /**
  19299. * Interface used to define additional presentation attributes
  19300. */
  19301. export interface IVRPresentationAttributes {
  19302. /**
  19303. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19304. */
  19305. highRefreshRate: boolean;
  19306. /**
  19307. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19308. */
  19309. foveationLevel: number;
  19310. }
  19311. interface Engine {
  19312. /** @hidden */
  19313. _vrDisplay: any;
  19314. /** @hidden */
  19315. _vrSupported: boolean;
  19316. /** @hidden */
  19317. _oldSize: Size;
  19318. /** @hidden */
  19319. _oldHardwareScaleFactor: number;
  19320. /** @hidden */
  19321. _vrExclusivePointerMode: boolean;
  19322. /** @hidden */
  19323. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19324. /** @hidden */
  19325. _onVRDisplayPointerRestricted: () => void;
  19326. /** @hidden */
  19327. _onVRDisplayPointerUnrestricted: () => void;
  19328. /** @hidden */
  19329. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19330. /** @hidden */
  19331. _onVrDisplayDisconnect: Nullable<() => void>;
  19332. /** @hidden */
  19333. _onVrDisplayPresentChange: Nullable<() => void>;
  19334. /**
  19335. * Observable signaled when VR display mode changes
  19336. */
  19337. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19338. /**
  19339. * Observable signaled when VR request present is complete
  19340. */
  19341. onVRRequestPresentComplete: Observable<boolean>;
  19342. /**
  19343. * Observable signaled when VR request present starts
  19344. */
  19345. onVRRequestPresentStart: Observable<Engine>;
  19346. /**
  19347. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19348. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19349. */
  19350. isInVRExclusivePointerMode: boolean;
  19351. /**
  19352. * Gets a boolean indicating if a webVR device was detected
  19353. * @returns true if a webVR device was detected
  19354. */
  19355. isVRDevicePresent(): boolean;
  19356. /**
  19357. * Gets the current webVR device
  19358. * @returns the current webVR device (or null)
  19359. */
  19360. getVRDevice(): any;
  19361. /**
  19362. * Initializes a webVR display and starts listening to display change events
  19363. * The onVRDisplayChangedObservable will be notified upon these changes
  19364. * @returns A promise containing a VRDisplay and if vr is supported
  19365. */
  19366. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19367. /** @hidden */
  19368. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19369. /**
  19370. * Gets or sets the presentation attributes used to configure VR rendering
  19371. */
  19372. vrPresentationAttributes?: IVRPresentationAttributes;
  19373. /**
  19374. * Call this function to switch to webVR mode
  19375. * Will do nothing if webVR is not supported or if there is no webVR device
  19376. * @param options the webvr options provided to the camera. mainly used for multiview
  19377. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19378. */
  19379. enableVR(options: WebVROptions): void;
  19380. /** @hidden */
  19381. _onVRFullScreenTriggered(): void;
  19382. }
  19383. }
  19384. declare module BABYLON {
  19385. /**
  19386. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19387. * IMPORTANT!! The data is right-hand data.
  19388. * @export
  19389. * @interface DevicePose
  19390. */
  19391. export interface DevicePose {
  19392. /**
  19393. * The position of the device, values in array are [x,y,z].
  19394. */
  19395. readonly position: Nullable<Float32Array>;
  19396. /**
  19397. * The linearVelocity of the device, values in array are [x,y,z].
  19398. */
  19399. readonly linearVelocity: Nullable<Float32Array>;
  19400. /**
  19401. * The linearAcceleration of the device, values in array are [x,y,z].
  19402. */
  19403. readonly linearAcceleration: Nullable<Float32Array>;
  19404. /**
  19405. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19406. */
  19407. readonly orientation: Nullable<Float32Array>;
  19408. /**
  19409. * The angularVelocity of the device, values in array are [x,y,z].
  19410. */
  19411. readonly angularVelocity: Nullable<Float32Array>;
  19412. /**
  19413. * The angularAcceleration of the device, values in array are [x,y,z].
  19414. */
  19415. readonly angularAcceleration: Nullable<Float32Array>;
  19416. }
  19417. /**
  19418. * Interface representing a pose controlled object in Babylon.
  19419. * A pose controlled object has both regular pose values as well as pose values
  19420. * from an external device such as a VR head mounted display
  19421. */
  19422. export interface PoseControlled {
  19423. /**
  19424. * The position of the object in babylon space.
  19425. */
  19426. position: Vector3;
  19427. /**
  19428. * The rotation quaternion of the object in babylon space.
  19429. */
  19430. rotationQuaternion: Quaternion;
  19431. /**
  19432. * The position of the device in babylon space.
  19433. */
  19434. devicePosition?: Vector3;
  19435. /**
  19436. * The rotation quaternion of the device in babylon space.
  19437. */
  19438. deviceRotationQuaternion: Quaternion;
  19439. /**
  19440. * The raw pose coming from the device.
  19441. */
  19442. rawPose: Nullable<DevicePose>;
  19443. /**
  19444. * The scale of the device to be used when translating from device space to babylon space.
  19445. */
  19446. deviceScaleFactor: number;
  19447. /**
  19448. * Updates the poseControlled values based on the input device pose.
  19449. * @param poseData the pose data to update the object with
  19450. */
  19451. updateFromDevice(poseData: DevicePose): void;
  19452. }
  19453. /**
  19454. * Set of options to customize the webVRCamera
  19455. */
  19456. export interface WebVROptions {
  19457. /**
  19458. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19459. */
  19460. trackPosition?: boolean;
  19461. /**
  19462. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19463. */
  19464. positionScale?: number;
  19465. /**
  19466. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19467. */
  19468. displayName?: string;
  19469. /**
  19470. * Should the native controller meshes be initialized. (default: true)
  19471. */
  19472. controllerMeshes?: boolean;
  19473. /**
  19474. * Creating a default HemiLight only on controllers. (default: true)
  19475. */
  19476. defaultLightingOnControllers?: boolean;
  19477. /**
  19478. * If you don't want to use the default VR button of the helper. (default: false)
  19479. */
  19480. useCustomVRButton?: boolean;
  19481. /**
  19482. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19483. */
  19484. customVRButton?: HTMLButtonElement;
  19485. /**
  19486. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19487. */
  19488. rayLength?: number;
  19489. /**
  19490. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19491. */
  19492. defaultHeight?: number;
  19493. /**
  19494. * If multiview should be used if availible (default: false)
  19495. */
  19496. useMultiview?: boolean;
  19497. }
  19498. /**
  19499. * This represents a WebVR camera.
  19500. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19501. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19502. */
  19503. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19504. private webVROptions;
  19505. /**
  19506. * @hidden
  19507. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19508. */
  19509. _vrDevice: any;
  19510. /**
  19511. * The rawPose of the vrDevice.
  19512. */
  19513. rawPose: Nullable<DevicePose>;
  19514. private _onVREnabled;
  19515. private _specsVersion;
  19516. private _attached;
  19517. private _frameData;
  19518. protected _descendants: Array<Node>;
  19519. private _deviceRoomPosition;
  19520. /** @hidden */
  19521. _deviceRoomRotationQuaternion: Quaternion;
  19522. private _standingMatrix;
  19523. /**
  19524. * Represents device position in babylon space.
  19525. */
  19526. devicePosition: Vector3;
  19527. /**
  19528. * Represents device rotation in babylon space.
  19529. */
  19530. deviceRotationQuaternion: Quaternion;
  19531. /**
  19532. * The scale of the device to be used when translating from device space to babylon space.
  19533. */
  19534. deviceScaleFactor: number;
  19535. private _deviceToWorld;
  19536. private _worldToDevice;
  19537. /**
  19538. * References to the webVR controllers for the vrDevice.
  19539. */
  19540. controllers: Array<WebVRController>;
  19541. /**
  19542. * Emits an event when a controller is attached.
  19543. */
  19544. onControllersAttachedObservable: Observable<WebVRController[]>;
  19545. /**
  19546. * Emits an event when a controller's mesh has been loaded;
  19547. */
  19548. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19549. /**
  19550. * Emits an event when the HMD's pose has been updated.
  19551. */
  19552. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19553. private _poseSet;
  19554. /**
  19555. * If the rig cameras be used as parent instead of this camera.
  19556. */
  19557. rigParenting: boolean;
  19558. private _lightOnControllers;
  19559. private _defaultHeight?;
  19560. /**
  19561. * Instantiates a WebVRFreeCamera.
  19562. * @param name The name of the WebVRFreeCamera
  19563. * @param position The starting anchor position for the camera
  19564. * @param scene The scene the camera belongs to
  19565. * @param webVROptions a set of customizable options for the webVRCamera
  19566. */
  19567. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19568. /**
  19569. * Gets the device distance from the ground in meters.
  19570. * @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.
  19571. */
  19572. deviceDistanceToRoomGround(): number;
  19573. /**
  19574. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19575. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19576. */
  19577. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19578. /**
  19579. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19580. * @returns A promise with a boolean set to if the standing matrix is supported.
  19581. */
  19582. useStandingMatrixAsync(): Promise<boolean>;
  19583. /**
  19584. * Disposes the camera
  19585. */
  19586. dispose(): void;
  19587. /**
  19588. * Gets a vrController by name.
  19589. * @param name The name of the controller to retreive
  19590. * @returns the controller matching the name specified or null if not found
  19591. */
  19592. getControllerByName(name: string): Nullable<WebVRController>;
  19593. private _leftController;
  19594. /**
  19595. * The controller corresponding to the users left hand.
  19596. */
  19597. get leftController(): Nullable<WebVRController>;
  19598. private _rightController;
  19599. /**
  19600. * The controller corresponding to the users right hand.
  19601. */
  19602. get rightController(): Nullable<WebVRController>;
  19603. /**
  19604. * Casts a ray forward from the vrCamera's gaze.
  19605. * @param length Length of the ray (default: 100)
  19606. * @returns the ray corresponding to the gaze
  19607. */
  19608. getForwardRay(length?: number): Ray;
  19609. /**
  19610. * @hidden
  19611. * Updates the camera based on device's frame data
  19612. */
  19613. _checkInputs(): void;
  19614. /**
  19615. * Updates the poseControlled values based on the input device pose.
  19616. * @param poseData Pose coming from the device
  19617. */
  19618. updateFromDevice(poseData: DevicePose): void;
  19619. private _htmlElementAttached;
  19620. private _detachIfAttached;
  19621. /**
  19622. * WebVR's attach control will start broadcasting frames to the device.
  19623. * Note that in certain browsers (chrome for example) this function must be called
  19624. * within a user-interaction callback. Example:
  19625. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19626. *
  19627. * @param element html element to attach the vrDevice to
  19628. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19629. */
  19630. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19631. /**
  19632. * Detaches the camera from the html element and disables VR
  19633. *
  19634. * @param element html element to detach from
  19635. */
  19636. detachControl(element: HTMLElement): void;
  19637. /**
  19638. * @returns the name of this class
  19639. */
  19640. getClassName(): string;
  19641. /**
  19642. * Calls resetPose on the vrDisplay
  19643. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19644. */
  19645. resetToCurrentRotation(): void;
  19646. /**
  19647. * @hidden
  19648. * Updates the rig cameras (left and right eye)
  19649. */
  19650. _updateRigCameras(): void;
  19651. private _workingVector;
  19652. private _oneVector;
  19653. private _workingMatrix;
  19654. private updateCacheCalled;
  19655. private _correctPositionIfNotTrackPosition;
  19656. /**
  19657. * @hidden
  19658. * Updates the cached values of the camera
  19659. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19660. */
  19661. _updateCache(ignoreParentClass?: boolean): void;
  19662. /**
  19663. * @hidden
  19664. * Get current device position in babylon world
  19665. */
  19666. _computeDevicePosition(): void;
  19667. /**
  19668. * Updates the current device position and rotation in the babylon world
  19669. */
  19670. update(): void;
  19671. /**
  19672. * @hidden
  19673. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19674. * @returns an identity matrix
  19675. */
  19676. _getViewMatrix(): Matrix;
  19677. private _tmpMatrix;
  19678. /**
  19679. * This function is called by the two RIG cameras.
  19680. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19681. * @hidden
  19682. */
  19683. _getWebVRViewMatrix(): Matrix;
  19684. /** @hidden */
  19685. _getWebVRProjectionMatrix(): Matrix;
  19686. private _onGamepadConnectedObserver;
  19687. private _onGamepadDisconnectedObserver;
  19688. private _updateCacheWhenTrackingDisabledObserver;
  19689. /**
  19690. * Initializes the controllers and their meshes
  19691. */
  19692. initControllers(): void;
  19693. }
  19694. }
  19695. declare module BABYLON {
  19696. /**
  19697. * Size options for a post process
  19698. */
  19699. export type PostProcessOptions = {
  19700. width: number;
  19701. height: number;
  19702. };
  19703. /**
  19704. * PostProcess can be used to apply a shader to a texture after it has been rendered
  19705. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19706. */
  19707. export class PostProcess {
  19708. /** Name of the PostProcess. */
  19709. name: string;
  19710. /**
  19711. * Gets or sets the unique id of the post process
  19712. */
  19713. uniqueId: number;
  19714. /**
  19715. * Width of the texture to apply the post process on
  19716. */
  19717. width: number;
  19718. /**
  19719. * Height of the texture to apply the post process on
  19720. */
  19721. height: number;
  19722. /**
  19723. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  19724. * @hidden
  19725. */
  19726. _outputTexture: Nullable<InternalTexture>;
  19727. /**
  19728. * Sampling mode used by the shader
  19729. * See https://doc.babylonjs.com/classes/3.1/texture
  19730. */
  19731. renderTargetSamplingMode: number;
  19732. /**
  19733. * Clear color to use when screen clearing
  19734. */
  19735. clearColor: Color4;
  19736. /**
  19737. * If the buffer needs to be cleared before applying the post process. (default: true)
  19738. * Should be set to false if shader will overwrite all previous pixels.
  19739. */
  19740. autoClear: boolean;
  19741. /**
  19742. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  19743. */
  19744. alphaMode: number;
  19745. /**
  19746. * Sets the setAlphaBlendConstants of the babylon engine
  19747. */
  19748. alphaConstants: Color4;
  19749. /**
  19750. * Animations to be used for the post processing
  19751. */
  19752. animations: Animation[];
  19753. /**
  19754. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  19755. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  19756. */
  19757. enablePixelPerfectMode: boolean;
  19758. /**
  19759. * Force the postprocess to be applied without taking in account viewport
  19760. */
  19761. forceFullscreenViewport: boolean;
  19762. /**
  19763. * List of inspectable custom properties (used by the Inspector)
  19764. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19765. */
  19766. inspectableCustomProperties: IInspectable[];
  19767. /**
  19768. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  19769. *
  19770. * | Value | Type | Description |
  19771. * | ----- | ----------------------------------- | ----------- |
  19772. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  19773. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  19774. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  19775. *
  19776. */
  19777. scaleMode: number;
  19778. /**
  19779. * Force textures to be a power of two (default: false)
  19780. */
  19781. alwaysForcePOT: boolean;
  19782. private _samples;
  19783. /**
  19784. * Number of sample textures (default: 1)
  19785. */
  19786. get samples(): number;
  19787. set samples(n: number);
  19788. /**
  19789. * Modify the scale of the post process to be the same as the viewport (default: false)
  19790. */
  19791. adaptScaleToCurrentViewport: boolean;
  19792. private _camera;
  19793. private _scene;
  19794. private _engine;
  19795. private _options;
  19796. private _reusable;
  19797. private _textureType;
  19798. private _textureFormat;
  19799. /**
  19800. * Smart array of input and output textures for the post process.
  19801. * @hidden
  19802. */
  19803. _textures: SmartArray<InternalTexture>;
  19804. /**
  19805. * The index in _textures that corresponds to the output texture.
  19806. * @hidden
  19807. */
  19808. _currentRenderTextureInd: number;
  19809. private _effect;
  19810. private _samplers;
  19811. private _fragmentUrl;
  19812. private _vertexUrl;
  19813. private _parameters;
  19814. private _scaleRatio;
  19815. protected _indexParameters: any;
  19816. private _shareOutputWithPostProcess;
  19817. private _texelSize;
  19818. private _forcedOutputTexture;
  19819. /**
  19820. * Returns the fragment url or shader name used in the post process.
  19821. * @returns the fragment url or name in the shader store.
  19822. */
  19823. getEffectName(): string;
  19824. /**
  19825. * An event triggered when the postprocess is activated.
  19826. */
  19827. onActivateObservable: Observable<Camera>;
  19828. private _onActivateObserver;
  19829. /**
  19830. * A function that is added to the onActivateObservable
  19831. */
  19832. set onActivate(callback: Nullable<(camera: Camera) => void>);
  19833. /**
  19834. * An event triggered when the postprocess changes its size.
  19835. */
  19836. onSizeChangedObservable: Observable<PostProcess>;
  19837. private _onSizeChangedObserver;
  19838. /**
  19839. * A function that is added to the onSizeChangedObservable
  19840. */
  19841. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  19842. /**
  19843. * An event triggered when the postprocess applies its effect.
  19844. */
  19845. onApplyObservable: Observable<Effect>;
  19846. private _onApplyObserver;
  19847. /**
  19848. * A function that is added to the onApplyObservable
  19849. */
  19850. set onApply(callback: (effect: Effect) => void);
  19851. /**
  19852. * An event triggered before rendering the postprocess
  19853. */
  19854. onBeforeRenderObservable: Observable<Effect>;
  19855. private _onBeforeRenderObserver;
  19856. /**
  19857. * A function that is added to the onBeforeRenderObservable
  19858. */
  19859. set onBeforeRender(callback: (effect: Effect) => void);
  19860. /**
  19861. * An event triggered after rendering the postprocess
  19862. */
  19863. onAfterRenderObservable: Observable<Effect>;
  19864. private _onAfterRenderObserver;
  19865. /**
  19866. * A function that is added to the onAfterRenderObservable
  19867. */
  19868. set onAfterRender(callback: (efect: Effect) => void);
  19869. /**
  19870. * 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
  19871. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  19872. */
  19873. get inputTexture(): InternalTexture;
  19874. set inputTexture(value: InternalTexture);
  19875. /**
  19876. * Gets the camera which post process is applied to.
  19877. * @returns The camera the post process is applied to.
  19878. */
  19879. getCamera(): Camera;
  19880. /**
  19881. * Gets the texel size of the postprocess.
  19882. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  19883. */
  19884. get texelSize(): Vector2;
  19885. /**
  19886. * Creates a new instance PostProcess
  19887. * @param name The name of the PostProcess.
  19888. * @param fragmentUrl The url of the fragment shader to be used.
  19889. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  19890. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  19891. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  19892. * @param camera The camera to apply the render pass to.
  19893. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19894. * @param engine The engine which the post process will be applied. (default: current engine)
  19895. * @param reusable If the post process can be reused on the same frame. (default: false)
  19896. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  19897. * @param textureType Type of textures used when performing the post process. (default: 0)
  19898. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  19899. * @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
  19900. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  19901. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  19902. */
  19903. constructor(
  19904. /** Name of the PostProcess. */
  19905. 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);
  19906. /**
  19907. * Gets a string idenfifying the name of the class
  19908. * @returns "PostProcess" string
  19909. */
  19910. getClassName(): string;
  19911. /**
  19912. * Gets the engine which this post process belongs to.
  19913. * @returns The engine the post process was enabled with.
  19914. */
  19915. getEngine(): Engine;
  19916. /**
  19917. * The effect that is created when initializing the post process.
  19918. * @returns The created effect corresponding the the postprocess.
  19919. */
  19920. getEffect(): Effect;
  19921. /**
  19922. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  19923. * @param postProcess The post process to share the output with.
  19924. * @returns This post process.
  19925. */
  19926. shareOutputWith(postProcess: PostProcess): PostProcess;
  19927. /**
  19928. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  19929. * This should be called if the post process that shares output with this post process is disabled/disposed.
  19930. */
  19931. useOwnOutput(): void;
  19932. /**
  19933. * Updates the effect with the current post process compile time values and recompiles the shader.
  19934. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  19935. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  19936. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  19937. * @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
  19938. * @param onCompiled Called when the shader has been compiled.
  19939. * @param onError Called if there is an error when compiling a shader.
  19940. */
  19941. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19942. /**
  19943. * The post process is reusable if it can be used multiple times within one frame.
  19944. * @returns If the post process is reusable
  19945. */
  19946. isReusable(): boolean;
  19947. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  19948. markTextureDirty(): void;
  19949. /**
  19950. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  19951. * 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.
  19952. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  19953. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  19954. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  19955. * @returns The target texture that was bound to be written to.
  19956. */
  19957. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  19958. /**
  19959. * If the post process is supported.
  19960. */
  19961. get isSupported(): boolean;
  19962. /**
  19963. * The aspect ratio of the output texture.
  19964. */
  19965. get aspectRatio(): number;
  19966. /**
  19967. * Get a value indicating if the post-process is ready to be used
  19968. * @returns true if the post-process is ready (shader is compiled)
  19969. */
  19970. isReady(): boolean;
  19971. /**
  19972. * Binds all textures and uniforms to the shader, this will be run on every pass.
  19973. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  19974. */
  19975. apply(): Nullable<Effect>;
  19976. private _disposeTextures;
  19977. /**
  19978. * Disposes the post process.
  19979. * @param camera The camera to dispose the post process on.
  19980. */
  19981. dispose(camera?: Camera): void;
  19982. }
  19983. }
  19984. declare module BABYLON {
  19985. /** @hidden */
  19986. export var kernelBlurVaryingDeclaration: {
  19987. name: string;
  19988. shader: string;
  19989. };
  19990. }
  19991. declare module BABYLON {
  19992. /** @hidden */
  19993. export var kernelBlurFragment: {
  19994. name: string;
  19995. shader: string;
  19996. };
  19997. }
  19998. declare module BABYLON {
  19999. /** @hidden */
  20000. export var kernelBlurFragment2: {
  20001. name: string;
  20002. shader: string;
  20003. };
  20004. }
  20005. declare module BABYLON {
  20006. /** @hidden */
  20007. export var kernelBlurPixelShader: {
  20008. name: string;
  20009. shader: string;
  20010. };
  20011. }
  20012. declare module BABYLON {
  20013. /** @hidden */
  20014. export var kernelBlurVertex: {
  20015. name: string;
  20016. shader: string;
  20017. };
  20018. }
  20019. declare module BABYLON {
  20020. /** @hidden */
  20021. export var kernelBlurVertexShader: {
  20022. name: string;
  20023. shader: string;
  20024. };
  20025. }
  20026. declare module BABYLON {
  20027. /**
  20028. * The Blur Post Process which blurs an image based on a kernel and direction.
  20029. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20030. */
  20031. export class BlurPostProcess extends PostProcess {
  20032. /** The direction in which to blur the image. */
  20033. direction: Vector2;
  20034. private blockCompilation;
  20035. protected _kernel: number;
  20036. protected _idealKernel: number;
  20037. protected _packedFloat: boolean;
  20038. private _staticDefines;
  20039. /**
  20040. * Sets the length in pixels of the blur sample region
  20041. */
  20042. set kernel(v: number);
  20043. /**
  20044. * Gets the length in pixels of the blur sample region
  20045. */
  20046. get kernel(): number;
  20047. /**
  20048. * Sets wether or not the blur needs to unpack/repack floats
  20049. */
  20050. set packedFloat(v: boolean);
  20051. /**
  20052. * Gets wether or not the blur is unpacking/repacking floats
  20053. */
  20054. get packedFloat(): boolean;
  20055. /**
  20056. * Creates a new instance BlurPostProcess
  20057. * @param name The name of the effect.
  20058. * @param direction The direction in which to blur the image.
  20059. * @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.
  20060. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20061. * @param camera The camera to apply the render pass to.
  20062. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20063. * @param engine The engine which the post process will be applied. (default: current engine)
  20064. * @param reusable If the post process can be reused on the same frame. (default: false)
  20065. * @param textureType Type of textures used when performing the post process. (default: 0)
  20066. * @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)
  20067. */
  20068. constructor(name: string,
  20069. /** The direction in which to blur the image. */
  20070. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20071. /**
  20072. * Updates the effect with the current post process compile time values and recompiles the shader.
  20073. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20074. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20075. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20076. * @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
  20077. * @param onCompiled Called when the shader has been compiled.
  20078. * @param onError Called if there is an error when compiling a shader.
  20079. */
  20080. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20081. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20082. /**
  20083. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20084. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20085. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20086. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20087. * The gaps between physical kernels are compensated for in the weighting of the samples
  20088. * @param idealKernel Ideal blur kernel.
  20089. * @return Nearest best kernel.
  20090. */
  20091. protected _nearestBestKernel(idealKernel: number): number;
  20092. /**
  20093. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20094. * @param x The point on the Gaussian distribution to sample.
  20095. * @return the value of the Gaussian function at x.
  20096. */
  20097. protected _gaussianWeight(x: number): number;
  20098. /**
  20099. * Generates a string that can be used as a floating point number in GLSL.
  20100. * @param x Value to print.
  20101. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20102. * @return GLSL float string.
  20103. */
  20104. protected _glslFloat(x: number, decimalFigures?: number): string;
  20105. }
  20106. }
  20107. declare module BABYLON {
  20108. /**
  20109. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20110. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20111. * You can then easily use it as a reflectionTexture on a flat surface.
  20112. * In case the surface is not a plane, please consider relying on reflection probes.
  20113. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20114. */
  20115. export class MirrorTexture extends RenderTargetTexture {
  20116. private scene;
  20117. /**
  20118. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20119. * 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.
  20120. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20121. */
  20122. mirrorPlane: Plane;
  20123. /**
  20124. * Define the blur ratio used to blur the reflection if needed.
  20125. */
  20126. set blurRatio(value: number);
  20127. get blurRatio(): number;
  20128. /**
  20129. * Define the adaptive blur kernel used to blur the reflection if needed.
  20130. * This will autocompute the closest best match for the `blurKernel`
  20131. */
  20132. set adaptiveBlurKernel(value: number);
  20133. /**
  20134. * Define the blur kernel used to blur the reflection if needed.
  20135. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20136. */
  20137. set blurKernel(value: number);
  20138. /**
  20139. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20140. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20141. */
  20142. set blurKernelX(value: number);
  20143. get blurKernelX(): number;
  20144. /**
  20145. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20146. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20147. */
  20148. set blurKernelY(value: number);
  20149. get blurKernelY(): number;
  20150. private _autoComputeBlurKernel;
  20151. protected _onRatioRescale(): void;
  20152. private _updateGammaSpace;
  20153. private _imageProcessingConfigChangeObserver;
  20154. private _transformMatrix;
  20155. private _mirrorMatrix;
  20156. private _savedViewMatrix;
  20157. private _blurX;
  20158. private _blurY;
  20159. private _adaptiveBlurKernel;
  20160. private _blurKernelX;
  20161. private _blurKernelY;
  20162. private _blurRatio;
  20163. /**
  20164. * Instantiates a Mirror Texture.
  20165. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20166. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20167. * You can then easily use it as a reflectionTexture on a flat surface.
  20168. * In case the surface is not a plane, please consider relying on reflection probes.
  20169. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20170. * @param name
  20171. * @param size
  20172. * @param scene
  20173. * @param generateMipMaps
  20174. * @param type
  20175. * @param samplingMode
  20176. * @param generateDepthBuffer
  20177. */
  20178. constructor(name: string, size: number | {
  20179. width: number;
  20180. height: number;
  20181. } | {
  20182. ratio: number;
  20183. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20184. private _preparePostProcesses;
  20185. /**
  20186. * Clone the mirror texture.
  20187. * @returns the cloned texture
  20188. */
  20189. clone(): MirrorTexture;
  20190. /**
  20191. * Serialize the texture to a JSON representation you could use in Parse later on
  20192. * @returns the serialized JSON representation
  20193. */
  20194. serialize(): any;
  20195. /**
  20196. * Dispose the texture and release its associated resources.
  20197. */
  20198. dispose(): void;
  20199. }
  20200. }
  20201. declare module BABYLON {
  20202. /**
  20203. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20204. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20205. */
  20206. export class Texture extends BaseTexture {
  20207. /**
  20208. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20209. */
  20210. static SerializeBuffers: boolean;
  20211. /** @hidden */
  20212. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  20213. /** @hidden */
  20214. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  20215. /** @hidden */
  20216. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  20217. /** nearest is mag = nearest and min = nearest and mip = linear */
  20218. static readonly NEAREST_SAMPLINGMODE: number;
  20219. /** nearest is mag = nearest and min = nearest and mip = linear */
  20220. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20221. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20222. static readonly BILINEAR_SAMPLINGMODE: number;
  20223. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20224. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20225. /** Trilinear is mag = linear and min = linear and mip = linear */
  20226. static readonly TRILINEAR_SAMPLINGMODE: number;
  20227. /** Trilinear is mag = linear and min = linear and mip = linear */
  20228. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20229. /** mag = nearest and min = nearest and mip = nearest */
  20230. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20231. /** mag = nearest and min = linear and mip = nearest */
  20232. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20233. /** mag = nearest and min = linear and mip = linear */
  20234. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20235. /** mag = nearest and min = linear and mip = none */
  20236. static readonly NEAREST_LINEAR: number;
  20237. /** mag = nearest and min = nearest and mip = none */
  20238. static readonly NEAREST_NEAREST: number;
  20239. /** mag = linear and min = nearest and mip = nearest */
  20240. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20241. /** mag = linear and min = nearest and mip = linear */
  20242. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20243. /** mag = linear and min = linear and mip = none */
  20244. static readonly LINEAR_LINEAR: number;
  20245. /** mag = linear and min = nearest and mip = none */
  20246. static readonly LINEAR_NEAREST: number;
  20247. /** Explicit coordinates mode */
  20248. static readonly EXPLICIT_MODE: number;
  20249. /** Spherical coordinates mode */
  20250. static readonly SPHERICAL_MODE: number;
  20251. /** Planar coordinates mode */
  20252. static readonly PLANAR_MODE: number;
  20253. /** Cubic coordinates mode */
  20254. static readonly CUBIC_MODE: number;
  20255. /** Projection coordinates mode */
  20256. static readonly PROJECTION_MODE: number;
  20257. /** Inverse Cubic coordinates mode */
  20258. static readonly SKYBOX_MODE: number;
  20259. /** Inverse Cubic coordinates mode */
  20260. static readonly INVCUBIC_MODE: number;
  20261. /** Equirectangular coordinates mode */
  20262. static readonly EQUIRECTANGULAR_MODE: number;
  20263. /** Equirectangular Fixed coordinates mode */
  20264. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20265. /** Equirectangular Fixed Mirrored coordinates mode */
  20266. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20267. /** Texture is not repeating outside of 0..1 UVs */
  20268. static readonly CLAMP_ADDRESSMODE: number;
  20269. /** Texture is repeating outside of 0..1 UVs */
  20270. static readonly WRAP_ADDRESSMODE: number;
  20271. /** Texture is repeating and mirrored */
  20272. static readonly MIRROR_ADDRESSMODE: number;
  20273. /**
  20274. * 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
  20275. */
  20276. static UseSerializedUrlIfAny: boolean;
  20277. /**
  20278. * Define the url of the texture.
  20279. */
  20280. url: Nullable<string>;
  20281. /**
  20282. * Define an offset on the texture to offset the u coordinates of the UVs
  20283. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20284. */
  20285. uOffset: number;
  20286. /**
  20287. * Define an offset on the texture to offset the v coordinates of the UVs
  20288. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20289. */
  20290. vOffset: number;
  20291. /**
  20292. * Define an offset on the texture to scale the u coordinates of the UVs
  20293. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20294. */
  20295. uScale: number;
  20296. /**
  20297. * Define an offset on the texture to scale the v coordinates of the UVs
  20298. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20299. */
  20300. vScale: number;
  20301. /**
  20302. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20303. * @see http://doc.babylonjs.com/how_to/more_materials
  20304. */
  20305. uAng: number;
  20306. /**
  20307. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20308. * @see http://doc.babylonjs.com/how_to/more_materials
  20309. */
  20310. vAng: number;
  20311. /**
  20312. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20313. * @see http://doc.babylonjs.com/how_to/more_materials
  20314. */
  20315. wAng: number;
  20316. /**
  20317. * Defines the center of rotation (U)
  20318. */
  20319. uRotationCenter: number;
  20320. /**
  20321. * Defines the center of rotation (V)
  20322. */
  20323. vRotationCenter: number;
  20324. /**
  20325. * Defines the center of rotation (W)
  20326. */
  20327. wRotationCenter: number;
  20328. /**
  20329. * Are mip maps generated for this texture or not.
  20330. */
  20331. get noMipmap(): boolean;
  20332. /**
  20333. * List of inspectable custom properties (used by the Inspector)
  20334. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20335. */
  20336. inspectableCustomProperties: Nullable<IInspectable[]>;
  20337. private _noMipmap;
  20338. /** @hidden */
  20339. _invertY: boolean;
  20340. private _rowGenerationMatrix;
  20341. private _cachedTextureMatrix;
  20342. private _projectionModeMatrix;
  20343. private _t0;
  20344. private _t1;
  20345. private _t2;
  20346. private _cachedUOffset;
  20347. private _cachedVOffset;
  20348. private _cachedUScale;
  20349. private _cachedVScale;
  20350. private _cachedUAng;
  20351. private _cachedVAng;
  20352. private _cachedWAng;
  20353. private _cachedProjectionMatrixId;
  20354. private _cachedCoordinatesMode;
  20355. /** @hidden */
  20356. protected _initialSamplingMode: number;
  20357. /** @hidden */
  20358. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20359. private _deleteBuffer;
  20360. protected _format: Nullable<number>;
  20361. private _delayedOnLoad;
  20362. private _delayedOnError;
  20363. private _mimeType?;
  20364. /**
  20365. * Observable triggered once the texture has been loaded.
  20366. */
  20367. onLoadObservable: Observable<Texture>;
  20368. protected _isBlocking: boolean;
  20369. /**
  20370. * Is the texture preventing material to render while loading.
  20371. * If false, a default texture will be used instead of the loading one during the preparation step.
  20372. */
  20373. set isBlocking(value: boolean);
  20374. get isBlocking(): boolean;
  20375. /**
  20376. * Get the current sampling mode associated with the texture.
  20377. */
  20378. get samplingMode(): number;
  20379. /**
  20380. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20381. */
  20382. get invertY(): boolean;
  20383. /**
  20384. * Instantiates a new texture.
  20385. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20386. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20387. * @param url defines the url of the picture to load as a texture
  20388. * @param scene defines the scene or engine the texture will belong to
  20389. * @param noMipmap defines if the texture will require mip maps or not
  20390. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20391. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20392. * @param onLoad defines a callback triggered when the texture has been loaded
  20393. * @param onError defines a callback triggered when an error occurred during the loading session
  20394. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20395. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20396. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20397. * @param mimeType defines an optional mime type information
  20398. */
  20399. 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);
  20400. /**
  20401. * Update the url (and optional buffer) of this texture if url was null during construction.
  20402. * @param url the url of the texture
  20403. * @param buffer the buffer of the texture (defaults to null)
  20404. * @param onLoad callback called when the texture is loaded (defaults to null)
  20405. */
  20406. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20407. /**
  20408. * Finish the loading sequence of a texture flagged as delayed load.
  20409. * @hidden
  20410. */
  20411. delayLoad(): void;
  20412. private _prepareRowForTextureGeneration;
  20413. /**
  20414. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20415. * @returns the transform matrix of the texture.
  20416. */
  20417. getTextureMatrix(uBase?: number): Matrix;
  20418. /**
  20419. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20420. * @returns The reflection texture transform
  20421. */
  20422. getReflectionTextureMatrix(): Matrix;
  20423. /**
  20424. * Clones the texture.
  20425. * @returns the cloned texture
  20426. */
  20427. clone(): Texture;
  20428. /**
  20429. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20430. * @returns The JSON representation of the texture
  20431. */
  20432. serialize(): any;
  20433. /**
  20434. * Get the current class name of the texture useful for serialization or dynamic coding.
  20435. * @returns "Texture"
  20436. */
  20437. getClassName(): string;
  20438. /**
  20439. * Dispose the texture and release its associated resources.
  20440. */
  20441. dispose(): void;
  20442. /**
  20443. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20444. * @param parsedTexture Define the JSON representation of the texture
  20445. * @param scene Define the scene the parsed texture should be instantiated in
  20446. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20447. * @returns The parsed texture if successful
  20448. */
  20449. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20450. /**
  20451. * Creates a texture from its base 64 representation.
  20452. * @param data Define the base64 payload without the data: prefix
  20453. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20454. * @param scene Define the scene the texture should belong to
  20455. * @param noMipmap Forces the texture to not create mip map information if true
  20456. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20457. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20458. * @param onLoad define a callback triggered when the texture has been loaded
  20459. * @param onError define a callback triggered when an error occurred during the loading session
  20460. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20461. * @returns the created texture
  20462. */
  20463. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20464. /**
  20465. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20466. * @param data Define the base64 payload without the data: prefix
  20467. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20468. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20469. * @param scene Define the scene the texture should belong to
  20470. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20471. * @param noMipmap Forces the texture to not create mip map information if true
  20472. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20473. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20474. * @param onLoad define a callback triggered when the texture has been loaded
  20475. * @param onError define a callback triggered when an error occurred during the loading session
  20476. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20477. * @returns the created texture
  20478. */
  20479. 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;
  20480. }
  20481. }
  20482. declare module BABYLON {
  20483. /**
  20484. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20485. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20486. */
  20487. export class PostProcessManager {
  20488. private _scene;
  20489. private _indexBuffer;
  20490. private _vertexBuffers;
  20491. /**
  20492. * Creates a new instance PostProcess
  20493. * @param scene The scene that the post process is associated with.
  20494. */
  20495. constructor(scene: Scene);
  20496. private _prepareBuffers;
  20497. private _buildIndexBuffer;
  20498. /**
  20499. * Rebuilds the vertex buffers of the manager.
  20500. * @hidden
  20501. */
  20502. _rebuild(): void;
  20503. /**
  20504. * Prepares a frame to be run through a post process.
  20505. * @param sourceTexture The input texture to the post procesess. (default: null)
  20506. * @param postProcesses An array of post processes to be run. (default: null)
  20507. * @returns True if the post processes were able to be run.
  20508. * @hidden
  20509. */
  20510. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20511. /**
  20512. * Manually render a set of post processes to a texture.
  20513. * @param postProcesses An array of post processes to be run.
  20514. * @param targetTexture The target texture to render to.
  20515. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20516. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20517. * @param lodLevel defines which lod of the texture to render to
  20518. */
  20519. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20520. /**
  20521. * Finalize the result of the output of the postprocesses.
  20522. * @param doNotPresent If true the result will not be displayed to the screen.
  20523. * @param targetTexture The target texture to render to.
  20524. * @param faceIndex The index of the face to bind the target texture to.
  20525. * @param postProcesses The array of post processes to render.
  20526. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20527. * @hidden
  20528. */
  20529. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20530. /**
  20531. * Disposes of the post process manager.
  20532. */
  20533. dispose(): void;
  20534. }
  20535. }
  20536. declare module BABYLON {
  20537. /**
  20538. * This Helps creating a texture that will be created from a camera in your scene.
  20539. * It is basically a dynamic texture that could be used to create special effects for instance.
  20540. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20541. */
  20542. export class RenderTargetTexture extends Texture {
  20543. isCube: boolean;
  20544. /**
  20545. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20546. */
  20547. static readonly REFRESHRATE_RENDER_ONCE: number;
  20548. /**
  20549. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20550. */
  20551. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20552. /**
  20553. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20554. * the central point of your effect and can save a lot of performances.
  20555. */
  20556. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20557. /**
  20558. * Use this predicate to dynamically define the list of mesh you want to render.
  20559. * If set, the renderList property will be overwritten.
  20560. */
  20561. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20562. private _renderList;
  20563. /**
  20564. * Use this list to define the list of mesh you want to render.
  20565. */
  20566. get renderList(): Nullable<Array<AbstractMesh>>;
  20567. set renderList(value: Nullable<Array<AbstractMesh>>);
  20568. /**
  20569. * Use this function to overload the renderList array at rendering time.
  20570. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20571. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20572. * the cube (if the RTT is a cube, else layerOrFace=0).
  20573. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  20574. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  20575. * hold dummy elements!
  20576. */
  20577. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  20578. private _hookArray;
  20579. /**
  20580. * Define if particles should be rendered in your texture.
  20581. */
  20582. renderParticles: boolean;
  20583. /**
  20584. * Define if sprites should be rendered in your texture.
  20585. */
  20586. renderSprites: boolean;
  20587. /**
  20588. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20589. */
  20590. coordinatesMode: number;
  20591. /**
  20592. * Define the camera used to render the texture.
  20593. */
  20594. activeCamera: Nullable<Camera>;
  20595. /**
  20596. * Override the mesh isReady function with your own one.
  20597. */
  20598. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  20599. /**
  20600. * Override the render function of the texture with your own one.
  20601. */
  20602. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20603. /**
  20604. * Define if camera post processes should be use while rendering the texture.
  20605. */
  20606. useCameraPostProcesses: boolean;
  20607. /**
  20608. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20609. */
  20610. ignoreCameraViewport: boolean;
  20611. private _postProcessManager;
  20612. private _postProcesses;
  20613. private _resizeObserver;
  20614. /**
  20615. * An event triggered when the texture is unbind.
  20616. */
  20617. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20618. /**
  20619. * An event triggered when the texture is unbind.
  20620. */
  20621. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20622. private _onAfterUnbindObserver;
  20623. /**
  20624. * Set a after unbind callback in the texture.
  20625. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20626. */
  20627. set onAfterUnbind(callback: () => void);
  20628. /**
  20629. * An event triggered before rendering the texture
  20630. */
  20631. onBeforeRenderObservable: Observable<number>;
  20632. private _onBeforeRenderObserver;
  20633. /**
  20634. * Set a before render callback in the texture.
  20635. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20636. */
  20637. set onBeforeRender(callback: (faceIndex: number) => void);
  20638. /**
  20639. * An event triggered after rendering the texture
  20640. */
  20641. onAfterRenderObservable: Observable<number>;
  20642. private _onAfterRenderObserver;
  20643. /**
  20644. * Set a after render callback in the texture.
  20645. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20646. */
  20647. set onAfterRender(callback: (faceIndex: number) => void);
  20648. /**
  20649. * An event triggered after the texture clear
  20650. */
  20651. onClearObservable: Observable<Engine>;
  20652. private _onClearObserver;
  20653. /**
  20654. * Set a clear callback in the texture.
  20655. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20656. */
  20657. set onClear(callback: (Engine: Engine) => void);
  20658. /**
  20659. * An event triggered when the texture is resized.
  20660. */
  20661. onResizeObservable: Observable<RenderTargetTexture>;
  20662. /**
  20663. * Define the clear color of the Render Target if it should be different from the scene.
  20664. */
  20665. clearColor: Color4;
  20666. protected _size: number | {
  20667. width: number;
  20668. height: number;
  20669. layers?: number;
  20670. };
  20671. protected _initialSizeParameter: number | {
  20672. width: number;
  20673. height: number;
  20674. } | {
  20675. ratio: number;
  20676. };
  20677. protected _sizeRatio: Nullable<number>;
  20678. /** @hidden */
  20679. _generateMipMaps: boolean;
  20680. protected _renderingManager: RenderingManager;
  20681. /** @hidden */
  20682. _waitingRenderList: string[];
  20683. protected _doNotChangeAspectRatio: boolean;
  20684. protected _currentRefreshId: number;
  20685. protected _refreshRate: number;
  20686. protected _textureMatrix: Matrix;
  20687. protected _samples: number;
  20688. protected _renderTargetOptions: RenderTargetCreationOptions;
  20689. /**
  20690. * Gets render target creation options that were used.
  20691. */
  20692. get renderTargetOptions(): RenderTargetCreationOptions;
  20693. protected _engine: Engine;
  20694. protected _onRatioRescale(): void;
  20695. /**
  20696. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20697. * It must define where the camera used to render the texture is set
  20698. */
  20699. boundingBoxPosition: Vector3;
  20700. private _boundingBoxSize;
  20701. /**
  20702. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20703. * When defined, the cubemap will switch to local mode
  20704. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20705. * @example https://www.babylonjs-playground.com/#RNASML
  20706. */
  20707. set boundingBoxSize(value: Vector3);
  20708. get boundingBoxSize(): Vector3;
  20709. /**
  20710. * In case the RTT has been created with a depth texture, get the associated
  20711. * depth texture.
  20712. * Otherwise, return null.
  20713. */
  20714. get depthStencilTexture(): Nullable<InternalTexture>;
  20715. /**
  20716. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20717. * or used a shadow, depth texture...
  20718. * @param name The friendly name of the texture
  20719. * @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)
  20720. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20721. * @param generateMipMaps True if mip maps need to be generated after render.
  20722. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20723. * @param type The type of the buffer in the RTT (int, half float, float...)
  20724. * @param isCube True if a cube texture needs to be created
  20725. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20726. * @param generateDepthBuffer True to generate a depth buffer
  20727. * @param generateStencilBuffer True to generate a stencil buffer
  20728. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20729. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20730. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20731. */
  20732. constructor(name: string, size: number | {
  20733. width: number;
  20734. height: number;
  20735. layers?: number;
  20736. } | {
  20737. ratio: number;
  20738. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20739. /**
  20740. * Creates a depth stencil texture.
  20741. * This is only available in WebGL 2 or with the depth texture extension available.
  20742. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20743. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20744. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20745. */
  20746. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20747. private _processSizeParameter;
  20748. /**
  20749. * Define the number of samples to use in case of MSAA.
  20750. * It defaults to one meaning no MSAA has been enabled.
  20751. */
  20752. get samples(): number;
  20753. set samples(value: number);
  20754. /**
  20755. * Resets the refresh counter of the texture and start bak from scratch.
  20756. * Could be useful to regenerate the texture if it is setup to render only once.
  20757. */
  20758. resetRefreshCounter(): void;
  20759. /**
  20760. * Define the refresh rate of the texture or the rendering frequency.
  20761. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20762. */
  20763. get refreshRate(): number;
  20764. set refreshRate(value: number);
  20765. /**
  20766. * Adds a post process to the render target rendering passes.
  20767. * @param postProcess define the post process to add
  20768. */
  20769. addPostProcess(postProcess: PostProcess): void;
  20770. /**
  20771. * Clear all the post processes attached to the render target
  20772. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20773. */
  20774. clearPostProcesses(dispose?: boolean): void;
  20775. /**
  20776. * Remove one of the post process from the list of attached post processes to the texture
  20777. * @param postProcess define the post process to remove from the list
  20778. */
  20779. removePostProcess(postProcess: PostProcess): void;
  20780. /** @hidden */
  20781. _shouldRender(): boolean;
  20782. /**
  20783. * Gets the actual render size of the texture.
  20784. * @returns the width of the render size
  20785. */
  20786. getRenderSize(): number;
  20787. /**
  20788. * Gets the actual render width of the texture.
  20789. * @returns the width of the render size
  20790. */
  20791. getRenderWidth(): number;
  20792. /**
  20793. * Gets the actual render height of the texture.
  20794. * @returns the height of the render size
  20795. */
  20796. getRenderHeight(): number;
  20797. /**
  20798. * Gets the actual number of layers of the texture.
  20799. * @returns the number of layers
  20800. */
  20801. getRenderLayers(): number;
  20802. /**
  20803. * Get if the texture can be rescaled or not.
  20804. */
  20805. get canRescale(): boolean;
  20806. /**
  20807. * Resize the texture using a ratio.
  20808. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20809. */
  20810. scale(ratio: number): void;
  20811. /**
  20812. * Get the texture reflection matrix used to rotate/transform the reflection.
  20813. * @returns the reflection matrix
  20814. */
  20815. getReflectionTextureMatrix(): Matrix;
  20816. /**
  20817. * Resize the texture to a new desired size.
  20818. * Be carrefull as it will recreate all the data in the new texture.
  20819. * @param size Define the new size. It can be:
  20820. * - a number for squared texture,
  20821. * - an object containing { width: number, height: number }
  20822. * - or an object containing a ratio { ratio: number }
  20823. */
  20824. resize(size: number | {
  20825. width: number;
  20826. height: number;
  20827. } | {
  20828. ratio: number;
  20829. }): void;
  20830. private _defaultRenderListPrepared;
  20831. /**
  20832. * Renders all the objects from the render list into the texture.
  20833. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20834. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20835. */
  20836. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20837. private _bestReflectionRenderTargetDimension;
  20838. private _prepareRenderingManager;
  20839. /**
  20840. * @hidden
  20841. * @param faceIndex face index to bind to if this is a cubetexture
  20842. * @param layer defines the index of the texture to bind in the array
  20843. */
  20844. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  20845. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20846. private renderToTarget;
  20847. /**
  20848. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20849. * This allowed control for front to back rendering or reversly depending of the special needs.
  20850. *
  20851. * @param renderingGroupId The rendering group id corresponding to its index
  20852. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20853. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20854. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20855. */
  20856. 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;
  20857. /**
  20858. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20859. *
  20860. * @param renderingGroupId The rendering group id corresponding to its index
  20861. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20862. */
  20863. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20864. /**
  20865. * Clones the texture.
  20866. * @returns the cloned texture
  20867. */
  20868. clone(): RenderTargetTexture;
  20869. /**
  20870. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20871. * @returns The JSON representation of the texture
  20872. */
  20873. serialize(): any;
  20874. /**
  20875. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20876. */
  20877. disposeFramebufferObjects(): void;
  20878. /**
  20879. * Dispose the texture and release its associated resources.
  20880. */
  20881. dispose(): void;
  20882. /** @hidden */
  20883. _rebuild(): void;
  20884. /**
  20885. * Clear the info related to rendering groups preventing retention point in material dispose.
  20886. */
  20887. freeRenderingGroups(): void;
  20888. /**
  20889. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20890. * @returns the view count
  20891. */
  20892. getViewCount(): number;
  20893. }
  20894. }
  20895. declare module BABYLON {
  20896. /**
  20897. * Options for compiling materials.
  20898. */
  20899. export interface IMaterialCompilationOptions {
  20900. /**
  20901. * Defines whether clip planes are enabled.
  20902. */
  20903. clipPlane: boolean;
  20904. /**
  20905. * Defines whether instances are enabled.
  20906. */
  20907. useInstances: boolean;
  20908. }
  20909. /**
  20910. * Base class for the main features of a material in Babylon.js
  20911. */
  20912. export class Material implements IAnimatable {
  20913. /**
  20914. * Returns the triangle fill mode
  20915. */
  20916. static readonly TriangleFillMode: number;
  20917. /**
  20918. * Returns the wireframe mode
  20919. */
  20920. static readonly WireFrameFillMode: number;
  20921. /**
  20922. * Returns the point fill mode
  20923. */
  20924. static readonly PointFillMode: number;
  20925. /**
  20926. * Returns the point list draw mode
  20927. */
  20928. static readonly PointListDrawMode: number;
  20929. /**
  20930. * Returns the line list draw mode
  20931. */
  20932. static readonly LineListDrawMode: number;
  20933. /**
  20934. * Returns the line loop draw mode
  20935. */
  20936. static readonly LineLoopDrawMode: number;
  20937. /**
  20938. * Returns the line strip draw mode
  20939. */
  20940. static readonly LineStripDrawMode: number;
  20941. /**
  20942. * Returns the triangle strip draw mode
  20943. */
  20944. static readonly TriangleStripDrawMode: number;
  20945. /**
  20946. * Returns the triangle fan draw mode
  20947. */
  20948. static readonly TriangleFanDrawMode: number;
  20949. /**
  20950. * Stores the clock-wise side orientation
  20951. */
  20952. static readonly ClockWiseSideOrientation: number;
  20953. /**
  20954. * Stores the counter clock-wise side orientation
  20955. */
  20956. static readonly CounterClockWiseSideOrientation: number;
  20957. /**
  20958. * The dirty texture flag value
  20959. */
  20960. static readonly TextureDirtyFlag: number;
  20961. /**
  20962. * The dirty light flag value
  20963. */
  20964. static readonly LightDirtyFlag: number;
  20965. /**
  20966. * The dirty fresnel flag value
  20967. */
  20968. static readonly FresnelDirtyFlag: number;
  20969. /**
  20970. * The dirty attribute flag value
  20971. */
  20972. static readonly AttributesDirtyFlag: number;
  20973. /**
  20974. * The dirty misc flag value
  20975. */
  20976. static readonly MiscDirtyFlag: number;
  20977. /**
  20978. * The all dirty flag value
  20979. */
  20980. static readonly AllDirtyFlag: number;
  20981. /**
  20982. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  20983. */
  20984. static readonly MATERIAL_OPAQUE: number;
  20985. /**
  20986. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  20987. */
  20988. static readonly MATERIAL_ALPHATEST: number;
  20989. /**
  20990. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  20991. */
  20992. static readonly MATERIAL_ALPHABLEND: number;
  20993. /**
  20994. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  20995. * They are also discarded below the alpha cutoff threshold to improve performances.
  20996. */
  20997. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  20998. /**
  20999. * The ID of the material
  21000. */
  21001. id: string;
  21002. /**
  21003. * Gets or sets the unique id of the material
  21004. */
  21005. uniqueId: number;
  21006. /**
  21007. * The name of the material
  21008. */
  21009. name: string;
  21010. /**
  21011. * Gets or sets user defined metadata
  21012. */
  21013. metadata: any;
  21014. /**
  21015. * For internal use only. Please do not use.
  21016. */
  21017. reservedDataStore: any;
  21018. /**
  21019. * Specifies if the ready state should be checked on each call
  21020. */
  21021. checkReadyOnEveryCall: boolean;
  21022. /**
  21023. * Specifies if the ready state should be checked once
  21024. */
  21025. checkReadyOnlyOnce: boolean;
  21026. /**
  21027. * The state of the material
  21028. */
  21029. state: string;
  21030. /**
  21031. * The alpha value of the material
  21032. */
  21033. protected _alpha: number;
  21034. /**
  21035. * List of inspectable custom properties (used by the Inspector)
  21036. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21037. */
  21038. inspectableCustomProperties: IInspectable[];
  21039. /**
  21040. * Sets the alpha value of the material
  21041. */
  21042. set alpha(value: number);
  21043. /**
  21044. * Gets the alpha value of the material
  21045. */
  21046. get alpha(): number;
  21047. /**
  21048. * Specifies if back face culling is enabled
  21049. */
  21050. protected _backFaceCulling: boolean;
  21051. /**
  21052. * Sets the back-face culling state
  21053. */
  21054. set backFaceCulling(value: boolean);
  21055. /**
  21056. * Gets the back-face culling state
  21057. */
  21058. get backFaceCulling(): boolean;
  21059. /**
  21060. * Stores the value for side orientation
  21061. */
  21062. sideOrientation: number;
  21063. /**
  21064. * Callback triggered when the material is compiled
  21065. */
  21066. onCompiled: Nullable<(effect: Effect) => void>;
  21067. /**
  21068. * Callback triggered when an error occurs
  21069. */
  21070. onError: Nullable<(effect: Effect, errors: string) => void>;
  21071. /**
  21072. * Callback triggered to get the render target textures
  21073. */
  21074. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21075. /**
  21076. * Gets a boolean indicating that current material needs to register RTT
  21077. */
  21078. get hasRenderTargetTextures(): boolean;
  21079. /**
  21080. * Specifies if the material should be serialized
  21081. */
  21082. doNotSerialize: boolean;
  21083. /**
  21084. * @hidden
  21085. */
  21086. _storeEffectOnSubMeshes: boolean;
  21087. /**
  21088. * Stores the animations for the material
  21089. */
  21090. animations: Nullable<Array<Animation>>;
  21091. /**
  21092. * An event triggered when the material is disposed
  21093. */
  21094. onDisposeObservable: Observable<Material>;
  21095. /**
  21096. * An observer which watches for dispose events
  21097. */
  21098. private _onDisposeObserver;
  21099. private _onUnBindObservable;
  21100. /**
  21101. * Called during a dispose event
  21102. */
  21103. set onDispose(callback: () => void);
  21104. private _onBindObservable;
  21105. /**
  21106. * An event triggered when the material is bound
  21107. */
  21108. get onBindObservable(): Observable<AbstractMesh>;
  21109. /**
  21110. * An observer which watches for bind events
  21111. */
  21112. private _onBindObserver;
  21113. /**
  21114. * Called during a bind event
  21115. */
  21116. set onBind(callback: (Mesh: AbstractMesh) => void);
  21117. /**
  21118. * An event triggered when the material is unbound
  21119. */
  21120. get onUnBindObservable(): Observable<Material>;
  21121. /**
  21122. * Stores the value of the alpha mode
  21123. */
  21124. private _alphaMode;
  21125. /**
  21126. * Sets the value of the alpha mode.
  21127. *
  21128. * | Value | Type | Description |
  21129. * | --- | --- | --- |
  21130. * | 0 | ALPHA_DISABLE | |
  21131. * | 1 | ALPHA_ADD | |
  21132. * | 2 | ALPHA_COMBINE | |
  21133. * | 3 | ALPHA_SUBTRACT | |
  21134. * | 4 | ALPHA_MULTIPLY | |
  21135. * | 5 | ALPHA_MAXIMIZED | |
  21136. * | 6 | ALPHA_ONEONE | |
  21137. * | 7 | ALPHA_PREMULTIPLIED | |
  21138. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21139. * | 9 | ALPHA_INTERPOLATE | |
  21140. * | 10 | ALPHA_SCREENMODE | |
  21141. *
  21142. */
  21143. set alphaMode(value: number);
  21144. /**
  21145. * Gets the value of the alpha mode
  21146. */
  21147. get alphaMode(): number;
  21148. /**
  21149. * Stores the state of the need depth pre-pass value
  21150. */
  21151. private _needDepthPrePass;
  21152. /**
  21153. * Sets the need depth pre-pass value
  21154. */
  21155. set needDepthPrePass(value: boolean);
  21156. /**
  21157. * Gets the depth pre-pass value
  21158. */
  21159. get needDepthPrePass(): boolean;
  21160. /**
  21161. * Specifies if depth writing should be disabled
  21162. */
  21163. disableDepthWrite: boolean;
  21164. /**
  21165. * Specifies if depth writing should be forced
  21166. */
  21167. forceDepthWrite: boolean;
  21168. /**
  21169. * Specifies the depth function that should be used. 0 means the default engine function
  21170. */
  21171. depthFunction: number;
  21172. /**
  21173. * Specifies if there should be a separate pass for culling
  21174. */
  21175. separateCullingPass: boolean;
  21176. /**
  21177. * Stores the state specifing if fog should be enabled
  21178. */
  21179. private _fogEnabled;
  21180. /**
  21181. * Sets the state for enabling fog
  21182. */
  21183. set fogEnabled(value: boolean);
  21184. /**
  21185. * Gets the value of the fog enabled state
  21186. */
  21187. get fogEnabled(): boolean;
  21188. /**
  21189. * Stores the size of points
  21190. */
  21191. pointSize: number;
  21192. /**
  21193. * Stores the z offset value
  21194. */
  21195. zOffset: number;
  21196. /**
  21197. * Gets a value specifying if wireframe mode is enabled
  21198. */
  21199. get wireframe(): boolean;
  21200. /**
  21201. * Sets the state of wireframe mode
  21202. */
  21203. set wireframe(value: boolean);
  21204. /**
  21205. * Gets the value specifying if point clouds are enabled
  21206. */
  21207. get pointsCloud(): boolean;
  21208. /**
  21209. * Sets the state of point cloud mode
  21210. */
  21211. set pointsCloud(value: boolean);
  21212. /**
  21213. * Gets the material fill mode
  21214. */
  21215. get fillMode(): number;
  21216. /**
  21217. * Sets the material fill mode
  21218. */
  21219. set fillMode(value: number);
  21220. /**
  21221. * @hidden
  21222. * Stores the effects for the material
  21223. */
  21224. _effect: Nullable<Effect>;
  21225. /**
  21226. * Specifies if uniform buffers should be used
  21227. */
  21228. private _useUBO;
  21229. /**
  21230. * Stores a reference to the scene
  21231. */
  21232. private _scene;
  21233. /**
  21234. * Stores the fill mode state
  21235. */
  21236. private _fillMode;
  21237. /**
  21238. * Specifies if the depth write state should be cached
  21239. */
  21240. private _cachedDepthWriteState;
  21241. /**
  21242. * Specifies if the depth function state should be cached
  21243. */
  21244. private _cachedDepthFunctionState;
  21245. /**
  21246. * Stores the uniform buffer
  21247. */
  21248. protected _uniformBuffer: UniformBuffer;
  21249. /** @hidden */
  21250. _indexInSceneMaterialArray: number;
  21251. /** @hidden */
  21252. meshMap: Nullable<{
  21253. [id: string]: AbstractMesh | undefined;
  21254. }>;
  21255. /**
  21256. * Creates a material instance
  21257. * @param name defines the name of the material
  21258. * @param scene defines the scene to reference
  21259. * @param doNotAdd specifies if the material should be added to the scene
  21260. */
  21261. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21262. /**
  21263. * Returns a string representation of the current material
  21264. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21265. * @returns a string with material information
  21266. */
  21267. toString(fullDetails?: boolean): string;
  21268. /**
  21269. * Gets the class name of the material
  21270. * @returns a string with the class name of the material
  21271. */
  21272. getClassName(): string;
  21273. /**
  21274. * Specifies if updates for the material been locked
  21275. */
  21276. get isFrozen(): boolean;
  21277. /**
  21278. * Locks updates for the material
  21279. */
  21280. freeze(): void;
  21281. /**
  21282. * Unlocks updates for the material
  21283. */
  21284. unfreeze(): void;
  21285. /**
  21286. * Specifies if the material is ready to be used
  21287. * @param mesh defines the mesh to check
  21288. * @param useInstances specifies if instances should be used
  21289. * @returns a boolean indicating if the material is ready to be used
  21290. */
  21291. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21292. /**
  21293. * Specifies that the submesh is ready to be used
  21294. * @param mesh defines the mesh to check
  21295. * @param subMesh defines which submesh to check
  21296. * @param useInstances specifies that instances should be used
  21297. * @returns a boolean indicating that the submesh is ready or not
  21298. */
  21299. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21300. /**
  21301. * Returns the material effect
  21302. * @returns the effect associated with the material
  21303. */
  21304. getEffect(): Nullable<Effect>;
  21305. /**
  21306. * Returns the current scene
  21307. * @returns a Scene
  21308. */
  21309. getScene(): Scene;
  21310. /**
  21311. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21312. */
  21313. protected _forceAlphaTest: boolean;
  21314. /**
  21315. * The transparency mode of the material.
  21316. */
  21317. protected _transparencyMode: Nullable<number>;
  21318. /**
  21319. * Gets the current transparency mode.
  21320. */
  21321. get transparencyMode(): Nullable<number>;
  21322. /**
  21323. * Sets the transparency mode of the material.
  21324. *
  21325. * | Value | Type | Description |
  21326. * | ----- | ----------------------------------- | ----------- |
  21327. * | 0 | OPAQUE | |
  21328. * | 1 | ALPHATEST | |
  21329. * | 2 | ALPHABLEND | |
  21330. * | 3 | ALPHATESTANDBLEND | |
  21331. *
  21332. */
  21333. set transparencyMode(value: Nullable<number>);
  21334. /**
  21335. * Returns true if alpha blending should be disabled.
  21336. */
  21337. protected get _disableAlphaBlending(): boolean;
  21338. /**
  21339. * Specifies whether or not this material should be rendered in alpha blend mode.
  21340. * @returns a boolean specifying if alpha blending is needed
  21341. */
  21342. needAlphaBlending(): boolean;
  21343. /**
  21344. * Specifies if the mesh will require alpha blending
  21345. * @param mesh defines the mesh to check
  21346. * @returns a boolean specifying if alpha blending is needed for the mesh
  21347. */
  21348. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21349. /**
  21350. * Specifies whether or not this material should be rendered in alpha test mode.
  21351. * @returns a boolean specifying if an alpha test is needed.
  21352. */
  21353. needAlphaTesting(): boolean;
  21354. /**
  21355. * Specifies if material alpha testing should be turned on for the mesh
  21356. * @param mesh defines the mesh to check
  21357. */
  21358. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21359. /**
  21360. * Gets the texture used for the alpha test
  21361. * @returns the texture to use for alpha testing
  21362. */
  21363. getAlphaTestTexture(): Nullable<BaseTexture>;
  21364. /**
  21365. * Marks the material to indicate that it needs to be re-calculated
  21366. */
  21367. markDirty(): void;
  21368. /** @hidden */
  21369. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21370. /**
  21371. * Binds the material to the mesh
  21372. * @param world defines the world transformation matrix
  21373. * @param mesh defines the mesh to bind the material to
  21374. */
  21375. bind(world: Matrix, mesh?: Mesh): void;
  21376. /**
  21377. * Binds the submesh to the material
  21378. * @param world defines the world transformation matrix
  21379. * @param mesh defines the mesh containing the submesh
  21380. * @param subMesh defines the submesh to bind the material to
  21381. */
  21382. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21383. /**
  21384. * Binds the world matrix to the material
  21385. * @param world defines the world transformation matrix
  21386. */
  21387. bindOnlyWorldMatrix(world: Matrix): void;
  21388. /**
  21389. * Binds the scene's uniform buffer to the effect.
  21390. * @param effect defines the effect to bind to the scene uniform buffer
  21391. * @param sceneUbo defines the uniform buffer storing scene data
  21392. */
  21393. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21394. /**
  21395. * Binds the view matrix to the effect
  21396. * @param effect defines the effect to bind the view matrix to
  21397. */
  21398. bindView(effect: Effect): void;
  21399. /**
  21400. * Binds the view projection matrix to the effect
  21401. * @param effect defines the effect to bind the view projection matrix to
  21402. */
  21403. bindViewProjection(effect: Effect): void;
  21404. /**
  21405. * Processes to execute after binding the material to a mesh
  21406. * @param mesh defines the rendered mesh
  21407. */
  21408. protected _afterBind(mesh?: Mesh): void;
  21409. /**
  21410. * Unbinds the material from the mesh
  21411. */
  21412. unbind(): void;
  21413. /**
  21414. * Gets the active textures from the material
  21415. * @returns an array of textures
  21416. */
  21417. getActiveTextures(): BaseTexture[];
  21418. /**
  21419. * Specifies if the material uses a texture
  21420. * @param texture defines the texture to check against the material
  21421. * @returns a boolean specifying if the material uses the texture
  21422. */
  21423. hasTexture(texture: BaseTexture): boolean;
  21424. /**
  21425. * Makes a duplicate of the material, and gives it a new name
  21426. * @param name defines the new name for the duplicated material
  21427. * @returns the cloned material
  21428. */
  21429. clone(name: string): Nullable<Material>;
  21430. /**
  21431. * Gets the meshes bound to the material
  21432. * @returns an array of meshes bound to the material
  21433. */
  21434. getBindedMeshes(): AbstractMesh[];
  21435. /**
  21436. * Force shader compilation
  21437. * @param mesh defines the mesh associated with this material
  21438. * @param onCompiled defines a function to execute once the material is compiled
  21439. * @param options defines the options to configure the compilation
  21440. * @param onError defines a function to execute if the material fails compiling
  21441. */
  21442. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21443. /**
  21444. * Force shader compilation
  21445. * @param mesh defines the mesh that will use this material
  21446. * @param options defines additional options for compiling the shaders
  21447. * @returns a promise that resolves when the compilation completes
  21448. */
  21449. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21450. private static readonly _AllDirtyCallBack;
  21451. private static readonly _ImageProcessingDirtyCallBack;
  21452. private static readonly _TextureDirtyCallBack;
  21453. private static readonly _FresnelDirtyCallBack;
  21454. private static readonly _MiscDirtyCallBack;
  21455. private static readonly _LightsDirtyCallBack;
  21456. private static readonly _AttributeDirtyCallBack;
  21457. private static _FresnelAndMiscDirtyCallBack;
  21458. private static _TextureAndMiscDirtyCallBack;
  21459. private static readonly _DirtyCallbackArray;
  21460. private static readonly _RunDirtyCallBacks;
  21461. /**
  21462. * Marks a define in the material to indicate that it needs to be re-computed
  21463. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21464. */
  21465. markAsDirty(flag: number): void;
  21466. /**
  21467. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21468. * @param func defines a function which checks material defines against the submeshes
  21469. */
  21470. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21471. /**
  21472. * Indicates that we need to re-calculated for all submeshes
  21473. */
  21474. protected _markAllSubMeshesAsAllDirty(): void;
  21475. /**
  21476. * Indicates that image processing needs to be re-calculated for all submeshes
  21477. */
  21478. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21479. /**
  21480. * Indicates that textures need to be re-calculated for all submeshes
  21481. */
  21482. protected _markAllSubMeshesAsTexturesDirty(): void;
  21483. /**
  21484. * Indicates that fresnel needs to be re-calculated for all submeshes
  21485. */
  21486. protected _markAllSubMeshesAsFresnelDirty(): void;
  21487. /**
  21488. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21489. */
  21490. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21491. /**
  21492. * Indicates that lights need to be re-calculated for all submeshes
  21493. */
  21494. protected _markAllSubMeshesAsLightsDirty(): void;
  21495. /**
  21496. * Indicates that attributes need to be re-calculated for all submeshes
  21497. */
  21498. protected _markAllSubMeshesAsAttributesDirty(): void;
  21499. /**
  21500. * Indicates that misc needs to be re-calculated for all submeshes
  21501. */
  21502. protected _markAllSubMeshesAsMiscDirty(): void;
  21503. /**
  21504. * Indicates that textures and misc need to be re-calculated for all submeshes
  21505. */
  21506. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21507. /**
  21508. * Disposes the material
  21509. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21510. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21511. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21512. */
  21513. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21514. /** @hidden */
  21515. private releaseVertexArrayObject;
  21516. /**
  21517. * Serializes this material
  21518. * @returns the serialized material object
  21519. */
  21520. serialize(): any;
  21521. /**
  21522. * Creates a material from parsed material data
  21523. * @param parsedMaterial defines parsed material data
  21524. * @param scene defines the hosting scene
  21525. * @param rootUrl defines the root URL to use to load textures
  21526. * @returns a new material
  21527. */
  21528. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21529. }
  21530. }
  21531. declare module BABYLON {
  21532. /**
  21533. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21534. * separate meshes. This can be use to improve performances.
  21535. * @see http://doc.babylonjs.com/how_to/multi_materials
  21536. */
  21537. export class MultiMaterial extends Material {
  21538. private _subMaterials;
  21539. /**
  21540. * Gets or Sets the list of Materials used within the multi material.
  21541. * They need to be ordered according to the submeshes order in the associated mesh
  21542. */
  21543. get subMaterials(): Nullable<Material>[];
  21544. set subMaterials(value: Nullable<Material>[]);
  21545. /**
  21546. * Function used to align with Node.getChildren()
  21547. * @returns the list of Materials used within the multi material
  21548. */
  21549. getChildren(): Nullable<Material>[];
  21550. /**
  21551. * Instantiates a new Multi Material
  21552. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21553. * separate meshes. This can be use to improve performances.
  21554. * @see http://doc.babylonjs.com/how_to/multi_materials
  21555. * @param name Define the name in the scene
  21556. * @param scene Define the scene the material belongs to
  21557. */
  21558. constructor(name: string, scene: Scene);
  21559. private _hookArray;
  21560. /**
  21561. * Get one of the submaterial by its index in the submaterials array
  21562. * @param index The index to look the sub material at
  21563. * @returns The Material if the index has been defined
  21564. */
  21565. getSubMaterial(index: number): Nullable<Material>;
  21566. /**
  21567. * Get the list of active textures for the whole sub materials list.
  21568. * @returns All the textures that will be used during the rendering
  21569. */
  21570. getActiveTextures(): BaseTexture[];
  21571. /**
  21572. * Gets the current class name of the material e.g. "MultiMaterial"
  21573. * Mainly use in serialization.
  21574. * @returns the class name
  21575. */
  21576. getClassName(): string;
  21577. /**
  21578. * Checks if the material is ready to render the requested sub mesh
  21579. * @param mesh Define the mesh the submesh belongs to
  21580. * @param subMesh Define the sub mesh to look readyness for
  21581. * @param useInstances Define whether or not the material is used with instances
  21582. * @returns true if ready, otherwise false
  21583. */
  21584. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21585. /**
  21586. * Clones the current material and its related sub materials
  21587. * @param name Define the name of the newly cloned material
  21588. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21589. * @returns the cloned material
  21590. */
  21591. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21592. /**
  21593. * Serializes the materials into a JSON representation.
  21594. * @returns the JSON representation
  21595. */
  21596. serialize(): any;
  21597. /**
  21598. * Dispose the material and release its associated resources
  21599. * @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)
  21600. * @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)
  21601. * @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)
  21602. */
  21603. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21604. /**
  21605. * Creates a MultiMaterial from parsed MultiMaterial data.
  21606. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21607. * @param scene defines the hosting scene
  21608. * @returns a new MultiMaterial
  21609. */
  21610. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21611. }
  21612. }
  21613. declare module BABYLON {
  21614. /**
  21615. * Base class for submeshes
  21616. */
  21617. export class BaseSubMesh {
  21618. /** @hidden */
  21619. _materialDefines: Nullable<MaterialDefines>;
  21620. /** @hidden */
  21621. _materialEffect: Nullable<Effect>;
  21622. /**
  21623. * Gets material defines used by the effect associated to the sub mesh
  21624. */
  21625. get materialDefines(): Nullable<MaterialDefines>;
  21626. /**
  21627. * Sets material defines used by the effect associated to the sub mesh
  21628. */
  21629. set materialDefines(defines: Nullable<MaterialDefines>);
  21630. /**
  21631. * Gets associated effect
  21632. */
  21633. get effect(): Nullable<Effect>;
  21634. /**
  21635. * Sets associated effect (effect used to render this submesh)
  21636. * @param effect defines the effect to associate with
  21637. * @param defines defines the set of defines used to compile this effect
  21638. */
  21639. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21640. }
  21641. /**
  21642. * Defines a subdivision inside a mesh
  21643. */
  21644. export class SubMesh extends BaseSubMesh implements ICullable {
  21645. /** the material index to use */
  21646. materialIndex: number;
  21647. /** vertex index start */
  21648. verticesStart: number;
  21649. /** vertices count */
  21650. verticesCount: number;
  21651. /** index start */
  21652. indexStart: number;
  21653. /** indices count */
  21654. indexCount: number;
  21655. /** @hidden */
  21656. _linesIndexCount: number;
  21657. private _mesh;
  21658. private _renderingMesh;
  21659. private _boundingInfo;
  21660. private _linesIndexBuffer;
  21661. /** @hidden */
  21662. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21663. /** @hidden */
  21664. _trianglePlanes: Plane[];
  21665. /** @hidden */
  21666. _lastColliderTransformMatrix: Nullable<Matrix>;
  21667. /** @hidden */
  21668. _renderId: number;
  21669. /** @hidden */
  21670. _alphaIndex: number;
  21671. /** @hidden */
  21672. _distanceToCamera: number;
  21673. /** @hidden */
  21674. _id: number;
  21675. private _currentMaterial;
  21676. /**
  21677. * Add a new submesh to a mesh
  21678. * @param materialIndex defines the material index to use
  21679. * @param verticesStart defines vertex index start
  21680. * @param verticesCount defines vertices count
  21681. * @param indexStart defines index start
  21682. * @param indexCount defines indices count
  21683. * @param mesh defines the parent mesh
  21684. * @param renderingMesh defines an optional rendering mesh
  21685. * @param createBoundingBox defines if bounding box should be created for this submesh
  21686. * @returns the new submesh
  21687. */
  21688. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21689. /**
  21690. * Creates a new submesh
  21691. * @param materialIndex defines the material index to use
  21692. * @param verticesStart defines vertex index start
  21693. * @param verticesCount defines vertices count
  21694. * @param indexStart defines index start
  21695. * @param indexCount defines indices count
  21696. * @param mesh defines the parent mesh
  21697. * @param renderingMesh defines an optional rendering mesh
  21698. * @param createBoundingBox defines if bounding box should be created for this submesh
  21699. */
  21700. constructor(
  21701. /** the material index to use */
  21702. materialIndex: number,
  21703. /** vertex index start */
  21704. verticesStart: number,
  21705. /** vertices count */
  21706. verticesCount: number,
  21707. /** index start */
  21708. indexStart: number,
  21709. /** indices count */
  21710. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21711. /**
  21712. * Returns true if this submesh covers the entire parent mesh
  21713. * @ignorenaming
  21714. */
  21715. get IsGlobal(): boolean;
  21716. /**
  21717. * Returns the submesh BoudingInfo object
  21718. * @returns current bounding info (or mesh's one if the submesh is global)
  21719. */
  21720. getBoundingInfo(): BoundingInfo;
  21721. /**
  21722. * Sets the submesh BoundingInfo
  21723. * @param boundingInfo defines the new bounding info to use
  21724. * @returns the SubMesh
  21725. */
  21726. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21727. /**
  21728. * Returns the mesh of the current submesh
  21729. * @return the parent mesh
  21730. */
  21731. getMesh(): AbstractMesh;
  21732. /**
  21733. * Returns the rendering mesh of the submesh
  21734. * @returns the rendering mesh (could be different from parent mesh)
  21735. */
  21736. getRenderingMesh(): Mesh;
  21737. /**
  21738. * Returns the submesh material
  21739. * @returns null or the current material
  21740. */
  21741. getMaterial(): Nullable<Material>;
  21742. /**
  21743. * Sets a new updated BoundingInfo object to the submesh
  21744. * @param data defines an optional position array to use to determine the bounding info
  21745. * @returns the SubMesh
  21746. */
  21747. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21748. /** @hidden */
  21749. _checkCollision(collider: Collider): boolean;
  21750. /**
  21751. * Updates the submesh BoundingInfo
  21752. * @param world defines the world matrix to use to update the bounding info
  21753. * @returns the submesh
  21754. */
  21755. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21756. /**
  21757. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21758. * @param frustumPlanes defines the frustum planes
  21759. * @returns true if the submesh is intersecting with the frustum
  21760. */
  21761. isInFrustum(frustumPlanes: Plane[]): boolean;
  21762. /**
  21763. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21764. * @param frustumPlanes defines the frustum planes
  21765. * @returns true if the submesh is inside the frustum
  21766. */
  21767. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21768. /**
  21769. * Renders the submesh
  21770. * @param enableAlphaMode defines if alpha needs to be used
  21771. * @returns the submesh
  21772. */
  21773. render(enableAlphaMode: boolean): SubMesh;
  21774. /**
  21775. * @hidden
  21776. */
  21777. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21778. /**
  21779. * Checks if the submesh intersects with a ray
  21780. * @param ray defines the ray to test
  21781. * @returns true is the passed ray intersects the submesh bounding box
  21782. */
  21783. canIntersects(ray: Ray): boolean;
  21784. /**
  21785. * Intersects current submesh with a ray
  21786. * @param ray defines the ray to test
  21787. * @param positions defines mesh's positions array
  21788. * @param indices defines mesh's indices array
  21789. * @param fastCheck defines if only bounding info should be used
  21790. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21791. * @returns intersection info or null if no intersection
  21792. */
  21793. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21794. /** @hidden */
  21795. private _intersectLines;
  21796. /** @hidden */
  21797. private _intersectUnIndexedLines;
  21798. /** @hidden */
  21799. private _intersectTriangles;
  21800. /** @hidden */
  21801. private _intersectUnIndexedTriangles;
  21802. /** @hidden */
  21803. _rebuild(): void;
  21804. /**
  21805. * Creates a new submesh from the passed mesh
  21806. * @param newMesh defines the new hosting mesh
  21807. * @param newRenderingMesh defines an optional rendering mesh
  21808. * @returns the new submesh
  21809. */
  21810. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21811. /**
  21812. * Release associated resources
  21813. */
  21814. dispose(): void;
  21815. /**
  21816. * Gets the class name
  21817. * @returns the string "SubMesh".
  21818. */
  21819. getClassName(): string;
  21820. /**
  21821. * Creates a new submesh from indices data
  21822. * @param materialIndex the index of the main mesh material
  21823. * @param startIndex the index where to start the copy in the mesh indices array
  21824. * @param indexCount the number of indices to copy then from the startIndex
  21825. * @param mesh the main mesh to create the submesh from
  21826. * @param renderingMesh the optional rendering mesh
  21827. * @returns a new submesh
  21828. */
  21829. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21830. }
  21831. }
  21832. declare module BABYLON {
  21833. /**
  21834. * Class used to represent data loading progression
  21835. */
  21836. export class SceneLoaderFlags {
  21837. private static _ForceFullSceneLoadingForIncremental;
  21838. private static _ShowLoadingScreen;
  21839. private static _CleanBoneMatrixWeights;
  21840. private static _loggingLevel;
  21841. /**
  21842. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21843. */
  21844. static get ForceFullSceneLoadingForIncremental(): boolean;
  21845. static set ForceFullSceneLoadingForIncremental(value: boolean);
  21846. /**
  21847. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21848. */
  21849. static get ShowLoadingScreen(): boolean;
  21850. static set ShowLoadingScreen(value: boolean);
  21851. /**
  21852. * Defines the current logging level (while loading the scene)
  21853. * @ignorenaming
  21854. */
  21855. static get loggingLevel(): number;
  21856. static set loggingLevel(value: number);
  21857. /**
  21858. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21859. */
  21860. static get CleanBoneMatrixWeights(): boolean;
  21861. static set CleanBoneMatrixWeights(value: boolean);
  21862. }
  21863. }
  21864. declare module BABYLON {
  21865. /**
  21866. * Class used to store geometry data (vertex buffers + index buffer)
  21867. */
  21868. export class Geometry implements IGetSetVerticesData {
  21869. /**
  21870. * Gets or sets the ID of the geometry
  21871. */
  21872. id: string;
  21873. /**
  21874. * Gets or sets the unique ID of the geometry
  21875. */
  21876. uniqueId: number;
  21877. /**
  21878. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21879. */
  21880. delayLoadState: number;
  21881. /**
  21882. * Gets the file containing the data to load when running in delay load state
  21883. */
  21884. delayLoadingFile: Nullable<string>;
  21885. /**
  21886. * Callback called when the geometry is updated
  21887. */
  21888. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21889. private _scene;
  21890. private _engine;
  21891. private _meshes;
  21892. private _totalVertices;
  21893. /** @hidden */
  21894. _indices: IndicesArray;
  21895. /** @hidden */
  21896. _vertexBuffers: {
  21897. [key: string]: VertexBuffer;
  21898. };
  21899. private _isDisposed;
  21900. private _extend;
  21901. private _boundingBias;
  21902. /** @hidden */
  21903. _delayInfo: Array<string>;
  21904. private _indexBuffer;
  21905. private _indexBufferIsUpdatable;
  21906. /** @hidden */
  21907. _boundingInfo: Nullable<BoundingInfo>;
  21908. /** @hidden */
  21909. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21910. /** @hidden */
  21911. _softwareSkinningFrameId: number;
  21912. private _vertexArrayObjects;
  21913. private _updatable;
  21914. /** @hidden */
  21915. _positions: Nullable<Vector3[]>;
  21916. /**
  21917. * 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
  21918. */
  21919. get boundingBias(): Vector2;
  21920. /**
  21921. * 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
  21922. */
  21923. set boundingBias(value: Vector2);
  21924. /**
  21925. * Static function used to attach a new empty geometry to a mesh
  21926. * @param mesh defines the mesh to attach the geometry to
  21927. * @returns the new Geometry
  21928. */
  21929. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21930. /**
  21931. * Creates a new geometry
  21932. * @param id defines the unique ID
  21933. * @param scene defines the hosting scene
  21934. * @param vertexData defines the VertexData used to get geometry data
  21935. * @param updatable defines if geometry must be updatable (false by default)
  21936. * @param mesh defines the mesh that will be associated with the geometry
  21937. */
  21938. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21939. /**
  21940. * Gets the current extend of the geometry
  21941. */
  21942. get extend(): {
  21943. minimum: Vector3;
  21944. maximum: Vector3;
  21945. };
  21946. /**
  21947. * Gets the hosting scene
  21948. * @returns the hosting Scene
  21949. */
  21950. getScene(): Scene;
  21951. /**
  21952. * Gets the hosting engine
  21953. * @returns the hosting Engine
  21954. */
  21955. getEngine(): Engine;
  21956. /**
  21957. * Defines if the geometry is ready to use
  21958. * @returns true if the geometry is ready to be used
  21959. */
  21960. isReady(): boolean;
  21961. /**
  21962. * Gets a value indicating that the geometry should not be serialized
  21963. */
  21964. get doNotSerialize(): boolean;
  21965. /** @hidden */
  21966. _rebuild(): void;
  21967. /**
  21968. * Affects all geometry data in one call
  21969. * @param vertexData defines the geometry data
  21970. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21971. */
  21972. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21973. /**
  21974. * Set specific vertex data
  21975. * @param kind defines the data kind (Position, normal, etc...)
  21976. * @param data defines the vertex data to use
  21977. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21978. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21979. */
  21980. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21981. /**
  21982. * Removes a specific vertex data
  21983. * @param kind defines the data kind (Position, normal, etc...)
  21984. */
  21985. removeVerticesData(kind: string): void;
  21986. /**
  21987. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21988. * @param buffer defines the vertex buffer to use
  21989. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21990. */
  21991. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21992. /**
  21993. * Update a specific vertex buffer
  21994. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21995. * It will do nothing if the buffer is not updatable
  21996. * @param kind defines the data kind (Position, normal, etc...)
  21997. * @param data defines the data to use
  21998. * @param offset defines the offset in the target buffer where to store the data
  21999. * @param useBytes set to true if the offset is in bytes
  22000. */
  22001. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22002. /**
  22003. * Update a specific vertex buffer
  22004. * This function will create a new buffer if the current one is not updatable
  22005. * @param kind defines the data kind (Position, normal, etc...)
  22006. * @param data defines the data to use
  22007. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22008. */
  22009. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22010. private _updateBoundingInfo;
  22011. /** @hidden */
  22012. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22013. /**
  22014. * Gets total number of vertices
  22015. * @returns the total number of vertices
  22016. */
  22017. getTotalVertices(): number;
  22018. /**
  22019. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22020. * @param kind defines the data kind (Position, normal, etc...)
  22021. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22022. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22023. * @returns a float array containing vertex data
  22024. */
  22025. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22026. /**
  22027. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22028. * @param kind defines the data kind (Position, normal, etc...)
  22029. * @returns true if the vertex buffer with the specified kind is updatable
  22030. */
  22031. isVertexBufferUpdatable(kind: string): boolean;
  22032. /**
  22033. * Gets a specific vertex buffer
  22034. * @param kind defines the data kind (Position, normal, etc...)
  22035. * @returns a VertexBuffer
  22036. */
  22037. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22038. /**
  22039. * Returns all vertex buffers
  22040. * @return an object holding all vertex buffers indexed by kind
  22041. */
  22042. getVertexBuffers(): Nullable<{
  22043. [key: string]: VertexBuffer;
  22044. }>;
  22045. /**
  22046. * Gets a boolean indicating if specific vertex buffer is present
  22047. * @param kind defines the data kind (Position, normal, etc...)
  22048. * @returns true if data is present
  22049. */
  22050. isVerticesDataPresent(kind: string): boolean;
  22051. /**
  22052. * Gets a list of all attached data kinds (Position, normal, etc...)
  22053. * @returns a list of string containing all kinds
  22054. */
  22055. getVerticesDataKinds(): string[];
  22056. /**
  22057. * Update index buffer
  22058. * @param indices defines the indices to store in the index buffer
  22059. * @param offset defines the offset in the target buffer where to store the data
  22060. * @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)
  22061. */
  22062. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22063. /**
  22064. * Creates a new index buffer
  22065. * @param indices defines the indices to store in the index buffer
  22066. * @param totalVertices defines the total number of vertices (could be null)
  22067. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22068. */
  22069. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22070. /**
  22071. * Return the total number of indices
  22072. * @returns the total number of indices
  22073. */
  22074. getTotalIndices(): number;
  22075. /**
  22076. * Gets the index buffer array
  22077. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22078. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22079. * @returns the index buffer array
  22080. */
  22081. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22082. /**
  22083. * Gets the index buffer
  22084. * @return the index buffer
  22085. */
  22086. getIndexBuffer(): Nullable<DataBuffer>;
  22087. /** @hidden */
  22088. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22089. /**
  22090. * Release the associated resources for a specific mesh
  22091. * @param mesh defines the source mesh
  22092. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22093. */
  22094. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22095. /**
  22096. * Apply current geometry to a given mesh
  22097. * @param mesh defines the mesh to apply geometry to
  22098. */
  22099. applyToMesh(mesh: Mesh): void;
  22100. private _updateExtend;
  22101. private _applyToMesh;
  22102. private notifyUpdate;
  22103. /**
  22104. * Load the geometry if it was flagged as delay loaded
  22105. * @param scene defines the hosting scene
  22106. * @param onLoaded defines a callback called when the geometry is loaded
  22107. */
  22108. load(scene: Scene, onLoaded?: () => void): void;
  22109. private _queueLoad;
  22110. /**
  22111. * Invert the geometry to move from a right handed system to a left handed one.
  22112. */
  22113. toLeftHanded(): void;
  22114. /** @hidden */
  22115. _resetPointsArrayCache(): void;
  22116. /** @hidden */
  22117. _generatePointsArray(): boolean;
  22118. /**
  22119. * Gets a value indicating if the geometry is disposed
  22120. * @returns true if the geometry was disposed
  22121. */
  22122. isDisposed(): boolean;
  22123. private _disposeVertexArrayObjects;
  22124. /**
  22125. * Free all associated resources
  22126. */
  22127. dispose(): void;
  22128. /**
  22129. * Clone the current geometry into a new geometry
  22130. * @param id defines the unique ID of the new geometry
  22131. * @returns a new geometry object
  22132. */
  22133. copy(id: string): Geometry;
  22134. /**
  22135. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22136. * @return a JSON representation of the current geometry data (without the vertices data)
  22137. */
  22138. serialize(): any;
  22139. private toNumberArray;
  22140. /**
  22141. * Serialize all vertices data into a JSON oject
  22142. * @returns a JSON representation of the current geometry data
  22143. */
  22144. serializeVerticeData(): any;
  22145. /**
  22146. * Extracts a clone of a mesh geometry
  22147. * @param mesh defines the source mesh
  22148. * @param id defines the unique ID of the new geometry object
  22149. * @returns the new geometry object
  22150. */
  22151. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22152. /**
  22153. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22154. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22155. * Be aware Math.random() could cause collisions, but:
  22156. * "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"
  22157. * @returns a string containing a new GUID
  22158. */
  22159. static RandomId(): string;
  22160. /** @hidden */
  22161. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22162. private static _CleanMatricesWeights;
  22163. /**
  22164. * Create a new geometry from persisted data (Using .babylon file format)
  22165. * @param parsedVertexData defines the persisted data
  22166. * @param scene defines the hosting scene
  22167. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22168. * @returns the new geometry object
  22169. */
  22170. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22171. }
  22172. }
  22173. declare module BABYLON {
  22174. /**
  22175. * Define an interface for all classes that will get and set the data on vertices
  22176. */
  22177. export interface IGetSetVerticesData {
  22178. /**
  22179. * Gets a boolean indicating if specific vertex data is present
  22180. * @param kind defines the vertex data kind to use
  22181. * @returns true is data kind is present
  22182. */
  22183. isVerticesDataPresent(kind: string): boolean;
  22184. /**
  22185. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22186. * @param kind defines the data kind (Position, normal, etc...)
  22187. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22188. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22189. * @returns a float array containing vertex data
  22190. */
  22191. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22192. /**
  22193. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22194. * @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.
  22195. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22196. * @returns the indices array or an empty array if the mesh has no geometry
  22197. */
  22198. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22199. /**
  22200. * Set specific vertex data
  22201. * @param kind defines the data kind (Position, normal, etc...)
  22202. * @param data defines the vertex data to use
  22203. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22204. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22205. */
  22206. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22207. /**
  22208. * Update a specific associated vertex buffer
  22209. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22210. * - VertexBuffer.PositionKind
  22211. * - VertexBuffer.UVKind
  22212. * - VertexBuffer.UV2Kind
  22213. * - VertexBuffer.UV3Kind
  22214. * - VertexBuffer.UV4Kind
  22215. * - VertexBuffer.UV5Kind
  22216. * - VertexBuffer.UV6Kind
  22217. * - VertexBuffer.ColorKind
  22218. * - VertexBuffer.MatricesIndicesKind
  22219. * - VertexBuffer.MatricesIndicesExtraKind
  22220. * - VertexBuffer.MatricesWeightsKind
  22221. * - VertexBuffer.MatricesWeightsExtraKind
  22222. * @param data defines the data source
  22223. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22224. * @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)
  22225. */
  22226. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22227. /**
  22228. * Creates a new index buffer
  22229. * @param indices defines the indices to store in the index buffer
  22230. * @param totalVertices defines the total number of vertices (could be null)
  22231. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22232. */
  22233. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22234. }
  22235. /**
  22236. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22237. */
  22238. export class VertexData {
  22239. /**
  22240. * Mesh side orientation : usually the external or front surface
  22241. */
  22242. static readonly FRONTSIDE: number;
  22243. /**
  22244. * Mesh side orientation : usually the internal or back surface
  22245. */
  22246. static readonly BACKSIDE: number;
  22247. /**
  22248. * Mesh side orientation : both internal and external or front and back surfaces
  22249. */
  22250. static readonly DOUBLESIDE: number;
  22251. /**
  22252. * Mesh side orientation : by default, `FRONTSIDE`
  22253. */
  22254. static readonly DEFAULTSIDE: number;
  22255. /**
  22256. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22257. */
  22258. positions: Nullable<FloatArray>;
  22259. /**
  22260. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22261. */
  22262. normals: Nullable<FloatArray>;
  22263. /**
  22264. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22265. */
  22266. tangents: Nullable<FloatArray>;
  22267. /**
  22268. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22269. */
  22270. uvs: Nullable<FloatArray>;
  22271. /**
  22272. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22273. */
  22274. uvs2: Nullable<FloatArray>;
  22275. /**
  22276. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22277. */
  22278. uvs3: Nullable<FloatArray>;
  22279. /**
  22280. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22281. */
  22282. uvs4: Nullable<FloatArray>;
  22283. /**
  22284. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22285. */
  22286. uvs5: Nullable<FloatArray>;
  22287. /**
  22288. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22289. */
  22290. uvs6: Nullable<FloatArray>;
  22291. /**
  22292. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22293. */
  22294. colors: Nullable<FloatArray>;
  22295. /**
  22296. * 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).
  22297. */
  22298. matricesIndices: Nullable<FloatArray>;
  22299. /**
  22300. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22301. */
  22302. matricesWeights: Nullable<FloatArray>;
  22303. /**
  22304. * An array extending the number of possible indices
  22305. */
  22306. matricesIndicesExtra: Nullable<FloatArray>;
  22307. /**
  22308. * An array extending the number of possible weights when the number of indices is extended
  22309. */
  22310. matricesWeightsExtra: Nullable<FloatArray>;
  22311. /**
  22312. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22313. */
  22314. indices: Nullable<IndicesArray>;
  22315. /**
  22316. * Uses the passed data array to set the set the values for the specified kind of data
  22317. * @param data a linear array of floating numbers
  22318. * @param kind the type of data that is being set, eg positions, colors etc
  22319. */
  22320. set(data: FloatArray, kind: string): void;
  22321. /**
  22322. * Associates the vertexData to the passed Mesh.
  22323. * Sets it as updatable or not (default `false`)
  22324. * @param mesh the mesh the vertexData is applied to
  22325. * @param updatable when used and having the value true allows new data to update the vertexData
  22326. * @returns the VertexData
  22327. */
  22328. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22329. /**
  22330. * Associates the vertexData to the passed Geometry.
  22331. * Sets it as updatable or not (default `false`)
  22332. * @param geometry the geometry the vertexData is applied to
  22333. * @param updatable when used and having the value true allows new data to update the vertexData
  22334. * @returns VertexData
  22335. */
  22336. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22337. /**
  22338. * Updates the associated mesh
  22339. * @param mesh the mesh to be updated
  22340. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22341. * @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
  22342. * @returns VertexData
  22343. */
  22344. updateMesh(mesh: Mesh): VertexData;
  22345. /**
  22346. * Updates the associated geometry
  22347. * @param geometry the geometry to be updated
  22348. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22349. * @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
  22350. * @returns VertexData.
  22351. */
  22352. updateGeometry(geometry: Geometry): VertexData;
  22353. private _applyTo;
  22354. private _update;
  22355. /**
  22356. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22357. * @param matrix the transforming matrix
  22358. * @returns the VertexData
  22359. */
  22360. transform(matrix: Matrix): VertexData;
  22361. /**
  22362. * Merges the passed VertexData into the current one
  22363. * @param other the VertexData to be merged into the current one
  22364. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22365. * @returns the modified VertexData
  22366. */
  22367. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22368. private _mergeElement;
  22369. private _validate;
  22370. /**
  22371. * Serializes the VertexData
  22372. * @returns a serialized object
  22373. */
  22374. serialize(): any;
  22375. /**
  22376. * Extracts the vertexData from a mesh
  22377. * @param mesh the mesh from which to extract the VertexData
  22378. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22379. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22380. * @returns the object VertexData associated to the passed mesh
  22381. */
  22382. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22383. /**
  22384. * Extracts the vertexData from the geometry
  22385. * @param geometry the geometry from which to extract the VertexData
  22386. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22387. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22388. * @returns the object VertexData associated to the passed mesh
  22389. */
  22390. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22391. private static _ExtractFrom;
  22392. /**
  22393. * Creates the VertexData for a Ribbon
  22394. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22395. * * pathArray array of paths, each of which an array of successive Vector3
  22396. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22397. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22398. * * 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
  22399. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22400. * * 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)
  22401. * * 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)
  22402. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22403. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22404. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22405. * @returns the VertexData of the ribbon
  22406. */
  22407. static CreateRibbon(options: {
  22408. pathArray: Vector3[][];
  22409. closeArray?: boolean;
  22410. closePath?: boolean;
  22411. offset?: number;
  22412. sideOrientation?: number;
  22413. frontUVs?: Vector4;
  22414. backUVs?: Vector4;
  22415. invertUV?: boolean;
  22416. uvs?: Vector2[];
  22417. colors?: Color4[];
  22418. }): VertexData;
  22419. /**
  22420. * Creates the VertexData for a box
  22421. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22422. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22423. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22424. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22425. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22426. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22427. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22428. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22429. * * 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)
  22430. * * 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)
  22431. * @returns the VertexData of the box
  22432. */
  22433. static CreateBox(options: {
  22434. size?: number;
  22435. width?: number;
  22436. height?: number;
  22437. depth?: number;
  22438. faceUV?: Vector4[];
  22439. faceColors?: Color4[];
  22440. sideOrientation?: number;
  22441. frontUVs?: Vector4;
  22442. backUVs?: Vector4;
  22443. }): VertexData;
  22444. /**
  22445. * Creates the VertexData for a tiled box
  22446. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22447. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22448. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22449. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22450. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22451. * @returns the VertexData of the box
  22452. */
  22453. static CreateTiledBox(options: {
  22454. pattern?: number;
  22455. width?: number;
  22456. height?: number;
  22457. depth?: number;
  22458. tileSize?: number;
  22459. tileWidth?: number;
  22460. tileHeight?: number;
  22461. alignHorizontal?: number;
  22462. alignVertical?: number;
  22463. faceUV?: Vector4[];
  22464. faceColors?: Color4[];
  22465. sideOrientation?: number;
  22466. }): VertexData;
  22467. /**
  22468. * Creates the VertexData for a tiled plane
  22469. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22470. * * pattern a limited pattern arrangement depending on the number
  22471. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22472. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22473. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22474. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22475. * * 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)
  22476. * * 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)
  22477. * @returns the VertexData of the tiled plane
  22478. */
  22479. static CreateTiledPlane(options: {
  22480. pattern?: number;
  22481. tileSize?: number;
  22482. tileWidth?: number;
  22483. tileHeight?: number;
  22484. size?: number;
  22485. width?: number;
  22486. height?: number;
  22487. alignHorizontal?: number;
  22488. alignVertical?: number;
  22489. sideOrientation?: number;
  22490. frontUVs?: Vector4;
  22491. backUVs?: Vector4;
  22492. }): VertexData;
  22493. /**
  22494. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22495. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22496. * * segments sets the number of horizontal strips optional, default 32
  22497. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22498. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22499. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22500. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22501. * * 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
  22502. * * 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
  22503. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22504. * * 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)
  22505. * * 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)
  22506. * @returns the VertexData of the ellipsoid
  22507. */
  22508. static CreateSphere(options: {
  22509. segments?: number;
  22510. diameter?: number;
  22511. diameterX?: number;
  22512. diameterY?: number;
  22513. diameterZ?: number;
  22514. arc?: number;
  22515. slice?: number;
  22516. sideOrientation?: number;
  22517. frontUVs?: Vector4;
  22518. backUVs?: Vector4;
  22519. }): VertexData;
  22520. /**
  22521. * Creates the VertexData for a cylinder, cone or prism
  22522. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22523. * * height sets the height (y direction) of the cylinder, optional, default 2
  22524. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22525. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22526. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22527. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22528. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22529. * * 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
  22530. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22531. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22532. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22533. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22534. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22535. * * 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)
  22536. * * 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)
  22537. * @returns the VertexData of the cylinder, cone or prism
  22538. */
  22539. static CreateCylinder(options: {
  22540. height?: number;
  22541. diameterTop?: number;
  22542. diameterBottom?: number;
  22543. diameter?: number;
  22544. tessellation?: number;
  22545. subdivisions?: number;
  22546. arc?: number;
  22547. faceColors?: Color4[];
  22548. faceUV?: Vector4[];
  22549. hasRings?: boolean;
  22550. enclose?: boolean;
  22551. sideOrientation?: number;
  22552. frontUVs?: Vector4;
  22553. backUVs?: Vector4;
  22554. }): VertexData;
  22555. /**
  22556. * Creates the VertexData for a torus
  22557. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22558. * * diameter the diameter of the torus, optional default 1
  22559. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22560. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22561. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22562. * * 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)
  22563. * * 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)
  22564. * @returns the VertexData of the torus
  22565. */
  22566. static CreateTorus(options: {
  22567. diameter?: number;
  22568. thickness?: number;
  22569. tessellation?: number;
  22570. sideOrientation?: number;
  22571. frontUVs?: Vector4;
  22572. backUVs?: Vector4;
  22573. }): VertexData;
  22574. /**
  22575. * Creates the VertexData of the LineSystem
  22576. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22577. * - lines an array of lines, each line being an array of successive Vector3
  22578. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22579. * @returns the VertexData of the LineSystem
  22580. */
  22581. static CreateLineSystem(options: {
  22582. lines: Vector3[][];
  22583. colors?: Nullable<Color4[][]>;
  22584. }): VertexData;
  22585. /**
  22586. * Create the VertexData for a DashedLines
  22587. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22588. * - points an array successive Vector3
  22589. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22590. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22591. * - dashNb the intended total number of dashes, optional, default 200
  22592. * @returns the VertexData for the DashedLines
  22593. */
  22594. static CreateDashedLines(options: {
  22595. points: Vector3[];
  22596. dashSize?: number;
  22597. gapSize?: number;
  22598. dashNb?: number;
  22599. }): VertexData;
  22600. /**
  22601. * Creates the VertexData for a Ground
  22602. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22603. * - width the width (x direction) of the ground, optional, default 1
  22604. * - height the height (z direction) of the ground, optional, default 1
  22605. * - subdivisions the number of subdivisions per side, optional, default 1
  22606. * @returns the VertexData of the Ground
  22607. */
  22608. static CreateGround(options: {
  22609. width?: number;
  22610. height?: number;
  22611. subdivisions?: number;
  22612. subdivisionsX?: number;
  22613. subdivisionsY?: number;
  22614. }): VertexData;
  22615. /**
  22616. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22617. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22618. * * xmin the ground minimum X coordinate, optional, default -1
  22619. * * zmin the ground minimum Z coordinate, optional, default -1
  22620. * * xmax the ground maximum X coordinate, optional, default 1
  22621. * * zmax the ground maximum Z coordinate, optional, default 1
  22622. * * 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}
  22623. * * 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}
  22624. * @returns the VertexData of the TiledGround
  22625. */
  22626. static CreateTiledGround(options: {
  22627. xmin: number;
  22628. zmin: number;
  22629. xmax: number;
  22630. zmax: number;
  22631. subdivisions?: {
  22632. w: number;
  22633. h: number;
  22634. };
  22635. precision?: {
  22636. w: number;
  22637. h: number;
  22638. };
  22639. }): VertexData;
  22640. /**
  22641. * Creates the VertexData of the Ground designed from a heightmap
  22642. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22643. * * width the width (x direction) of the ground
  22644. * * height the height (z direction) of the ground
  22645. * * subdivisions the number of subdivisions per side
  22646. * * minHeight the minimum altitude on the ground, optional, default 0
  22647. * * maxHeight the maximum altitude on the ground, optional default 1
  22648. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22649. * * buffer the array holding the image color data
  22650. * * bufferWidth the width of image
  22651. * * bufferHeight the height of image
  22652. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22653. * @returns the VertexData of the Ground designed from a heightmap
  22654. */
  22655. static CreateGroundFromHeightMap(options: {
  22656. width: number;
  22657. height: number;
  22658. subdivisions: number;
  22659. minHeight: number;
  22660. maxHeight: number;
  22661. colorFilter: Color3;
  22662. buffer: Uint8Array;
  22663. bufferWidth: number;
  22664. bufferHeight: number;
  22665. alphaFilter: number;
  22666. }): VertexData;
  22667. /**
  22668. * Creates the VertexData for a Plane
  22669. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22670. * * size sets the width and height of the plane to the value of size, optional default 1
  22671. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22672. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22673. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22674. * * 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)
  22675. * * 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)
  22676. * @returns the VertexData of the box
  22677. */
  22678. static CreatePlane(options: {
  22679. size?: number;
  22680. width?: number;
  22681. height?: number;
  22682. sideOrientation?: number;
  22683. frontUVs?: Vector4;
  22684. backUVs?: Vector4;
  22685. }): VertexData;
  22686. /**
  22687. * Creates the VertexData of the Disc or regular Polygon
  22688. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22689. * * radius the radius of the disc, optional default 0.5
  22690. * * tessellation the number of polygon sides, optional, default 64
  22691. * * 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
  22692. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22693. * * 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)
  22694. * * 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)
  22695. * @returns the VertexData of the box
  22696. */
  22697. static CreateDisc(options: {
  22698. radius?: number;
  22699. tessellation?: number;
  22700. arc?: number;
  22701. sideOrientation?: number;
  22702. frontUVs?: Vector4;
  22703. backUVs?: Vector4;
  22704. }): VertexData;
  22705. /**
  22706. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22707. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22708. * @param polygon a mesh built from polygonTriangulation.build()
  22709. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22710. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22711. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22712. * @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)
  22713. * @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)
  22714. * @returns the VertexData of the Polygon
  22715. */
  22716. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22717. /**
  22718. * Creates the VertexData of the IcoSphere
  22719. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22720. * * radius the radius of the IcoSphere, optional default 1
  22721. * * radiusX allows stretching in the x direction, optional, default radius
  22722. * * radiusY allows stretching in the y direction, optional, default radius
  22723. * * radiusZ allows stretching in the z direction, optional, default radius
  22724. * * flat when true creates a flat shaded mesh, optional, default true
  22725. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22726. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22727. * * 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)
  22728. * * 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)
  22729. * @returns the VertexData of the IcoSphere
  22730. */
  22731. static CreateIcoSphere(options: {
  22732. radius?: number;
  22733. radiusX?: number;
  22734. radiusY?: number;
  22735. radiusZ?: number;
  22736. flat?: boolean;
  22737. subdivisions?: number;
  22738. sideOrientation?: number;
  22739. frontUVs?: Vector4;
  22740. backUVs?: Vector4;
  22741. }): VertexData;
  22742. /**
  22743. * Creates the VertexData for a Polyhedron
  22744. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22745. * * type provided types are:
  22746. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22747. * * 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)
  22748. * * size the size of the IcoSphere, optional default 1
  22749. * * sizeX allows stretching in the x direction, optional, default size
  22750. * * sizeY allows stretching in the y direction, optional, default size
  22751. * * sizeZ allows stretching in the z direction, optional, default size
  22752. * * 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
  22753. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22754. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22755. * * flat when true creates a flat shaded mesh, optional, default true
  22756. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22757. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22758. * * 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)
  22759. * * 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)
  22760. * @returns the VertexData of the Polyhedron
  22761. */
  22762. static CreatePolyhedron(options: {
  22763. type?: number;
  22764. size?: number;
  22765. sizeX?: number;
  22766. sizeY?: number;
  22767. sizeZ?: number;
  22768. custom?: any;
  22769. faceUV?: Vector4[];
  22770. faceColors?: Color4[];
  22771. flat?: boolean;
  22772. sideOrientation?: number;
  22773. frontUVs?: Vector4;
  22774. backUVs?: Vector4;
  22775. }): VertexData;
  22776. /**
  22777. * Creates the VertexData for a TorusKnot
  22778. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22779. * * radius the radius of the torus knot, optional, default 2
  22780. * * tube the thickness of the tube, optional, default 0.5
  22781. * * radialSegments the number of sides on each tube segments, optional, default 32
  22782. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22783. * * p the number of windings around the z axis, optional, default 2
  22784. * * q the number of windings around the x axis, optional, default 3
  22785. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22786. * * 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)
  22787. * * 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)
  22788. * @returns the VertexData of the Torus Knot
  22789. */
  22790. static CreateTorusKnot(options: {
  22791. radius?: number;
  22792. tube?: number;
  22793. radialSegments?: number;
  22794. tubularSegments?: number;
  22795. p?: number;
  22796. q?: number;
  22797. sideOrientation?: number;
  22798. frontUVs?: Vector4;
  22799. backUVs?: Vector4;
  22800. }): VertexData;
  22801. /**
  22802. * Compute normals for given positions and indices
  22803. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22804. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22805. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22806. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22807. * * facetNormals : optional array of facet normals (vector3)
  22808. * * facetPositions : optional array of facet positions (vector3)
  22809. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22810. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22811. * * bInfo : optional bounding info, required for facetPartitioning computation
  22812. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22813. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22814. * * useRightHandedSystem: optional boolean to for right handed system computation
  22815. * * depthSort : optional boolean to enable the facet depth sort computation
  22816. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22817. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22818. */
  22819. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22820. facetNormals?: any;
  22821. facetPositions?: any;
  22822. facetPartitioning?: any;
  22823. ratio?: number;
  22824. bInfo?: any;
  22825. bbSize?: Vector3;
  22826. subDiv?: any;
  22827. useRightHandedSystem?: boolean;
  22828. depthSort?: boolean;
  22829. distanceTo?: Vector3;
  22830. depthSortedFacets?: any;
  22831. }): void;
  22832. /** @hidden */
  22833. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22834. /**
  22835. * Applies VertexData created from the imported parameters to the geometry
  22836. * @param parsedVertexData the parsed data from an imported file
  22837. * @param geometry the geometry to apply the VertexData to
  22838. */
  22839. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22840. }
  22841. }
  22842. declare module BABYLON {
  22843. /**
  22844. * Defines a target to use with MorphTargetManager
  22845. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22846. */
  22847. export class MorphTarget implements IAnimatable {
  22848. /** defines the name of the target */
  22849. name: string;
  22850. /**
  22851. * Gets or sets the list of animations
  22852. */
  22853. animations: Animation[];
  22854. private _scene;
  22855. private _positions;
  22856. private _normals;
  22857. private _tangents;
  22858. private _uvs;
  22859. private _influence;
  22860. private _uniqueId;
  22861. /**
  22862. * Observable raised when the influence changes
  22863. */
  22864. onInfluenceChanged: Observable<boolean>;
  22865. /** @hidden */
  22866. _onDataLayoutChanged: Observable<void>;
  22867. /**
  22868. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22869. */
  22870. get influence(): number;
  22871. set influence(influence: number);
  22872. /**
  22873. * Gets or sets the id of the morph Target
  22874. */
  22875. id: string;
  22876. private _animationPropertiesOverride;
  22877. /**
  22878. * Gets or sets the animation properties override
  22879. */
  22880. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  22881. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  22882. /**
  22883. * Creates a new MorphTarget
  22884. * @param name defines the name of the target
  22885. * @param influence defines the influence to use
  22886. * @param scene defines the scene the morphtarget belongs to
  22887. */
  22888. constructor(
  22889. /** defines the name of the target */
  22890. name: string, influence?: number, scene?: Nullable<Scene>);
  22891. /**
  22892. * Gets the unique ID of this manager
  22893. */
  22894. get uniqueId(): number;
  22895. /**
  22896. * Gets a boolean defining if the target contains position data
  22897. */
  22898. get hasPositions(): boolean;
  22899. /**
  22900. * Gets a boolean defining if the target contains normal data
  22901. */
  22902. get hasNormals(): boolean;
  22903. /**
  22904. * Gets a boolean defining if the target contains tangent data
  22905. */
  22906. get hasTangents(): boolean;
  22907. /**
  22908. * Gets a boolean defining if the target contains texture coordinates data
  22909. */
  22910. get hasUVs(): boolean;
  22911. /**
  22912. * Affects position data to this target
  22913. * @param data defines the position data to use
  22914. */
  22915. setPositions(data: Nullable<FloatArray>): void;
  22916. /**
  22917. * Gets the position data stored in this target
  22918. * @returns a FloatArray containing the position data (or null if not present)
  22919. */
  22920. getPositions(): Nullable<FloatArray>;
  22921. /**
  22922. * Affects normal data to this target
  22923. * @param data defines the normal data to use
  22924. */
  22925. setNormals(data: Nullable<FloatArray>): void;
  22926. /**
  22927. * Gets the normal data stored in this target
  22928. * @returns a FloatArray containing the normal data (or null if not present)
  22929. */
  22930. getNormals(): Nullable<FloatArray>;
  22931. /**
  22932. * Affects tangent data to this target
  22933. * @param data defines the tangent data to use
  22934. */
  22935. setTangents(data: Nullable<FloatArray>): void;
  22936. /**
  22937. * Gets the tangent data stored in this target
  22938. * @returns a FloatArray containing the tangent data (or null if not present)
  22939. */
  22940. getTangents(): Nullable<FloatArray>;
  22941. /**
  22942. * Affects texture coordinates data to this target
  22943. * @param data defines the texture coordinates data to use
  22944. */
  22945. setUVs(data: Nullable<FloatArray>): void;
  22946. /**
  22947. * Gets the texture coordinates data stored in this target
  22948. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22949. */
  22950. getUVs(): Nullable<FloatArray>;
  22951. /**
  22952. * Clone the current target
  22953. * @returns a new MorphTarget
  22954. */
  22955. clone(): MorphTarget;
  22956. /**
  22957. * Serializes the current target into a Serialization object
  22958. * @returns the serialized object
  22959. */
  22960. serialize(): any;
  22961. /**
  22962. * Returns the string "MorphTarget"
  22963. * @returns "MorphTarget"
  22964. */
  22965. getClassName(): string;
  22966. /**
  22967. * Creates a new target from serialized data
  22968. * @param serializationObject defines the serialized data to use
  22969. * @returns a new MorphTarget
  22970. */
  22971. static Parse(serializationObject: any): MorphTarget;
  22972. /**
  22973. * Creates a MorphTarget from mesh data
  22974. * @param mesh defines the source mesh
  22975. * @param name defines the name to use for the new target
  22976. * @param influence defines the influence to attach to the target
  22977. * @returns a new MorphTarget
  22978. */
  22979. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22980. }
  22981. }
  22982. declare module BABYLON {
  22983. /**
  22984. * This class is used to deform meshes using morphing between different targets
  22985. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22986. */
  22987. export class MorphTargetManager {
  22988. private _targets;
  22989. private _targetInfluenceChangedObservers;
  22990. private _targetDataLayoutChangedObservers;
  22991. private _activeTargets;
  22992. private _scene;
  22993. private _influences;
  22994. private _supportsNormals;
  22995. private _supportsTangents;
  22996. private _supportsUVs;
  22997. private _vertexCount;
  22998. private _uniqueId;
  22999. private _tempInfluences;
  23000. /**
  23001. * Gets or sets a boolean indicating if normals must be morphed
  23002. */
  23003. enableNormalMorphing: boolean;
  23004. /**
  23005. * Gets or sets a boolean indicating if tangents must be morphed
  23006. */
  23007. enableTangentMorphing: boolean;
  23008. /**
  23009. * Gets or sets a boolean indicating if UV must be morphed
  23010. */
  23011. enableUVMorphing: boolean;
  23012. /**
  23013. * Creates a new MorphTargetManager
  23014. * @param scene defines the current scene
  23015. */
  23016. constructor(scene?: Nullable<Scene>);
  23017. /**
  23018. * Gets the unique ID of this manager
  23019. */
  23020. get uniqueId(): number;
  23021. /**
  23022. * Gets the number of vertices handled by this manager
  23023. */
  23024. get vertexCount(): number;
  23025. /**
  23026. * Gets a boolean indicating if this manager supports morphing of normals
  23027. */
  23028. get supportsNormals(): boolean;
  23029. /**
  23030. * Gets a boolean indicating if this manager supports morphing of tangents
  23031. */
  23032. get supportsTangents(): boolean;
  23033. /**
  23034. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23035. */
  23036. get supportsUVs(): boolean;
  23037. /**
  23038. * Gets the number of targets stored in this manager
  23039. */
  23040. get numTargets(): number;
  23041. /**
  23042. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23043. */
  23044. get numInfluencers(): number;
  23045. /**
  23046. * Gets the list of influences (one per target)
  23047. */
  23048. get influences(): Float32Array;
  23049. /**
  23050. * Gets the active target at specified index. An active target is a target with an influence > 0
  23051. * @param index defines the index to check
  23052. * @returns the requested target
  23053. */
  23054. getActiveTarget(index: number): MorphTarget;
  23055. /**
  23056. * Gets the target at specified index
  23057. * @param index defines the index to check
  23058. * @returns the requested target
  23059. */
  23060. getTarget(index: number): MorphTarget;
  23061. /**
  23062. * Add a new target to this manager
  23063. * @param target defines the target to add
  23064. */
  23065. addTarget(target: MorphTarget): void;
  23066. /**
  23067. * Removes a target from the manager
  23068. * @param target defines the target to remove
  23069. */
  23070. removeTarget(target: MorphTarget): void;
  23071. /**
  23072. * Clone the current manager
  23073. * @returns a new MorphTargetManager
  23074. */
  23075. clone(): MorphTargetManager;
  23076. /**
  23077. * Serializes the current manager into a Serialization object
  23078. * @returns the serialized object
  23079. */
  23080. serialize(): any;
  23081. private _syncActiveTargets;
  23082. /**
  23083. * Syncrhonize the targets with all the meshes using this morph target manager
  23084. */
  23085. synchronize(): void;
  23086. /**
  23087. * Creates a new MorphTargetManager from serialized data
  23088. * @param serializationObject defines the serialized data
  23089. * @param scene defines the hosting scene
  23090. * @returns the new MorphTargetManager
  23091. */
  23092. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23093. }
  23094. }
  23095. declare module BABYLON {
  23096. /**
  23097. * Class used to represent a specific level of detail of a mesh
  23098. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23099. */
  23100. export class MeshLODLevel {
  23101. /** Defines the distance where this level should start being displayed */
  23102. distance: number;
  23103. /** Defines the mesh to use to render this level */
  23104. mesh: Nullable<Mesh>;
  23105. /**
  23106. * Creates a new LOD level
  23107. * @param distance defines the distance where this level should star being displayed
  23108. * @param mesh defines the mesh to use to render this level
  23109. */
  23110. constructor(
  23111. /** Defines the distance where this level should start being displayed */
  23112. distance: number,
  23113. /** Defines the mesh to use to render this level */
  23114. mesh: Nullable<Mesh>);
  23115. }
  23116. }
  23117. declare module BABYLON {
  23118. /**
  23119. * Mesh representing the gorund
  23120. */
  23121. export class GroundMesh extends Mesh {
  23122. /** If octree should be generated */
  23123. generateOctree: boolean;
  23124. private _heightQuads;
  23125. /** @hidden */
  23126. _subdivisionsX: number;
  23127. /** @hidden */
  23128. _subdivisionsY: number;
  23129. /** @hidden */
  23130. _width: number;
  23131. /** @hidden */
  23132. _height: number;
  23133. /** @hidden */
  23134. _minX: number;
  23135. /** @hidden */
  23136. _maxX: number;
  23137. /** @hidden */
  23138. _minZ: number;
  23139. /** @hidden */
  23140. _maxZ: number;
  23141. constructor(name: string, scene: Scene);
  23142. /**
  23143. * "GroundMesh"
  23144. * @returns "GroundMesh"
  23145. */
  23146. getClassName(): string;
  23147. /**
  23148. * The minimum of x and y subdivisions
  23149. */
  23150. get subdivisions(): number;
  23151. /**
  23152. * X subdivisions
  23153. */
  23154. get subdivisionsX(): number;
  23155. /**
  23156. * Y subdivisions
  23157. */
  23158. get subdivisionsY(): number;
  23159. /**
  23160. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23161. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23162. * @param chunksCount the number of subdivisions for x and y
  23163. * @param octreeBlocksSize (Default: 32)
  23164. */
  23165. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23166. /**
  23167. * Returns a height (y) value in the Worl system :
  23168. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23169. * @param x x coordinate
  23170. * @param z z coordinate
  23171. * @returns the ground y position if (x, z) are outside the ground surface.
  23172. */
  23173. getHeightAtCoordinates(x: number, z: number): number;
  23174. /**
  23175. * Returns a normalized vector (Vector3) orthogonal to the ground
  23176. * at the ground coordinates (x, z) expressed in the World system.
  23177. * @param x x coordinate
  23178. * @param z z coordinate
  23179. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23180. */
  23181. getNormalAtCoordinates(x: number, z: number): Vector3;
  23182. /**
  23183. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23184. * at the ground coordinates (x, z) expressed in the World system.
  23185. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23186. * @param x x coordinate
  23187. * @param z z coordinate
  23188. * @param ref vector to store the result
  23189. * @returns the GroundMesh.
  23190. */
  23191. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23192. /**
  23193. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23194. * if the ground has been updated.
  23195. * This can be used in the render loop.
  23196. * @returns the GroundMesh.
  23197. */
  23198. updateCoordinateHeights(): GroundMesh;
  23199. private _getFacetAt;
  23200. private _initHeightQuads;
  23201. private _computeHeightQuads;
  23202. /**
  23203. * Serializes this ground mesh
  23204. * @param serializationObject object to write serialization to
  23205. */
  23206. serialize(serializationObject: any): void;
  23207. /**
  23208. * Parses a serialized ground mesh
  23209. * @param parsedMesh the serialized mesh
  23210. * @param scene the scene to create the ground mesh in
  23211. * @returns the created ground mesh
  23212. */
  23213. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23214. }
  23215. }
  23216. declare module BABYLON {
  23217. /**
  23218. * Interface for Physics-Joint data
  23219. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23220. */
  23221. export interface PhysicsJointData {
  23222. /**
  23223. * The main pivot of the joint
  23224. */
  23225. mainPivot?: Vector3;
  23226. /**
  23227. * The connected pivot of the joint
  23228. */
  23229. connectedPivot?: Vector3;
  23230. /**
  23231. * The main axis of the joint
  23232. */
  23233. mainAxis?: Vector3;
  23234. /**
  23235. * The connected axis of the joint
  23236. */
  23237. connectedAxis?: Vector3;
  23238. /**
  23239. * The collision of the joint
  23240. */
  23241. collision?: boolean;
  23242. /**
  23243. * Native Oimo/Cannon/Energy data
  23244. */
  23245. nativeParams?: any;
  23246. }
  23247. /**
  23248. * This is a holder class for the physics joint created by the physics plugin
  23249. * It holds a set of functions to control the underlying joint
  23250. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23251. */
  23252. export class PhysicsJoint {
  23253. /**
  23254. * The type of the physics joint
  23255. */
  23256. type: number;
  23257. /**
  23258. * The data for the physics joint
  23259. */
  23260. jointData: PhysicsJointData;
  23261. private _physicsJoint;
  23262. protected _physicsPlugin: IPhysicsEnginePlugin;
  23263. /**
  23264. * Initializes the physics joint
  23265. * @param type The type of the physics joint
  23266. * @param jointData The data for the physics joint
  23267. */
  23268. constructor(
  23269. /**
  23270. * The type of the physics joint
  23271. */
  23272. type: number,
  23273. /**
  23274. * The data for the physics joint
  23275. */
  23276. jointData: PhysicsJointData);
  23277. /**
  23278. * Gets the physics joint
  23279. */
  23280. get physicsJoint(): any;
  23281. /**
  23282. * Sets the physics joint
  23283. */
  23284. set physicsJoint(newJoint: any);
  23285. /**
  23286. * Sets the physics plugin
  23287. */
  23288. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23289. /**
  23290. * Execute a function that is physics-plugin specific.
  23291. * @param {Function} func the function that will be executed.
  23292. * It accepts two parameters: the physics world and the physics joint
  23293. */
  23294. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23295. /**
  23296. * Distance-Joint type
  23297. */
  23298. static DistanceJoint: number;
  23299. /**
  23300. * Hinge-Joint type
  23301. */
  23302. static HingeJoint: number;
  23303. /**
  23304. * Ball-and-Socket joint type
  23305. */
  23306. static BallAndSocketJoint: number;
  23307. /**
  23308. * Wheel-Joint type
  23309. */
  23310. static WheelJoint: number;
  23311. /**
  23312. * Slider-Joint type
  23313. */
  23314. static SliderJoint: number;
  23315. /**
  23316. * Prismatic-Joint type
  23317. */
  23318. static PrismaticJoint: number;
  23319. /**
  23320. * Universal-Joint type
  23321. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23322. */
  23323. static UniversalJoint: number;
  23324. /**
  23325. * Hinge-Joint 2 type
  23326. */
  23327. static Hinge2Joint: number;
  23328. /**
  23329. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23330. */
  23331. static PointToPointJoint: number;
  23332. /**
  23333. * Spring-Joint type
  23334. */
  23335. static SpringJoint: number;
  23336. /**
  23337. * Lock-Joint type
  23338. */
  23339. static LockJoint: number;
  23340. }
  23341. /**
  23342. * A class representing a physics distance joint
  23343. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23344. */
  23345. export class DistanceJoint extends PhysicsJoint {
  23346. /**
  23347. *
  23348. * @param jointData The data for the Distance-Joint
  23349. */
  23350. constructor(jointData: DistanceJointData);
  23351. /**
  23352. * Update the predefined distance.
  23353. * @param maxDistance The maximum preferred distance
  23354. * @param minDistance The minimum preferred distance
  23355. */
  23356. updateDistance(maxDistance: number, minDistance?: number): void;
  23357. }
  23358. /**
  23359. * Represents a Motor-Enabled Joint
  23360. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23361. */
  23362. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23363. /**
  23364. * Initializes the Motor-Enabled Joint
  23365. * @param type The type of the joint
  23366. * @param jointData The physica joint data for the joint
  23367. */
  23368. constructor(type: number, jointData: PhysicsJointData);
  23369. /**
  23370. * Set the motor values.
  23371. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23372. * @param force the force to apply
  23373. * @param maxForce max force for this motor.
  23374. */
  23375. setMotor(force?: number, maxForce?: number): void;
  23376. /**
  23377. * Set the motor's limits.
  23378. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23379. * @param upperLimit The upper limit of the motor
  23380. * @param lowerLimit The lower limit of the motor
  23381. */
  23382. setLimit(upperLimit: number, lowerLimit?: number): void;
  23383. }
  23384. /**
  23385. * This class represents a single physics Hinge-Joint
  23386. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23387. */
  23388. export class HingeJoint extends MotorEnabledJoint {
  23389. /**
  23390. * Initializes the Hinge-Joint
  23391. * @param jointData The joint data for the Hinge-Joint
  23392. */
  23393. constructor(jointData: PhysicsJointData);
  23394. /**
  23395. * Set the motor values.
  23396. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23397. * @param {number} force the force to apply
  23398. * @param {number} maxForce max force for this motor.
  23399. */
  23400. setMotor(force?: number, maxForce?: number): void;
  23401. /**
  23402. * Set the motor's limits.
  23403. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23404. * @param upperLimit The upper limit of the motor
  23405. * @param lowerLimit The lower limit of the motor
  23406. */
  23407. setLimit(upperLimit: number, lowerLimit?: number): void;
  23408. }
  23409. /**
  23410. * This class represents a dual hinge physics joint (same as wheel joint)
  23411. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23412. */
  23413. export class Hinge2Joint extends MotorEnabledJoint {
  23414. /**
  23415. * Initializes the Hinge2-Joint
  23416. * @param jointData The joint data for the Hinge2-Joint
  23417. */
  23418. constructor(jointData: PhysicsJointData);
  23419. /**
  23420. * Set the motor values.
  23421. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23422. * @param {number} targetSpeed the speed the motor is to reach
  23423. * @param {number} maxForce max force for this motor.
  23424. * @param {motorIndex} the motor's index, 0 or 1.
  23425. */
  23426. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23427. /**
  23428. * Set the motor limits.
  23429. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23430. * @param {number} upperLimit the upper limit
  23431. * @param {number} lowerLimit lower limit
  23432. * @param {motorIndex} the motor's index, 0 or 1.
  23433. */
  23434. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23435. }
  23436. /**
  23437. * Interface for a motor enabled joint
  23438. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23439. */
  23440. export interface IMotorEnabledJoint {
  23441. /**
  23442. * Physics joint
  23443. */
  23444. physicsJoint: any;
  23445. /**
  23446. * Sets the motor of the motor-enabled joint
  23447. * @param force The force of the motor
  23448. * @param maxForce The maximum force of the motor
  23449. * @param motorIndex The index of the motor
  23450. */
  23451. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23452. /**
  23453. * Sets the limit of the motor
  23454. * @param upperLimit The upper limit of the motor
  23455. * @param lowerLimit The lower limit of the motor
  23456. * @param motorIndex The index of the motor
  23457. */
  23458. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23459. }
  23460. /**
  23461. * Joint data for a Distance-Joint
  23462. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23463. */
  23464. export interface DistanceJointData extends PhysicsJointData {
  23465. /**
  23466. * Max distance the 2 joint objects can be apart
  23467. */
  23468. maxDistance: number;
  23469. }
  23470. /**
  23471. * Joint data from a spring joint
  23472. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23473. */
  23474. export interface SpringJointData extends PhysicsJointData {
  23475. /**
  23476. * Length of the spring
  23477. */
  23478. length: number;
  23479. /**
  23480. * Stiffness of the spring
  23481. */
  23482. stiffness: number;
  23483. /**
  23484. * Damping of the spring
  23485. */
  23486. damping: number;
  23487. /** this callback will be called when applying the force to the impostors. */
  23488. forceApplicationCallback: () => void;
  23489. }
  23490. }
  23491. declare module BABYLON {
  23492. /**
  23493. * Holds the data for the raycast result
  23494. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23495. */
  23496. export class PhysicsRaycastResult {
  23497. private _hasHit;
  23498. private _hitDistance;
  23499. private _hitNormalWorld;
  23500. private _hitPointWorld;
  23501. private _rayFromWorld;
  23502. private _rayToWorld;
  23503. /**
  23504. * Gets if there was a hit
  23505. */
  23506. get hasHit(): boolean;
  23507. /**
  23508. * Gets the distance from the hit
  23509. */
  23510. get hitDistance(): number;
  23511. /**
  23512. * Gets the hit normal/direction in the world
  23513. */
  23514. get hitNormalWorld(): Vector3;
  23515. /**
  23516. * Gets the hit point in the world
  23517. */
  23518. get hitPointWorld(): Vector3;
  23519. /**
  23520. * Gets the ray "start point" of the ray in the world
  23521. */
  23522. get rayFromWorld(): Vector3;
  23523. /**
  23524. * Gets the ray "end point" of the ray in the world
  23525. */
  23526. get rayToWorld(): Vector3;
  23527. /**
  23528. * Sets the hit data (normal & point in world space)
  23529. * @param hitNormalWorld defines the normal in world space
  23530. * @param hitPointWorld defines the point in world space
  23531. */
  23532. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23533. /**
  23534. * Sets the distance from the start point to the hit point
  23535. * @param distance
  23536. */
  23537. setHitDistance(distance: number): void;
  23538. /**
  23539. * Calculates the distance manually
  23540. */
  23541. calculateHitDistance(): void;
  23542. /**
  23543. * Resets all the values to default
  23544. * @param from The from point on world space
  23545. * @param to The to point on world space
  23546. */
  23547. reset(from?: Vector3, to?: Vector3): void;
  23548. }
  23549. /**
  23550. * Interface for the size containing width and height
  23551. */
  23552. interface IXYZ {
  23553. /**
  23554. * X
  23555. */
  23556. x: number;
  23557. /**
  23558. * Y
  23559. */
  23560. y: number;
  23561. /**
  23562. * Z
  23563. */
  23564. z: number;
  23565. }
  23566. }
  23567. declare module BABYLON {
  23568. /**
  23569. * Interface used to describe a physics joint
  23570. */
  23571. export interface PhysicsImpostorJoint {
  23572. /** Defines the main impostor to which the joint is linked */
  23573. mainImpostor: PhysicsImpostor;
  23574. /** Defines the impostor that is connected to the main impostor using this joint */
  23575. connectedImpostor: PhysicsImpostor;
  23576. /** Defines the joint itself */
  23577. joint: PhysicsJoint;
  23578. }
  23579. /** @hidden */
  23580. export interface IPhysicsEnginePlugin {
  23581. world: any;
  23582. name: string;
  23583. setGravity(gravity: Vector3): void;
  23584. setTimeStep(timeStep: number): void;
  23585. getTimeStep(): number;
  23586. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23587. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23588. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23589. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23590. removePhysicsBody(impostor: PhysicsImpostor): void;
  23591. generateJoint(joint: PhysicsImpostorJoint): void;
  23592. removeJoint(joint: PhysicsImpostorJoint): void;
  23593. isSupported(): boolean;
  23594. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23595. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23596. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23597. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23598. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23599. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23600. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23601. getBodyMass(impostor: PhysicsImpostor): number;
  23602. getBodyFriction(impostor: PhysicsImpostor): number;
  23603. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23604. getBodyRestitution(impostor: PhysicsImpostor): number;
  23605. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23606. getBodyPressure?(impostor: PhysicsImpostor): number;
  23607. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23608. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23609. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23610. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23611. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23612. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23613. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23614. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23615. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23616. sleepBody(impostor: PhysicsImpostor): void;
  23617. wakeUpBody(impostor: PhysicsImpostor): void;
  23618. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23619. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23620. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23621. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23622. getRadius(impostor: PhysicsImpostor): number;
  23623. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23624. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23625. dispose(): void;
  23626. }
  23627. /**
  23628. * Interface used to define a physics engine
  23629. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23630. */
  23631. export interface IPhysicsEngine {
  23632. /**
  23633. * Gets the gravity vector used by the simulation
  23634. */
  23635. gravity: Vector3;
  23636. /**
  23637. * Sets the gravity vector used by the simulation
  23638. * @param gravity defines the gravity vector to use
  23639. */
  23640. setGravity(gravity: Vector3): void;
  23641. /**
  23642. * Set the time step of the physics engine.
  23643. * Default is 1/60.
  23644. * To slow it down, enter 1/600 for example.
  23645. * To speed it up, 1/30
  23646. * @param newTimeStep the new timestep to apply to this world.
  23647. */
  23648. setTimeStep(newTimeStep: number): void;
  23649. /**
  23650. * Get the time step of the physics engine.
  23651. * @returns the current time step
  23652. */
  23653. getTimeStep(): number;
  23654. /**
  23655. * Set the sub time step of the physics engine.
  23656. * Default is 0 meaning there is no sub steps
  23657. * To increase physics resolution precision, set a small value (like 1 ms)
  23658. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23659. */
  23660. setSubTimeStep(subTimeStep: number): void;
  23661. /**
  23662. * Get the sub time step of the physics engine.
  23663. * @returns the current sub time step
  23664. */
  23665. getSubTimeStep(): number;
  23666. /**
  23667. * Release all resources
  23668. */
  23669. dispose(): void;
  23670. /**
  23671. * Gets the name of the current physics plugin
  23672. * @returns the name of the plugin
  23673. */
  23674. getPhysicsPluginName(): string;
  23675. /**
  23676. * Adding a new impostor for the impostor tracking.
  23677. * This will be done by the impostor itself.
  23678. * @param impostor the impostor to add
  23679. */
  23680. addImpostor(impostor: PhysicsImpostor): void;
  23681. /**
  23682. * Remove an impostor from the engine.
  23683. * This impostor and its mesh will not longer be updated by the physics engine.
  23684. * @param impostor the impostor to remove
  23685. */
  23686. removeImpostor(impostor: PhysicsImpostor): void;
  23687. /**
  23688. * Add a joint to the physics engine
  23689. * @param mainImpostor defines the main impostor to which the joint is added.
  23690. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23691. * @param joint defines the joint that will connect both impostors.
  23692. */
  23693. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23694. /**
  23695. * Removes a joint from the simulation
  23696. * @param mainImpostor defines the impostor used with the joint
  23697. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23698. * @param joint defines the joint to remove
  23699. */
  23700. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23701. /**
  23702. * Gets the current plugin used to run the simulation
  23703. * @returns current plugin
  23704. */
  23705. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23706. /**
  23707. * Gets the list of physic impostors
  23708. * @returns an array of PhysicsImpostor
  23709. */
  23710. getImpostors(): Array<PhysicsImpostor>;
  23711. /**
  23712. * Gets the impostor for a physics enabled object
  23713. * @param object defines the object impersonated by the impostor
  23714. * @returns the PhysicsImpostor or null if not found
  23715. */
  23716. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23717. /**
  23718. * Gets the impostor for a physics body object
  23719. * @param body defines physics body used by the impostor
  23720. * @returns the PhysicsImpostor or null if not found
  23721. */
  23722. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23723. /**
  23724. * Does a raycast in the physics world
  23725. * @param from when should the ray start?
  23726. * @param to when should the ray end?
  23727. * @returns PhysicsRaycastResult
  23728. */
  23729. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23730. /**
  23731. * Called by the scene. No need to call it.
  23732. * @param delta defines the timespam between frames
  23733. */
  23734. _step(delta: number): void;
  23735. }
  23736. }
  23737. declare module BABYLON {
  23738. /**
  23739. * The interface for the physics imposter parameters
  23740. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23741. */
  23742. export interface PhysicsImpostorParameters {
  23743. /**
  23744. * The mass of the physics imposter
  23745. */
  23746. mass: number;
  23747. /**
  23748. * The friction of the physics imposter
  23749. */
  23750. friction?: number;
  23751. /**
  23752. * The coefficient of restitution of the physics imposter
  23753. */
  23754. restitution?: number;
  23755. /**
  23756. * The native options of the physics imposter
  23757. */
  23758. nativeOptions?: any;
  23759. /**
  23760. * Specifies if the parent should be ignored
  23761. */
  23762. ignoreParent?: boolean;
  23763. /**
  23764. * Specifies if bi-directional transformations should be disabled
  23765. */
  23766. disableBidirectionalTransformation?: boolean;
  23767. /**
  23768. * The pressure inside the physics imposter, soft object only
  23769. */
  23770. pressure?: number;
  23771. /**
  23772. * The stiffness the physics imposter, soft object only
  23773. */
  23774. stiffness?: number;
  23775. /**
  23776. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23777. */
  23778. velocityIterations?: number;
  23779. /**
  23780. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23781. */
  23782. positionIterations?: number;
  23783. /**
  23784. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23785. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23786. * Add to fix multiple points
  23787. */
  23788. fixedPoints?: number;
  23789. /**
  23790. * The collision margin around a soft object
  23791. */
  23792. margin?: number;
  23793. /**
  23794. * The collision margin around a soft object
  23795. */
  23796. damping?: number;
  23797. /**
  23798. * The path for a rope based on an extrusion
  23799. */
  23800. path?: any;
  23801. /**
  23802. * The shape of an extrusion used for a rope based on an extrusion
  23803. */
  23804. shape?: any;
  23805. }
  23806. /**
  23807. * Interface for a physics-enabled object
  23808. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23809. */
  23810. export interface IPhysicsEnabledObject {
  23811. /**
  23812. * The position of the physics-enabled object
  23813. */
  23814. position: Vector3;
  23815. /**
  23816. * The rotation of the physics-enabled object
  23817. */
  23818. rotationQuaternion: Nullable<Quaternion>;
  23819. /**
  23820. * The scale of the physics-enabled object
  23821. */
  23822. scaling: Vector3;
  23823. /**
  23824. * The rotation of the physics-enabled object
  23825. */
  23826. rotation?: Vector3;
  23827. /**
  23828. * The parent of the physics-enabled object
  23829. */
  23830. parent?: any;
  23831. /**
  23832. * The bounding info of the physics-enabled object
  23833. * @returns The bounding info of the physics-enabled object
  23834. */
  23835. getBoundingInfo(): BoundingInfo;
  23836. /**
  23837. * Computes the world matrix
  23838. * @param force Specifies if the world matrix should be computed by force
  23839. * @returns A world matrix
  23840. */
  23841. computeWorldMatrix(force: boolean): Matrix;
  23842. /**
  23843. * Gets the world matrix
  23844. * @returns A world matrix
  23845. */
  23846. getWorldMatrix?(): Matrix;
  23847. /**
  23848. * Gets the child meshes
  23849. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23850. * @returns An array of abstract meshes
  23851. */
  23852. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23853. /**
  23854. * Gets the vertex data
  23855. * @param kind The type of vertex data
  23856. * @returns A nullable array of numbers, or a float32 array
  23857. */
  23858. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23859. /**
  23860. * Gets the indices from the mesh
  23861. * @returns A nullable array of index arrays
  23862. */
  23863. getIndices?(): Nullable<IndicesArray>;
  23864. /**
  23865. * Gets the scene from the mesh
  23866. * @returns the indices array or null
  23867. */
  23868. getScene?(): Scene;
  23869. /**
  23870. * Gets the absolute position from the mesh
  23871. * @returns the absolute position
  23872. */
  23873. getAbsolutePosition(): Vector3;
  23874. /**
  23875. * Gets the absolute pivot point from the mesh
  23876. * @returns the absolute pivot point
  23877. */
  23878. getAbsolutePivotPoint(): Vector3;
  23879. /**
  23880. * Rotates the mesh
  23881. * @param axis The axis of rotation
  23882. * @param amount The amount of rotation
  23883. * @param space The space of the rotation
  23884. * @returns The rotation transform node
  23885. */
  23886. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23887. /**
  23888. * Translates the mesh
  23889. * @param axis The axis of translation
  23890. * @param distance The distance of translation
  23891. * @param space The space of the translation
  23892. * @returns The transform node
  23893. */
  23894. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23895. /**
  23896. * Sets the absolute position of the mesh
  23897. * @param absolutePosition The absolute position of the mesh
  23898. * @returns The transform node
  23899. */
  23900. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23901. /**
  23902. * Gets the class name of the mesh
  23903. * @returns The class name
  23904. */
  23905. getClassName(): string;
  23906. }
  23907. /**
  23908. * Represents a physics imposter
  23909. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23910. */
  23911. export class PhysicsImpostor {
  23912. /**
  23913. * The physics-enabled object used as the physics imposter
  23914. */
  23915. object: IPhysicsEnabledObject;
  23916. /**
  23917. * The type of the physics imposter
  23918. */
  23919. type: number;
  23920. private _options;
  23921. private _scene?;
  23922. /**
  23923. * The default object size of the imposter
  23924. */
  23925. static DEFAULT_OBJECT_SIZE: Vector3;
  23926. /**
  23927. * The identity quaternion of the imposter
  23928. */
  23929. static IDENTITY_QUATERNION: Quaternion;
  23930. /** @hidden */
  23931. _pluginData: any;
  23932. private _physicsEngine;
  23933. private _physicsBody;
  23934. private _bodyUpdateRequired;
  23935. private _onBeforePhysicsStepCallbacks;
  23936. private _onAfterPhysicsStepCallbacks;
  23937. /** @hidden */
  23938. _onPhysicsCollideCallbacks: Array<{
  23939. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23940. otherImpostors: Array<PhysicsImpostor>;
  23941. }>;
  23942. private _deltaPosition;
  23943. private _deltaRotation;
  23944. private _deltaRotationConjugated;
  23945. /** @hidden */
  23946. _isFromLine: boolean;
  23947. private _parent;
  23948. private _isDisposed;
  23949. private static _tmpVecs;
  23950. private static _tmpQuat;
  23951. /**
  23952. * Specifies if the physics imposter is disposed
  23953. */
  23954. get isDisposed(): boolean;
  23955. /**
  23956. * Gets the mass of the physics imposter
  23957. */
  23958. get mass(): number;
  23959. set mass(value: number);
  23960. /**
  23961. * Gets the coefficient of friction
  23962. */
  23963. get friction(): number;
  23964. /**
  23965. * Sets the coefficient of friction
  23966. */
  23967. set friction(value: number);
  23968. /**
  23969. * Gets the coefficient of restitution
  23970. */
  23971. get restitution(): number;
  23972. /**
  23973. * Sets the coefficient of restitution
  23974. */
  23975. set restitution(value: number);
  23976. /**
  23977. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23978. */
  23979. get pressure(): number;
  23980. /**
  23981. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23982. */
  23983. set pressure(value: number);
  23984. /**
  23985. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23986. */
  23987. get stiffness(): number;
  23988. /**
  23989. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23990. */
  23991. set stiffness(value: number);
  23992. /**
  23993. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23994. */
  23995. get velocityIterations(): number;
  23996. /**
  23997. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23998. */
  23999. set velocityIterations(value: number);
  24000. /**
  24001. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24002. */
  24003. get positionIterations(): number;
  24004. /**
  24005. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24006. */
  24007. set positionIterations(value: number);
  24008. /**
  24009. * The unique id of the physics imposter
  24010. * set by the physics engine when adding this impostor to the array
  24011. */
  24012. uniqueId: number;
  24013. /**
  24014. * @hidden
  24015. */
  24016. soft: boolean;
  24017. /**
  24018. * @hidden
  24019. */
  24020. segments: number;
  24021. private _joints;
  24022. /**
  24023. * Initializes the physics imposter
  24024. * @param object The physics-enabled object used as the physics imposter
  24025. * @param type The type of the physics imposter
  24026. * @param _options The options for the physics imposter
  24027. * @param _scene The Babylon scene
  24028. */
  24029. constructor(
  24030. /**
  24031. * The physics-enabled object used as the physics imposter
  24032. */
  24033. object: IPhysicsEnabledObject,
  24034. /**
  24035. * The type of the physics imposter
  24036. */
  24037. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24038. /**
  24039. * This function will completly initialize this impostor.
  24040. * It will create a new body - but only if this mesh has no parent.
  24041. * If it has, this impostor will not be used other than to define the impostor
  24042. * of the child mesh.
  24043. * @hidden
  24044. */
  24045. _init(): void;
  24046. private _getPhysicsParent;
  24047. /**
  24048. * Should a new body be generated.
  24049. * @returns boolean specifying if body initialization is required
  24050. */
  24051. isBodyInitRequired(): boolean;
  24052. /**
  24053. * Sets the updated scaling
  24054. * @param updated Specifies if the scaling is updated
  24055. */
  24056. setScalingUpdated(): void;
  24057. /**
  24058. * Force a regeneration of this or the parent's impostor's body.
  24059. * Use under cautious - This will remove all joints already implemented.
  24060. */
  24061. forceUpdate(): void;
  24062. /**
  24063. * Gets the body that holds this impostor. Either its own, or its parent.
  24064. */
  24065. get physicsBody(): any;
  24066. /**
  24067. * Get the parent of the physics imposter
  24068. * @returns Physics imposter or null
  24069. */
  24070. get parent(): Nullable<PhysicsImpostor>;
  24071. /**
  24072. * Sets the parent of the physics imposter
  24073. */
  24074. set parent(value: Nullable<PhysicsImpostor>);
  24075. /**
  24076. * Set the physics body. Used mainly by the physics engine/plugin
  24077. */
  24078. set physicsBody(physicsBody: any);
  24079. /**
  24080. * Resets the update flags
  24081. */
  24082. resetUpdateFlags(): void;
  24083. /**
  24084. * Gets the object extend size
  24085. * @returns the object extend size
  24086. */
  24087. getObjectExtendSize(): Vector3;
  24088. /**
  24089. * Gets the object center
  24090. * @returns The object center
  24091. */
  24092. getObjectCenter(): Vector3;
  24093. /**
  24094. * Get a specific parameter from the options parameters
  24095. * @param paramName The object parameter name
  24096. * @returns The object parameter
  24097. */
  24098. getParam(paramName: string): any;
  24099. /**
  24100. * Sets a specific parameter in the options given to the physics plugin
  24101. * @param paramName The parameter name
  24102. * @param value The value of the parameter
  24103. */
  24104. setParam(paramName: string, value: number): void;
  24105. /**
  24106. * Specifically change the body's mass option. Won't recreate the physics body object
  24107. * @param mass The mass of the physics imposter
  24108. */
  24109. setMass(mass: number): void;
  24110. /**
  24111. * Gets the linear velocity
  24112. * @returns linear velocity or null
  24113. */
  24114. getLinearVelocity(): Nullable<Vector3>;
  24115. /**
  24116. * Sets the linear velocity
  24117. * @param velocity linear velocity or null
  24118. */
  24119. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24120. /**
  24121. * Gets the angular velocity
  24122. * @returns angular velocity or null
  24123. */
  24124. getAngularVelocity(): Nullable<Vector3>;
  24125. /**
  24126. * Sets the angular velocity
  24127. * @param velocity The velocity or null
  24128. */
  24129. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24130. /**
  24131. * Execute a function with the physics plugin native code
  24132. * Provide a function the will have two variables - the world object and the physics body object
  24133. * @param func The function to execute with the physics plugin native code
  24134. */
  24135. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24136. /**
  24137. * Register a function that will be executed before the physics world is stepping forward
  24138. * @param func The function to execute before the physics world is stepped forward
  24139. */
  24140. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24141. /**
  24142. * Unregister a function that will be executed before the physics world is stepping forward
  24143. * @param func The function to execute before the physics world is stepped forward
  24144. */
  24145. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24146. /**
  24147. * Register a function that will be executed after the physics step
  24148. * @param func The function to execute after physics step
  24149. */
  24150. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24151. /**
  24152. * Unregisters a function that will be executed after the physics step
  24153. * @param func The function to execute after physics step
  24154. */
  24155. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24156. /**
  24157. * register a function that will be executed when this impostor collides against a different body
  24158. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24159. * @param func Callback that is executed on collision
  24160. */
  24161. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24162. /**
  24163. * Unregisters the physics imposter on contact
  24164. * @param collideAgainst The physics object to collide against
  24165. * @param func Callback to execute on collision
  24166. */
  24167. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24168. private _tmpQuat;
  24169. private _tmpQuat2;
  24170. /**
  24171. * Get the parent rotation
  24172. * @returns The parent rotation
  24173. */
  24174. getParentsRotation(): Quaternion;
  24175. /**
  24176. * this function is executed by the physics engine.
  24177. */
  24178. beforeStep: () => void;
  24179. /**
  24180. * this function is executed by the physics engine
  24181. */
  24182. afterStep: () => void;
  24183. /**
  24184. * Legacy collision detection event support
  24185. */
  24186. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24187. /**
  24188. * event and body object due to cannon's event-based architecture.
  24189. */
  24190. onCollide: (e: {
  24191. body: any;
  24192. }) => void;
  24193. /**
  24194. * Apply a force
  24195. * @param force The force to apply
  24196. * @param contactPoint The contact point for the force
  24197. * @returns The physics imposter
  24198. */
  24199. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24200. /**
  24201. * Apply an impulse
  24202. * @param force The impulse force
  24203. * @param contactPoint The contact point for the impulse force
  24204. * @returns The physics imposter
  24205. */
  24206. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24207. /**
  24208. * A help function to create a joint
  24209. * @param otherImpostor A physics imposter used to create a joint
  24210. * @param jointType The type of joint
  24211. * @param jointData The data for the joint
  24212. * @returns The physics imposter
  24213. */
  24214. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24215. /**
  24216. * Add a joint to this impostor with a different impostor
  24217. * @param otherImpostor A physics imposter used to add a joint
  24218. * @param joint The joint to add
  24219. * @returns The physics imposter
  24220. */
  24221. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24222. /**
  24223. * Add an anchor to a cloth impostor
  24224. * @param otherImpostor rigid impostor to anchor to
  24225. * @param width ratio across width from 0 to 1
  24226. * @param height ratio up height from 0 to 1
  24227. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24228. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24229. * @returns impostor the soft imposter
  24230. */
  24231. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24232. /**
  24233. * Add a hook to a rope impostor
  24234. * @param otherImpostor rigid impostor to anchor to
  24235. * @param length ratio across rope from 0 to 1
  24236. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24237. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24238. * @returns impostor the rope imposter
  24239. */
  24240. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24241. /**
  24242. * Will keep this body still, in a sleep mode.
  24243. * @returns the physics imposter
  24244. */
  24245. sleep(): PhysicsImpostor;
  24246. /**
  24247. * Wake the body up.
  24248. * @returns The physics imposter
  24249. */
  24250. wakeUp(): PhysicsImpostor;
  24251. /**
  24252. * Clones the physics imposter
  24253. * @param newObject The physics imposter clones to this physics-enabled object
  24254. * @returns A nullable physics imposter
  24255. */
  24256. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24257. /**
  24258. * Disposes the physics imposter
  24259. */
  24260. dispose(): void;
  24261. /**
  24262. * Sets the delta position
  24263. * @param position The delta position amount
  24264. */
  24265. setDeltaPosition(position: Vector3): void;
  24266. /**
  24267. * Sets the delta rotation
  24268. * @param rotation The delta rotation amount
  24269. */
  24270. setDeltaRotation(rotation: Quaternion): void;
  24271. /**
  24272. * Gets the box size of the physics imposter and stores the result in the input parameter
  24273. * @param result Stores the box size
  24274. * @returns The physics imposter
  24275. */
  24276. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24277. /**
  24278. * Gets the radius of the physics imposter
  24279. * @returns Radius of the physics imposter
  24280. */
  24281. getRadius(): number;
  24282. /**
  24283. * Sync a bone with this impostor
  24284. * @param bone The bone to sync to the impostor.
  24285. * @param boneMesh The mesh that the bone is influencing.
  24286. * @param jointPivot The pivot of the joint / bone in local space.
  24287. * @param distToJoint Optional distance from the impostor to the joint.
  24288. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24289. */
  24290. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24291. /**
  24292. * Sync impostor to a bone
  24293. * @param bone The bone that the impostor will be synced to.
  24294. * @param boneMesh The mesh that the bone is influencing.
  24295. * @param jointPivot The pivot of the joint / bone in local space.
  24296. * @param distToJoint Optional distance from the impostor to the joint.
  24297. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24298. * @param boneAxis Optional vector3 axis the bone is aligned with
  24299. */
  24300. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24301. /**
  24302. * No-Imposter type
  24303. */
  24304. static NoImpostor: number;
  24305. /**
  24306. * Sphere-Imposter type
  24307. */
  24308. static SphereImpostor: number;
  24309. /**
  24310. * Box-Imposter type
  24311. */
  24312. static BoxImpostor: number;
  24313. /**
  24314. * Plane-Imposter type
  24315. */
  24316. static PlaneImpostor: number;
  24317. /**
  24318. * Mesh-imposter type
  24319. */
  24320. static MeshImpostor: number;
  24321. /**
  24322. * Capsule-Impostor type (Ammo.js plugin only)
  24323. */
  24324. static CapsuleImpostor: number;
  24325. /**
  24326. * Cylinder-Imposter type
  24327. */
  24328. static CylinderImpostor: number;
  24329. /**
  24330. * Particle-Imposter type
  24331. */
  24332. static ParticleImpostor: number;
  24333. /**
  24334. * Heightmap-Imposter type
  24335. */
  24336. static HeightmapImpostor: number;
  24337. /**
  24338. * ConvexHull-Impostor type (Ammo.js plugin only)
  24339. */
  24340. static ConvexHullImpostor: number;
  24341. /**
  24342. * Custom-Imposter type (Ammo.js plugin only)
  24343. */
  24344. static CustomImpostor: number;
  24345. /**
  24346. * Rope-Imposter type
  24347. */
  24348. static RopeImpostor: number;
  24349. /**
  24350. * Cloth-Imposter type
  24351. */
  24352. static ClothImpostor: number;
  24353. /**
  24354. * Softbody-Imposter type
  24355. */
  24356. static SoftbodyImpostor: number;
  24357. }
  24358. }
  24359. declare module BABYLON {
  24360. /**
  24361. * @hidden
  24362. **/
  24363. export class _CreationDataStorage {
  24364. closePath?: boolean;
  24365. closeArray?: boolean;
  24366. idx: number[];
  24367. dashSize: number;
  24368. gapSize: number;
  24369. path3D: Path3D;
  24370. pathArray: Vector3[][];
  24371. arc: number;
  24372. radius: number;
  24373. cap: number;
  24374. tessellation: number;
  24375. }
  24376. /**
  24377. * @hidden
  24378. **/
  24379. class _InstanceDataStorage {
  24380. visibleInstances: any;
  24381. batchCache: _InstancesBatch;
  24382. instancesBufferSize: number;
  24383. instancesBuffer: Nullable<Buffer>;
  24384. instancesData: Float32Array;
  24385. overridenInstanceCount: number;
  24386. isFrozen: boolean;
  24387. previousBatch: Nullable<_InstancesBatch>;
  24388. hardwareInstancedRendering: boolean;
  24389. sideOrientation: number;
  24390. manualUpdate: boolean;
  24391. }
  24392. /**
  24393. * @hidden
  24394. **/
  24395. export class _InstancesBatch {
  24396. mustReturn: boolean;
  24397. visibleInstances: Nullable<InstancedMesh[]>[];
  24398. renderSelf: boolean[];
  24399. hardwareInstancedRendering: boolean[];
  24400. }
  24401. /**
  24402. * Class used to represent renderable models
  24403. */
  24404. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24405. /**
  24406. * Mesh side orientation : usually the external or front surface
  24407. */
  24408. static readonly FRONTSIDE: number;
  24409. /**
  24410. * Mesh side orientation : usually the internal or back surface
  24411. */
  24412. static readonly BACKSIDE: number;
  24413. /**
  24414. * Mesh side orientation : both internal and external or front and back surfaces
  24415. */
  24416. static readonly DOUBLESIDE: number;
  24417. /**
  24418. * Mesh side orientation : by default, `FRONTSIDE`
  24419. */
  24420. static readonly DEFAULTSIDE: number;
  24421. /**
  24422. * Mesh cap setting : no cap
  24423. */
  24424. static readonly NO_CAP: number;
  24425. /**
  24426. * Mesh cap setting : one cap at the beginning of the mesh
  24427. */
  24428. static readonly CAP_START: number;
  24429. /**
  24430. * Mesh cap setting : one cap at the end of the mesh
  24431. */
  24432. static readonly CAP_END: number;
  24433. /**
  24434. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24435. */
  24436. static readonly CAP_ALL: number;
  24437. /**
  24438. * Mesh pattern setting : no flip or rotate
  24439. */
  24440. static readonly NO_FLIP: number;
  24441. /**
  24442. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24443. */
  24444. static readonly FLIP_TILE: number;
  24445. /**
  24446. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24447. */
  24448. static readonly ROTATE_TILE: number;
  24449. /**
  24450. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24451. */
  24452. static readonly FLIP_ROW: number;
  24453. /**
  24454. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24455. */
  24456. static readonly ROTATE_ROW: number;
  24457. /**
  24458. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24459. */
  24460. static readonly FLIP_N_ROTATE_TILE: number;
  24461. /**
  24462. * Mesh pattern setting : rotate pattern and rotate
  24463. */
  24464. static readonly FLIP_N_ROTATE_ROW: number;
  24465. /**
  24466. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24467. */
  24468. static readonly CENTER: number;
  24469. /**
  24470. * Mesh tile positioning : part tiles on left
  24471. */
  24472. static readonly LEFT: number;
  24473. /**
  24474. * Mesh tile positioning : part tiles on right
  24475. */
  24476. static readonly RIGHT: number;
  24477. /**
  24478. * Mesh tile positioning : part tiles on top
  24479. */
  24480. static readonly TOP: number;
  24481. /**
  24482. * Mesh tile positioning : part tiles on bottom
  24483. */
  24484. static readonly BOTTOM: number;
  24485. /**
  24486. * Gets the default side orientation.
  24487. * @param orientation the orientation to value to attempt to get
  24488. * @returns the default orientation
  24489. * @hidden
  24490. */
  24491. static _GetDefaultSideOrientation(orientation?: number): number;
  24492. private _internalMeshDataInfo;
  24493. /**
  24494. * An event triggered before rendering the mesh
  24495. */
  24496. get onBeforeRenderObservable(): Observable<Mesh>;
  24497. /**
  24498. * An event triggered before binding the mesh
  24499. */
  24500. get onBeforeBindObservable(): Observable<Mesh>;
  24501. /**
  24502. * An event triggered after rendering the mesh
  24503. */
  24504. get onAfterRenderObservable(): Observable<Mesh>;
  24505. /**
  24506. * An event triggered before drawing the mesh
  24507. */
  24508. get onBeforeDrawObservable(): Observable<Mesh>;
  24509. private _onBeforeDrawObserver;
  24510. /**
  24511. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24512. */
  24513. set onBeforeDraw(callback: () => void);
  24514. get hasInstances(): boolean;
  24515. /**
  24516. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24517. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24518. */
  24519. delayLoadState: number;
  24520. /**
  24521. * Gets the list of instances created from this mesh
  24522. * it is not supposed to be modified manually.
  24523. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24524. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24525. */
  24526. instances: InstancedMesh[];
  24527. /**
  24528. * Gets the file containing delay loading data for this mesh
  24529. */
  24530. delayLoadingFile: string;
  24531. /** @hidden */
  24532. _binaryInfo: any;
  24533. /**
  24534. * User defined function used to change how LOD level selection is done
  24535. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24536. */
  24537. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24538. /**
  24539. * Gets or sets the morph target manager
  24540. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24541. */
  24542. get morphTargetManager(): Nullable<MorphTargetManager>;
  24543. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24544. /** @hidden */
  24545. _creationDataStorage: Nullable<_CreationDataStorage>;
  24546. /** @hidden */
  24547. _geometry: Nullable<Geometry>;
  24548. /** @hidden */
  24549. _delayInfo: Array<string>;
  24550. /** @hidden */
  24551. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24552. /** @hidden */
  24553. _instanceDataStorage: _InstanceDataStorage;
  24554. private _effectiveMaterial;
  24555. /** @hidden */
  24556. _shouldGenerateFlatShading: boolean;
  24557. /** @hidden */
  24558. _originalBuilderSideOrientation: number;
  24559. /**
  24560. * Use this property to change the original side orientation defined at construction time
  24561. */
  24562. overrideMaterialSideOrientation: Nullable<number>;
  24563. /**
  24564. * Gets the source mesh (the one used to clone this one from)
  24565. */
  24566. get source(): Nullable<Mesh>;
  24567. /**
  24568. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24569. */
  24570. get isUnIndexed(): boolean;
  24571. set isUnIndexed(value: boolean);
  24572. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24573. get worldMatrixInstancedBuffer(): Float32Array;
  24574. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24575. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24576. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24577. /**
  24578. * @constructor
  24579. * @param name The value used by scene.getMeshByName() to do a lookup.
  24580. * @param scene The scene to add this mesh to.
  24581. * @param parent The parent of this mesh, if it has one
  24582. * @param source An optional Mesh from which geometry is shared, cloned.
  24583. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24584. * When false, achieved by calling a clone(), also passing False.
  24585. * This will make creation of children, recursive.
  24586. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24587. */
  24588. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24589. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24590. doNotInstantiate: boolean;
  24591. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24592. /**
  24593. * Gets the class name
  24594. * @returns the string "Mesh".
  24595. */
  24596. getClassName(): string;
  24597. /** @hidden */
  24598. get _isMesh(): boolean;
  24599. /**
  24600. * Returns a description of this mesh
  24601. * @param fullDetails define if full details about this mesh must be used
  24602. * @returns a descriptive string representing this mesh
  24603. */
  24604. toString(fullDetails?: boolean): string;
  24605. /** @hidden */
  24606. _unBindEffect(): void;
  24607. /**
  24608. * Gets a boolean indicating if this mesh has LOD
  24609. */
  24610. get hasLODLevels(): boolean;
  24611. /**
  24612. * Gets the list of MeshLODLevel associated with the current mesh
  24613. * @returns an array of MeshLODLevel
  24614. */
  24615. getLODLevels(): MeshLODLevel[];
  24616. private _sortLODLevels;
  24617. /**
  24618. * Add a mesh as LOD level triggered at the given distance.
  24619. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24620. * @param distance The distance from the center of the object to show this level
  24621. * @param mesh The mesh to be added as LOD level (can be null)
  24622. * @return This mesh (for chaining)
  24623. */
  24624. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24625. /**
  24626. * Returns the LOD level mesh at the passed distance or null if not found.
  24627. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24628. * @param distance The distance from the center of the object to show this level
  24629. * @returns a Mesh or `null`
  24630. */
  24631. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24632. /**
  24633. * Remove a mesh from the LOD array
  24634. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24635. * @param mesh defines the mesh to be removed
  24636. * @return This mesh (for chaining)
  24637. */
  24638. removeLODLevel(mesh: Mesh): Mesh;
  24639. /**
  24640. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24641. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24642. * @param camera defines the camera to use to compute distance
  24643. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24644. * @return This mesh (for chaining)
  24645. */
  24646. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24647. /**
  24648. * Gets the mesh internal Geometry object
  24649. */
  24650. get geometry(): Nullable<Geometry>;
  24651. /**
  24652. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24653. * @returns the total number of vertices
  24654. */
  24655. getTotalVertices(): number;
  24656. /**
  24657. * Returns the content of an associated vertex buffer
  24658. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24659. * - VertexBuffer.PositionKind
  24660. * - VertexBuffer.UVKind
  24661. * - VertexBuffer.UV2Kind
  24662. * - VertexBuffer.UV3Kind
  24663. * - VertexBuffer.UV4Kind
  24664. * - VertexBuffer.UV5Kind
  24665. * - VertexBuffer.UV6Kind
  24666. * - VertexBuffer.ColorKind
  24667. * - VertexBuffer.MatricesIndicesKind
  24668. * - VertexBuffer.MatricesIndicesExtraKind
  24669. * - VertexBuffer.MatricesWeightsKind
  24670. * - VertexBuffer.MatricesWeightsExtraKind
  24671. * @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
  24672. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24673. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24674. */
  24675. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24676. /**
  24677. * Returns the mesh VertexBuffer object from the requested `kind`
  24678. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24679. * - VertexBuffer.PositionKind
  24680. * - VertexBuffer.NormalKind
  24681. * - VertexBuffer.UVKind
  24682. * - VertexBuffer.UV2Kind
  24683. * - VertexBuffer.UV3Kind
  24684. * - VertexBuffer.UV4Kind
  24685. * - VertexBuffer.UV5Kind
  24686. * - VertexBuffer.UV6Kind
  24687. * - VertexBuffer.ColorKind
  24688. * - VertexBuffer.MatricesIndicesKind
  24689. * - VertexBuffer.MatricesIndicesExtraKind
  24690. * - VertexBuffer.MatricesWeightsKind
  24691. * - VertexBuffer.MatricesWeightsExtraKind
  24692. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24693. */
  24694. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24695. /**
  24696. * Tests if a specific vertex buffer is associated with this mesh
  24697. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24698. * - VertexBuffer.PositionKind
  24699. * - VertexBuffer.NormalKind
  24700. * - VertexBuffer.UVKind
  24701. * - VertexBuffer.UV2Kind
  24702. * - VertexBuffer.UV3Kind
  24703. * - VertexBuffer.UV4Kind
  24704. * - VertexBuffer.UV5Kind
  24705. * - VertexBuffer.UV6Kind
  24706. * - VertexBuffer.ColorKind
  24707. * - VertexBuffer.MatricesIndicesKind
  24708. * - VertexBuffer.MatricesIndicesExtraKind
  24709. * - VertexBuffer.MatricesWeightsKind
  24710. * - VertexBuffer.MatricesWeightsExtraKind
  24711. * @returns a boolean
  24712. */
  24713. isVerticesDataPresent(kind: string): boolean;
  24714. /**
  24715. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24716. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24717. * - VertexBuffer.PositionKind
  24718. * - VertexBuffer.UVKind
  24719. * - VertexBuffer.UV2Kind
  24720. * - VertexBuffer.UV3Kind
  24721. * - VertexBuffer.UV4Kind
  24722. * - VertexBuffer.UV5Kind
  24723. * - VertexBuffer.UV6Kind
  24724. * - VertexBuffer.ColorKind
  24725. * - VertexBuffer.MatricesIndicesKind
  24726. * - VertexBuffer.MatricesIndicesExtraKind
  24727. * - VertexBuffer.MatricesWeightsKind
  24728. * - VertexBuffer.MatricesWeightsExtraKind
  24729. * @returns a boolean
  24730. */
  24731. isVertexBufferUpdatable(kind: string): boolean;
  24732. /**
  24733. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24734. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24735. * - VertexBuffer.PositionKind
  24736. * - VertexBuffer.NormalKind
  24737. * - VertexBuffer.UVKind
  24738. * - VertexBuffer.UV2Kind
  24739. * - VertexBuffer.UV3Kind
  24740. * - VertexBuffer.UV4Kind
  24741. * - VertexBuffer.UV5Kind
  24742. * - VertexBuffer.UV6Kind
  24743. * - VertexBuffer.ColorKind
  24744. * - VertexBuffer.MatricesIndicesKind
  24745. * - VertexBuffer.MatricesIndicesExtraKind
  24746. * - VertexBuffer.MatricesWeightsKind
  24747. * - VertexBuffer.MatricesWeightsExtraKind
  24748. * @returns an array of strings
  24749. */
  24750. getVerticesDataKinds(): string[];
  24751. /**
  24752. * Returns a positive integer : the total number of indices in this mesh geometry.
  24753. * @returns the numner of indices or zero if the mesh has no geometry.
  24754. */
  24755. getTotalIndices(): number;
  24756. /**
  24757. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24758. * @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.
  24759. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24760. * @returns the indices array or an empty array if the mesh has no geometry
  24761. */
  24762. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24763. get isBlocked(): boolean;
  24764. /**
  24765. * Determine if the current mesh is ready to be rendered
  24766. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24767. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24768. * @returns true if all associated assets are ready (material, textures, shaders)
  24769. */
  24770. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24771. /**
  24772. * 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.
  24773. */
  24774. get areNormalsFrozen(): boolean;
  24775. /**
  24776. * 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.
  24777. * @returns the current mesh
  24778. */
  24779. freezeNormals(): Mesh;
  24780. /**
  24781. * 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
  24782. * @returns the current mesh
  24783. */
  24784. unfreezeNormals(): Mesh;
  24785. /**
  24786. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24787. */
  24788. set overridenInstanceCount(count: number);
  24789. /** @hidden */
  24790. _preActivate(): Mesh;
  24791. /** @hidden */
  24792. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24793. /** @hidden */
  24794. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24795. /**
  24796. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24797. * This means the mesh underlying bounding box and sphere are recomputed.
  24798. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24799. * @returns the current mesh
  24800. */
  24801. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24802. /** @hidden */
  24803. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24804. /**
  24805. * This function will subdivide the mesh into multiple submeshes
  24806. * @param count defines the expected number of submeshes
  24807. */
  24808. subdivide(count: number): void;
  24809. /**
  24810. * Copy a FloatArray into a specific associated vertex buffer
  24811. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24812. * - VertexBuffer.PositionKind
  24813. * - VertexBuffer.UVKind
  24814. * - VertexBuffer.UV2Kind
  24815. * - VertexBuffer.UV3Kind
  24816. * - VertexBuffer.UV4Kind
  24817. * - VertexBuffer.UV5Kind
  24818. * - VertexBuffer.UV6Kind
  24819. * - VertexBuffer.ColorKind
  24820. * - VertexBuffer.MatricesIndicesKind
  24821. * - VertexBuffer.MatricesIndicesExtraKind
  24822. * - VertexBuffer.MatricesWeightsKind
  24823. * - VertexBuffer.MatricesWeightsExtraKind
  24824. * @param data defines the data source
  24825. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24826. * @param stride defines the data stride size (can be null)
  24827. * @returns the current mesh
  24828. */
  24829. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24830. /**
  24831. * Delete a vertex buffer associated with this mesh
  24832. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24833. * - VertexBuffer.PositionKind
  24834. * - VertexBuffer.UVKind
  24835. * - VertexBuffer.UV2Kind
  24836. * - VertexBuffer.UV3Kind
  24837. * - VertexBuffer.UV4Kind
  24838. * - VertexBuffer.UV5Kind
  24839. * - VertexBuffer.UV6Kind
  24840. * - VertexBuffer.ColorKind
  24841. * - VertexBuffer.MatricesIndicesKind
  24842. * - VertexBuffer.MatricesIndicesExtraKind
  24843. * - VertexBuffer.MatricesWeightsKind
  24844. * - VertexBuffer.MatricesWeightsExtraKind
  24845. */
  24846. removeVerticesData(kind: string): void;
  24847. /**
  24848. * Flags an associated vertex buffer as updatable
  24849. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24850. * - VertexBuffer.PositionKind
  24851. * - VertexBuffer.UVKind
  24852. * - VertexBuffer.UV2Kind
  24853. * - VertexBuffer.UV3Kind
  24854. * - VertexBuffer.UV4Kind
  24855. * - VertexBuffer.UV5Kind
  24856. * - VertexBuffer.UV6Kind
  24857. * - VertexBuffer.ColorKind
  24858. * - VertexBuffer.MatricesIndicesKind
  24859. * - VertexBuffer.MatricesIndicesExtraKind
  24860. * - VertexBuffer.MatricesWeightsKind
  24861. * - VertexBuffer.MatricesWeightsExtraKind
  24862. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24863. */
  24864. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24865. /**
  24866. * Sets the mesh global Vertex Buffer
  24867. * @param buffer defines the buffer to use
  24868. * @returns the current mesh
  24869. */
  24870. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24871. /**
  24872. * Update a specific associated vertex buffer
  24873. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24874. * - VertexBuffer.PositionKind
  24875. * - VertexBuffer.UVKind
  24876. * - VertexBuffer.UV2Kind
  24877. * - VertexBuffer.UV3Kind
  24878. * - VertexBuffer.UV4Kind
  24879. * - VertexBuffer.UV5Kind
  24880. * - VertexBuffer.UV6Kind
  24881. * - VertexBuffer.ColorKind
  24882. * - VertexBuffer.MatricesIndicesKind
  24883. * - VertexBuffer.MatricesIndicesExtraKind
  24884. * - VertexBuffer.MatricesWeightsKind
  24885. * - VertexBuffer.MatricesWeightsExtraKind
  24886. * @param data defines the data source
  24887. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24888. * @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)
  24889. * @returns the current mesh
  24890. */
  24891. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24892. /**
  24893. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24894. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24895. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24896. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24897. * @returns the current mesh
  24898. */
  24899. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24900. /**
  24901. * Creates a un-shared specific occurence of the geometry for the mesh.
  24902. * @returns the current mesh
  24903. */
  24904. makeGeometryUnique(): Mesh;
  24905. /**
  24906. * Set the index buffer of this mesh
  24907. * @param indices defines the source data
  24908. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24909. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24910. * @returns the current mesh
  24911. */
  24912. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24913. /**
  24914. * Update the current index buffer
  24915. * @param indices defines the source data
  24916. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24917. * @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)
  24918. * @returns the current mesh
  24919. */
  24920. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24921. /**
  24922. * Invert the geometry to move from a right handed system to a left handed one.
  24923. * @returns the current mesh
  24924. */
  24925. toLeftHanded(): Mesh;
  24926. /** @hidden */
  24927. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24928. /** @hidden */
  24929. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24930. /**
  24931. * Registers for this mesh a javascript function called just before the rendering process
  24932. * @param func defines the function to call before rendering this mesh
  24933. * @returns the current mesh
  24934. */
  24935. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24936. /**
  24937. * Disposes a previously registered javascript function called before the rendering
  24938. * @param func defines the function to remove
  24939. * @returns the current mesh
  24940. */
  24941. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24942. /**
  24943. * Registers for this mesh a javascript function called just after the rendering is complete
  24944. * @param func defines the function to call after rendering this mesh
  24945. * @returns the current mesh
  24946. */
  24947. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24948. /**
  24949. * Disposes a previously registered javascript function called after the rendering.
  24950. * @param func defines the function to remove
  24951. * @returns the current mesh
  24952. */
  24953. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24954. /** @hidden */
  24955. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  24956. /** @hidden */
  24957. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24958. /** @hidden */
  24959. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24960. /** @hidden */
  24961. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24962. /** @hidden */
  24963. _rebuild(): void;
  24964. /** @hidden */
  24965. _freeze(): void;
  24966. /** @hidden */
  24967. _unFreeze(): void;
  24968. /**
  24969. * 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
  24970. * @param subMesh defines the subMesh to render
  24971. * @param enableAlphaMode defines if alpha mode can be changed
  24972. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24973. * @returns the current mesh
  24974. */
  24975. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24976. private _onBeforeDraw;
  24977. /**
  24978. * Renormalize the mesh and patch it up if there are no weights
  24979. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24980. * However in the case of zero weights then we set just a single influence to 1.
  24981. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24982. */
  24983. cleanMatrixWeights(): void;
  24984. private normalizeSkinFourWeights;
  24985. private normalizeSkinWeightsAndExtra;
  24986. /**
  24987. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24988. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24989. * the user know there was an issue with importing the mesh
  24990. * @returns a validation object with skinned, valid and report string
  24991. */
  24992. validateSkinning(): {
  24993. skinned: boolean;
  24994. valid: boolean;
  24995. report: string;
  24996. };
  24997. /** @hidden */
  24998. _checkDelayState(): Mesh;
  24999. private _queueLoad;
  25000. /**
  25001. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25002. * A mesh is in the frustum if its bounding box intersects the frustum
  25003. * @param frustumPlanes defines the frustum to test
  25004. * @returns true if the mesh is in the frustum planes
  25005. */
  25006. isInFrustum(frustumPlanes: Plane[]): boolean;
  25007. /**
  25008. * Sets the mesh material by the material or multiMaterial `id` property
  25009. * @param id is a string identifying the material or the multiMaterial
  25010. * @returns the current mesh
  25011. */
  25012. setMaterialByID(id: string): Mesh;
  25013. /**
  25014. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25015. * @returns an array of IAnimatable
  25016. */
  25017. getAnimatables(): IAnimatable[];
  25018. /**
  25019. * Modifies the mesh geometry according to the passed transformation matrix.
  25020. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25021. * The mesh normals are modified using the same transformation.
  25022. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25023. * @param transform defines the transform matrix to use
  25024. * @see http://doc.babylonjs.com/resources/baking_transformations
  25025. * @returns the current mesh
  25026. */
  25027. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25028. /**
  25029. * Modifies the mesh geometry according to its own current World Matrix.
  25030. * The mesh World Matrix is then reset.
  25031. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25032. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25033. * @see http://doc.babylonjs.com/resources/baking_transformations
  25034. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25035. * @returns the current mesh
  25036. */
  25037. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25038. /** @hidden */
  25039. get _positions(): Nullable<Vector3[]>;
  25040. /** @hidden */
  25041. _resetPointsArrayCache(): Mesh;
  25042. /** @hidden */
  25043. _generatePointsArray(): boolean;
  25044. /**
  25045. * Returns a new Mesh object generated from the current mesh properties.
  25046. * This method must not get confused with createInstance()
  25047. * @param name is a string, the name given to the new mesh
  25048. * @param newParent can be any Node object (default `null`)
  25049. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25050. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25051. * @returns a new mesh
  25052. */
  25053. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25054. /**
  25055. * Releases resources associated with this mesh.
  25056. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25057. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25058. */
  25059. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25060. /** @hidden */
  25061. _disposeInstanceSpecificData(): void;
  25062. /**
  25063. * Modifies the mesh geometry according to a displacement map.
  25064. * 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.
  25065. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25066. * @param url is a string, the URL from the image file is to be downloaded.
  25067. * @param minHeight is the lower limit of the displacement.
  25068. * @param maxHeight is the upper limit of the displacement.
  25069. * @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.
  25070. * @param uvOffset is an optional vector2 used to offset UV.
  25071. * @param uvScale is an optional vector2 used to scale UV.
  25072. * @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.
  25073. * @returns the Mesh.
  25074. */
  25075. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25076. /**
  25077. * Modifies the mesh geometry according to a displacementMap buffer.
  25078. * 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.
  25079. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25080. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25081. * @param heightMapWidth is the width of the buffer image.
  25082. * @param heightMapHeight is the height of the buffer image.
  25083. * @param minHeight is the lower limit of the displacement.
  25084. * @param maxHeight is the upper limit of the displacement.
  25085. * @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.
  25086. * @param uvOffset is an optional vector2 used to offset UV.
  25087. * @param uvScale is an optional vector2 used to scale UV.
  25088. * @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.
  25089. * @returns the Mesh.
  25090. */
  25091. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25092. /**
  25093. * Modify the mesh to get a flat shading rendering.
  25094. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25095. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25096. * @returns current mesh
  25097. */
  25098. convertToFlatShadedMesh(): Mesh;
  25099. /**
  25100. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25101. * In other words, more vertices, no more indices and a single bigger VBO.
  25102. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25103. * @returns current mesh
  25104. */
  25105. convertToUnIndexedMesh(): Mesh;
  25106. /**
  25107. * Inverses facet orientations.
  25108. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25109. * @param flipNormals will also inverts the normals
  25110. * @returns current mesh
  25111. */
  25112. flipFaces(flipNormals?: boolean): Mesh;
  25113. /**
  25114. * Increase the number of facets and hence vertices in a mesh
  25115. * Vertex normals are interpolated from existing vertex normals
  25116. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25117. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25118. */
  25119. increaseVertices(numberPerEdge: number): void;
  25120. /**
  25121. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25122. * This will undo any application of covertToFlatShadedMesh
  25123. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25124. */
  25125. forceSharedVertices(): void;
  25126. /** @hidden */
  25127. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25128. /** @hidden */
  25129. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25130. /**
  25131. * Creates a new InstancedMesh object from the mesh model.
  25132. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25133. * @param name defines the name of the new instance
  25134. * @returns a new InstancedMesh
  25135. */
  25136. createInstance(name: string): InstancedMesh;
  25137. /**
  25138. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25139. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25140. * @returns the current mesh
  25141. */
  25142. synchronizeInstances(): Mesh;
  25143. /**
  25144. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25145. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25146. * This should be used together with the simplification to avoid disappearing triangles.
  25147. * @param successCallback an optional success callback to be called after the optimization finished.
  25148. * @returns the current mesh
  25149. */
  25150. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25151. /**
  25152. * Serialize current mesh
  25153. * @param serializationObject defines the object which will receive the serialization data
  25154. */
  25155. serialize(serializationObject: any): void;
  25156. /** @hidden */
  25157. _syncGeometryWithMorphTargetManager(): void;
  25158. /** @hidden */
  25159. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25160. /**
  25161. * Returns a new Mesh object parsed from the source provided.
  25162. * @param parsedMesh is the source
  25163. * @param scene defines the hosting scene
  25164. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25165. * @returns a new Mesh
  25166. */
  25167. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25168. /**
  25169. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25170. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25171. * @param name defines the name of the mesh to create
  25172. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25173. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25174. * @param closePath creates a seam between the first and the last points of each path of the path array
  25175. * @param offset is taken in account only if the `pathArray` is containing a single path
  25176. * @param scene defines the hosting scene
  25177. * @param updatable defines if the mesh must be flagged as updatable
  25178. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25179. * @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)
  25180. * @returns a new Mesh
  25181. */
  25182. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25183. /**
  25184. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25185. * @param name defines the name of the mesh to create
  25186. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25187. * @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
  25188. * @param scene defines the hosting scene
  25189. * @param updatable defines if the mesh must be flagged as updatable
  25190. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25191. * @returns a new Mesh
  25192. */
  25193. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25194. /**
  25195. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25196. * @param name defines the name of the mesh to create
  25197. * @param size sets the size (float) of each box side (default 1)
  25198. * @param scene defines the hosting scene
  25199. * @param updatable defines if the mesh must be flagged as updatable
  25200. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25201. * @returns a new Mesh
  25202. */
  25203. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25204. /**
  25205. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25206. * @param name defines the name of the mesh to create
  25207. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25208. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25209. * @param scene defines the hosting scene
  25210. * @param updatable defines if the mesh must be flagged as updatable
  25211. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25212. * @returns a new Mesh
  25213. */
  25214. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25215. /**
  25216. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25217. * @param name defines the name of the mesh to create
  25218. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25219. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25220. * @param scene defines the hosting scene
  25221. * @returns a new Mesh
  25222. */
  25223. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25224. /**
  25225. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25226. * @param name defines the name of the mesh to create
  25227. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25228. * @param diameterTop set the top cap diameter (floats, default 1)
  25229. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25230. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25231. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25232. * @param scene defines the hosting scene
  25233. * @param updatable defines if the mesh must be flagged as updatable
  25234. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25235. * @returns a new Mesh
  25236. */
  25237. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25238. /**
  25239. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25240. * @param name defines the name of the mesh to create
  25241. * @param diameter sets the diameter size (float) of the torus (default 1)
  25242. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25243. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25244. * @param scene defines the hosting scene
  25245. * @param updatable defines if the mesh must be flagged as updatable
  25246. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25247. * @returns a new Mesh
  25248. */
  25249. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25250. /**
  25251. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25252. * @param name defines the name of the mesh to create
  25253. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25254. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25255. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25256. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25257. * @param p the number of windings on X axis (positive integers, default 2)
  25258. * @param q the number of windings on Y axis (positive integers, default 3)
  25259. * @param scene defines the hosting scene
  25260. * @param updatable defines if the mesh must be flagged as updatable
  25261. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25262. * @returns a new Mesh
  25263. */
  25264. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25265. /**
  25266. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25267. * @param name defines the name of the mesh to create
  25268. * @param points is an array successive Vector3
  25269. * @param scene defines the hosting scene
  25270. * @param updatable defines if the mesh must be flagged as updatable
  25271. * @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).
  25272. * @returns a new Mesh
  25273. */
  25274. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25275. /**
  25276. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25277. * @param name defines the name of the mesh to create
  25278. * @param points is an array successive Vector3
  25279. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25280. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25281. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25282. * @param scene defines the hosting scene
  25283. * @param updatable defines if the mesh must be flagged as updatable
  25284. * @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)
  25285. * @returns a new Mesh
  25286. */
  25287. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25288. /**
  25289. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25290. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25291. * 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.
  25292. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25293. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25294. * Remember you can only change the shape positions, not their number when updating a polygon.
  25295. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25296. * @param name defines the name of the mesh to create
  25297. * @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
  25298. * @param scene defines the hosting scene
  25299. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25300. * @param updatable defines if the mesh must be flagged as updatable
  25301. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25302. * @param earcutInjection can be used to inject your own earcut reference
  25303. * @returns a new Mesh
  25304. */
  25305. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25306. /**
  25307. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25308. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25309. * @param name defines the name of the mesh to create
  25310. * @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
  25311. * @param depth defines the height of extrusion
  25312. * @param scene defines the hosting scene
  25313. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25314. * @param updatable defines if the mesh must be flagged as updatable
  25315. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25316. * @param earcutInjection can be used to inject your own earcut reference
  25317. * @returns a new Mesh
  25318. */
  25319. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25320. /**
  25321. * Creates an extruded shape mesh.
  25322. * 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
  25323. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25324. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25325. * @param name defines the name of the mesh to create
  25326. * @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
  25327. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25328. * @param scale is the value to scale the shape
  25329. * @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
  25330. * @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
  25331. * @param scene defines the hosting scene
  25332. * @param updatable defines if the mesh must be flagged as updatable
  25333. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25334. * @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)
  25335. * @returns a new Mesh
  25336. */
  25337. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25338. /**
  25339. * Creates an custom extruded shape mesh.
  25340. * The custom extrusion is a parametric shape.
  25341. * It has no predefined shape. Its final shape will depend on the input parameters.
  25342. * Please consider using the same method from the MeshBuilder class instead
  25343. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25344. * @param name defines the name of the mesh to create
  25345. * @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
  25346. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25347. * @param scaleFunction is a custom Javascript function called on each path point
  25348. * @param rotationFunction is a custom Javascript function called on each path point
  25349. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25350. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25351. * @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
  25352. * @param scene defines the hosting scene
  25353. * @param updatable defines if the mesh must be flagged as updatable
  25354. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25355. * @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)
  25356. * @returns a new Mesh
  25357. */
  25358. 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;
  25359. /**
  25360. * Creates lathe mesh.
  25361. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25362. * Please consider using the same method from the MeshBuilder class instead
  25363. * @param name defines the name of the mesh to create
  25364. * @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
  25365. * @param radius is the radius value of the lathe
  25366. * @param tessellation is the side number of the lathe.
  25367. * @param scene defines the hosting scene
  25368. * @param updatable defines if the mesh must be flagged as updatable
  25369. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25370. * @returns a new Mesh
  25371. */
  25372. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25373. /**
  25374. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25375. * @param name defines the name of the mesh to create
  25376. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25377. * @param scene defines the hosting scene
  25378. * @param updatable defines if the mesh must be flagged as updatable
  25379. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25380. * @returns a new Mesh
  25381. */
  25382. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25383. /**
  25384. * Creates a ground mesh.
  25385. * Please consider using the same method from the MeshBuilder class instead
  25386. * @param name defines the name of the mesh to create
  25387. * @param width set the width of the ground
  25388. * @param height set the height of the ground
  25389. * @param subdivisions sets the number of subdivisions per side
  25390. * @param scene defines the hosting scene
  25391. * @param updatable defines if the mesh must be flagged as updatable
  25392. * @returns a new Mesh
  25393. */
  25394. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25395. /**
  25396. * Creates a tiled ground mesh.
  25397. * Please consider using the same method from the MeshBuilder class instead
  25398. * @param name defines the name of the mesh to create
  25399. * @param xmin set the ground minimum X coordinate
  25400. * @param zmin set the ground minimum Y coordinate
  25401. * @param xmax set the ground maximum X coordinate
  25402. * @param zmax set the ground maximum Z coordinate
  25403. * @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
  25404. * @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
  25405. * @param scene defines the hosting scene
  25406. * @param updatable defines if the mesh must be flagged as updatable
  25407. * @returns a new Mesh
  25408. */
  25409. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25410. w: number;
  25411. h: number;
  25412. }, precision: {
  25413. w: number;
  25414. h: number;
  25415. }, scene: Scene, updatable?: boolean): Mesh;
  25416. /**
  25417. * Creates a ground mesh from a height map.
  25418. * Please consider using the same method from the MeshBuilder class instead
  25419. * @see http://doc.babylonjs.com/babylon101/height_map
  25420. * @param name defines the name of the mesh to create
  25421. * @param url sets the URL of the height map image resource
  25422. * @param width set the ground width size
  25423. * @param height set the ground height size
  25424. * @param subdivisions sets the number of subdivision per side
  25425. * @param minHeight is the minimum altitude on the ground
  25426. * @param maxHeight is the maximum altitude on the ground
  25427. * @param scene defines the hosting scene
  25428. * @param updatable defines if the mesh must be flagged as updatable
  25429. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25430. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25431. * @returns a new Mesh
  25432. */
  25433. 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;
  25434. /**
  25435. * Creates a tube mesh.
  25436. * The tube is a parametric shape.
  25437. * It has no predefined shape. Its final shape will depend on the input parameters.
  25438. * Please consider using the same method from the MeshBuilder class instead
  25439. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25440. * @param name defines the name of the mesh to create
  25441. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25442. * @param radius sets the tube radius size
  25443. * @param tessellation is the number of sides on the tubular surface
  25444. * @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
  25445. * @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
  25446. * @param scene defines the hosting scene
  25447. * @param updatable defines if the mesh must be flagged as updatable
  25448. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25449. * @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)
  25450. * @returns a new Mesh
  25451. */
  25452. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25453. (i: number, distance: number): number;
  25454. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25455. /**
  25456. * Creates a polyhedron mesh.
  25457. * Please consider using the same method from the MeshBuilder class instead.
  25458. * * 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
  25459. * * The parameter `size` (positive float, default 1) sets the polygon size
  25460. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25461. * * 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`
  25462. * * 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
  25463. * * 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)`)
  25464. * * 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
  25465. * * 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
  25466. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25467. * * 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
  25468. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25469. * @param name defines the name of the mesh to create
  25470. * @param options defines the options used to create the mesh
  25471. * @param scene defines the hosting scene
  25472. * @returns a new Mesh
  25473. */
  25474. static CreatePolyhedron(name: string, options: {
  25475. type?: number;
  25476. size?: number;
  25477. sizeX?: number;
  25478. sizeY?: number;
  25479. sizeZ?: number;
  25480. custom?: any;
  25481. faceUV?: Vector4[];
  25482. faceColors?: Color4[];
  25483. updatable?: boolean;
  25484. sideOrientation?: number;
  25485. }, scene: Scene): Mesh;
  25486. /**
  25487. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25488. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25489. * * 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`)
  25490. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25491. * * 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
  25492. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25493. * * 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
  25494. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25495. * @param name defines the name of the mesh
  25496. * @param options defines the options used to create the mesh
  25497. * @param scene defines the hosting scene
  25498. * @returns a new Mesh
  25499. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25500. */
  25501. static CreateIcoSphere(name: string, options: {
  25502. radius?: number;
  25503. flat?: boolean;
  25504. subdivisions?: number;
  25505. sideOrientation?: number;
  25506. updatable?: boolean;
  25507. }, scene: Scene): Mesh;
  25508. /**
  25509. * Creates a decal mesh.
  25510. * Please consider using the same method from the MeshBuilder class instead.
  25511. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25512. * @param name defines the name of the mesh
  25513. * @param sourceMesh defines the mesh receiving the decal
  25514. * @param position sets the position of the decal in world coordinates
  25515. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25516. * @param size sets the decal scaling
  25517. * @param angle sets the angle to rotate the decal
  25518. * @returns a new Mesh
  25519. */
  25520. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25521. /**
  25522. * Prepare internal position array for software CPU skinning
  25523. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25524. */
  25525. setPositionsForCPUSkinning(): Float32Array;
  25526. /**
  25527. * Prepare internal normal array for software CPU skinning
  25528. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25529. */
  25530. setNormalsForCPUSkinning(): Float32Array;
  25531. /**
  25532. * Updates the vertex buffer by applying transformation from the bones
  25533. * @param skeleton defines the skeleton to apply to current mesh
  25534. * @returns the current mesh
  25535. */
  25536. applySkeleton(skeleton: Skeleton): Mesh;
  25537. /**
  25538. * 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
  25539. * @param meshes defines the list of meshes to scan
  25540. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25541. */
  25542. static MinMax(meshes: AbstractMesh[]): {
  25543. min: Vector3;
  25544. max: Vector3;
  25545. };
  25546. /**
  25547. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25548. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25549. * @returns a vector3
  25550. */
  25551. static Center(meshesOrMinMaxVector: {
  25552. min: Vector3;
  25553. max: Vector3;
  25554. } | AbstractMesh[]): Vector3;
  25555. /**
  25556. * Merge the array of meshes into a single mesh for performance reasons.
  25557. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25558. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25559. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25560. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25561. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25562. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25563. * @returns a new mesh
  25564. */
  25565. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25566. /** @hidden */
  25567. addInstance(instance: InstancedMesh): void;
  25568. /** @hidden */
  25569. removeInstance(instance: InstancedMesh): void;
  25570. }
  25571. }
  25572. declare module BABYLON {
  25573. /**
  25574. * This is the base class of all the camera used in the application.
  25575. * @see http://doc.babylonjs.com/features/cameras
  25576. */
  25577. export class Camera extends Node {
  25578. /** @hidden */
  25579. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25580. /**
  25581. * This is the default projection mode used by the cameras.
  25582. * It helps recreating a feeling of perspective and better appreciate depth.
  25583. * This is the best way to simulate real life cameras.
  25584. */
  25585. static readonly PERSPECTIVE_CAMERA: number;
  25586. /**
  25587. * This helps creating camera with an orthographic mode.
  25588. * 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.
  25589. */
  25590. static readonly ORTHOGRAPHIC_CAMERA: number;
  25591. /**
  25592. * This is the default FOV mode for perspective cameras.
  25593. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25594. */
  25595. static readonly FOVMODE_VERTICAL_FIXED: number;
  25596. /**
  25597. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25598. */
  25599. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25600. /**
  25601. * This specifies ther is no need for a camera rig.
  25602. * Basically only one eye is rendered corresponding to the camera.
  25603. */
  25604. static readonly RIG_MODE_NONE: number;
  25605. /**
  25606. * Simulates a camera Rig with one blue eye and one red eye.
  25607. * This can be use with 3d blue and red glasses.
  25608. */
  25609. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25610. /**
  25611. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25612. */
  25613. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25614. /**
  25615. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25616. */
  25617. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25618. /**
  25619. * Defines that both eyes of the camera will be rendered over under each other.
  25620. */
  25621. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25622. /**
  25623. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  25624. */
  25625. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  25626. /**
  25627. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25628. */
  25629. static readonly RIG_MODE_VR: number;
  25630. /**
  25631. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25632. */
  25633. static readonly RIG_MODE_WEBVR: number;
  25634. /**
  25635. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25636. */
  25637. static readonly RIG_MODE_CUSTOM: number;
  25638. /**
  25639. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25640. */
  25641. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25642. /**
  25643. * Define the input manager associated with the camera.
  25644. */
  25645. inputs: CameraInputsManager<Camera>;
  25646. /** @hidden */
  25647. _position: Vector3;
  25648. /**
  25649. * Define the current local position of the camera in the scene
  25650. */
  25651. get position(): Vector3;
  25652. set position(newPosition: Vector3);
  25653. /**
  25654. * The vector the camera should consider as up.
  25655. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25656. */
  25657. upVector: Vector3;
  25658. /**
  25659. * Define the current limit on the left side for an orthographic camera
  25660. * In scene unit
  25661. */
  25662. orthoLeft: Nullable<number>;
  25663. /**
  25664. * Define the current limit on the right side for an orthographic camera
  25665. * In scene unit
  25666. */
  25667. orthoRight: Nullable<number>;
  25668. /**
  25669. * Define the current limit on the bottom side for an orthographic camera
  25670. * In scene unit
  25671. */
  25672. orthoBottom: Nullable<number>;
  25673. /**
  25674. * Define the current limit on the top side for an orthographic camera
  25675. * In scene unit
  25676. */
  25677. orthoTop: Nullable<number>;
  25678. /**
  25679. * Field Of View is set in Radians. (default is 0.8)
  25680. */
  25681. fov: number;
  25682. /**
  25683. * Define the minimum distance the camera can see from.
  25684. * This is important to note that the depth buffer are not infinite and the closer it starts
  25685. * the more your scene might encounter depth fighting issue.
  25686. */
  25687. minZ: number;
  25688. /**
  25689. * Define the maximum distance the camera can see to.
  25690. * This is important to note that the depth buffer are not infinite and the further it end
  25691. * the more your scene might encounter depth fighting issue.
  25692. */
  25693. maxZ: number;
  25694. /**
  25695. * Define the default inertia of the camera.
  25696. * This helps giving a smooth feeling to the camera movement.
  25697. */
  25698. inertia: number;
  25699. /**
  25700. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25701. */
  25702. mode: number;
  25703. /**
  25704. * Define whether the camera is intermediate.
  25705. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25706. */
  25707. isIntermediate: boolean;
  25708. /**
  25709. * Define the viewport of the camera.
  25710. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25711. */
  25712. viewport: Viewport;
  25713. /**
  25714. * Restricts the camera to viewing objects with the same layerMask.
  25715. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25716. */
  25717. layerMask: number;
  25718. /**
  25719. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25720. */
  25721. fovMode: number;
  25722. /**
  25723. * Rig mode of the camera.
  25724. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25725. * This is normally controlled byt the camera themselves as internal use.
  25726. */
  25727. cameraRigMode: number;
  25728. /**
  25729. * Defines the distance between both "eyes" in case of a RIG
  25730. */
  25731. interaxialDistance: number;
  25732. /**
  25733. * Defines if stereoscopic rendering is done side by side or over under.
  25734. */
  25735. isStereoscopicSideBySide: boolean;
  25736. /**
  25737. * 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
  25738. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25739. * else in the scene. (Eg. security camera)
  25740. *
  25741. * 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)
  25742. */
  25743. customRenderTargets: RenderTargetTexture[];
  25744. /**
  25745. * When set, the camera will render to this render target instead of the default canvas
  25746. *
  25747. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25748. */
  25749. outputRenderTarget: Nullable<RenderTargetTexture>;
  25750. /**
  25751. * Observable triggered when the camera view matrix has changed.
  25752. */
  25753. onViewMatrixChangedObservable: Observable<Camera>;
  25754. /**
  25755. * Observable triggered when the camera Projection matrix has changed.
  25756. */
  25757. onProjectionMatrixChangedObservable: Observable<Camera>;
  25758. /**
  25759. * Observable triggered when the inputs have been processed.
  25760. */
  25761. onAfterCheckInputsObservable: Observable<Camera>;
  25762. /**
  25763. * Observable triggered when reset has been called and applied to the camera.
  25764. */
  25765. onRestoreStateObservable: Observable<Camera>;
  25766. /**
  25767. * Is this camera a part of a rig system?
  25768. */
  25769. isRigCamera: boolean;
  25770. /**
  25771. * If isRigCamera set to true this will be set with the parent camera.
  25772. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  25773. */
  25774. rigParent?: Camera;
  25775. /** @hidden */
  25776. _cameraRigParams: any;
  25777. /** @hidden */
  25778. _rigCameras: Camera[];
  25779. /** @hidden */
  25780. _rigPostProcess: Nullable<PostProcess>;
  25781. protected _webvrViewMatrix: Matrix;
  25782. /** @hidden */
  25783. _skipRendering: boolean;
  25784. /** @hidden */
  25785. _projectionMatrix: Matrix;
  25786. /** @hidden */
  25787. _postProcesses: Nullable<PostProcess>[];
  25788. /** @hidden */
  25789. _activeMeshes: SmartArray<AbstractMesh>;
  25790. protected _globalPosition: Vector3;
  25791. /** @hidden */
  25792. _computedViewMatrix: Matrix;
  25793. private _doNotComputeProjectionMatrix;
  25794. private _transformMatrix;
  25795. private _frustumPlanes;
  25796. private _refreshFrustumPlanes;
  25797. private _storedFov;
  25798. private _stateStored;
  25799. /**
  25800. * Instantiates a new camera object.
  25801. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25802. * @see http://doc.babylonjs.com/features/cameras
  25803. * @param name Defines the name of the camera in the scene
  25804. * @param position Defines the position of the camera
  25805. * @param scene Defines the scene the camera belongs too
  25806. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25807. */
  25808. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25809. /**
  25810. * Store current camera state (fov, position, etc..)
  25811. * @returns the camera
  25812. */
  25813. storeState(): Camera;
  25814. /**
  25815. * Restores the camera state values if it has been stored. You must call storeState() first
  25816. */
  25817. protected _restoreStateValues(): boolean;
  25818. /**
  25819. * Restored camera state. You must call storeState() first.
  25820. * @returns true if restored and false otherwise
  25821. */
  25822. restoreState(): boolean;
  25823. /**
  25824. * Gets the class name of the camera.
  25825. * @returns the class name
  25826. */
  25827. getClassName(): string;
  25828. /** @hidden */
  25829. readonly _isCamera: boolean;
  25830. /**
  25831. * Gets a string representation of the camera useful for debug purpose.
  25832. * @param fullDetails Defines that a more verboe level of logging is required
  25833. * @returns the string representation
  25834. */
  25835. toString(fullDetails?: boolean): string;
  25836. /**
  25837. * Gets the current world space position of the camera.
  25838. */
  25839. get globalPosition(): Vector3;
  25840. /**
  25841. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25842. * @returns the active meshe list
  25843. */
  25844. getActiveMeshes(): SmartArray<AbstractMesh>;
  25845. /**
  25846. * Check whether a mesh is part of the current active mesh list of the camera
  25847. * @param mesh Defines the mesh to check
  25848. * @returns true if active, false otherwise
  25849. */
  25850. isActiveMesh(mesh: Mesh): boolean;
  25851. /**
  25852. * Is this camera ready to be used/rendered
  25853. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25854. * @return true if the camera is ready
  25855. */
  25856. isReady(completeCheck?: boolean): boolean;
  25857. /** @hidden */
  25858. _initCache(): void;
  25859. /** @hidden */
  25860. _updateCache(ignoreParentClass?: boolean): void;
  25861. /** @hidden */
  25862. _isSynchronized(): boolean;
  25863. /** @hidden */
  25864. _isSynchronizedViewMatrix(): boolean;
  25865. /** @hidden */
  25866. _isSynchronizedProjectionMatrix(): boolean;
  25867. /**
  25868. * Attach the input controls to a specific dom element to get the input from.
  25869. * @param element Defines the element the controls should be listened from
  25870. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25871. */
  25872. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25873. /**
  25874. * Detach the current controls from the specified dom element.
  25875. * @param element Defines the element to stop listening the inputs from
  25876. */
  25877. detachControl(element: HTMLElement): void;
  25878. /**
  25879. * Update the camera state according to the different inputs gathered during the frame.
  25880. */
  25881. update(): void;
  25882. /** @hidden */
  25883. _checkInputs(): void;
  25884. /** @hidden */
  25885. get rigCameras(): Camera[];
  25886. /**
  25887. * Gets the post process used by the rig cameras
  25888. */
  25889. get rigPostProcess(): Nullable<PostProcess>;
  25890. /**
  25891. * Internal, gets the first post proces.
  25892. * @returns the first post process to be run on this camera.
  25893. */
  25894. _getFirstPostProcess(): Nullable<PostProcess>;
  25895. private _cascadePostProcessesToRigCams;
  25896. /**
  25897. * Attach a post process to the camera.
  25898. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25899. * @param postProcess The post process to attach to the camera
  25900. * @param insertAt The position of the post process in case several of them are in use in the scene
  25901. * @returns the position the post process has been inserted at
  25902. */
  25903. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25904. /**
  25905. * Detach a post process to the camera.
  25906. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25907. * @param postProcess The post process to detach from the camera
  25908. */
  25909. detachPostProcess(postProcess: PostProcess): void;
  25910. /**
  25911. * Gets the current world matrix of the camera
  25912. */
  25913. getWorldMatrix(): Matrix;
  25914. /** @hidden */
  25915. _getViewMatrix(): Matrix;
  25916. /**
  25917. * Gets the current view matrix of the camera.
  25918. * @param force forces the camera to recompute the matrix without looking at the cached state
  25919. * @returns the view matrix
  25920. */
  25921. getViewMatrix(force?: boolean): Matrix;
  25922. /**
  25923. * Freeze the projection matrix.
  25924. * It will prevent the cache check of the camera projection compute and can speed up perf
  25925. * if no parameter of the camera are meant to change
  25926. * @param projection Defines manually a projection if necessary
  25927. */
  25928. freezeProjectionMatrix(projection?: Matrix): void;
  25929. /**
  25930. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25931. */
  25932. unfreezeProjectionMatrix(): void;
  25933. /**
  25934. * Gets the current projection matrix of the camera.
  25935. * @param force forces the camera to recompute the matrix without looking at the cached state
  25936. * @returns the projection matrix
  25937. */
  25938. getProjectionMatrix(force?: boolean): Matrix;
  25939. /**
  25940. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25941. * @returns a Matrix
  25942. */
  25943. getTransformationMatrix(): Matrix;
  25944. private _updateFrustumPlanes;
  25945. /**
  25946. * Checks if a cullable object (mesh...) is in the camera frustum
  25947. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25948. * @param target The object to check
  25949. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25950. * @returns true if the object is in frustum otherwise false
  25951. */
  25952. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25953. /**
  25954. * Checks if a cullable object (mesh...) is in the camera frustum
  25955. * Unlike isInFrustum this cheks the full bounding box
  25956. * @param target The object to check
  25957. * @returns true if the object is in frustum otherwise false
  25958. */
  25959. isCompletelyInFrustum(target: ICullable): boolean;
  25960. /**
  25961. * Gets a ray in the forward direction from the camera.
  25962. * @param length Defines the length of the ray to create
  25963. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25964. * @param origin Defines the start point of the ray which defaults to the camera position
  25965. * @returns the forward ray
  25966. */
  25967. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25968. /**
  25969. * Releases resources associated with this node.
  25970. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25971. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25972. */
  25973. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25974. /** @hidden */
  25975. _isLeftCamera: boolean;
  25976. /**
  25977. * Gets the left camera of a rig setup in case of Rigged Camera
  25978. */
  25979. get isLeftCamera(): boolean;
  25980. /** @hidden */
  25981. _isRightCamera: boolean;
  25982. /**
  25983. * Gets the right camera of a rig setup in case of Rigged Camera
  25984. */
  25985. get isRightCamera(): boolean;
  25986. /**
  25987. * Gets the left camera of a rig setup in case of Rigged Camera
  25988. */
  25989. get leftCamera(): Nullable<FreeCamera>;
  25990. /**
  25991. * Gets the right camera of a rig setup in case of Rigged Camera
  25992. */
  25993. get rightCamera(): Nullable<FreeCamera>;
  25994. /**
  25995. * Gets the left camera target of a rig setup in case of Rigged Camera
  25996. * @returns the target position
  25997. */
  25998. getLeftTarget(): Nullable<Vector3>;
  25999. /**
  26000. * Gets the right camera target of a rig setup in case of Rigged Camera
  26001. * @returns the target position
  26002. */
  26003. getRightTarget(): Nullable<Vector3>;
  26004. /**
  26005. * @hidden
  26006. */
  26007. setCameraRigMode(mode: number, rigParams: any): void;
  26008. /** @hidden */
  26009. static _setStereoscopicRigMode(camera: Camera): void;
  26010. /** @hidden */
  26011. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26012. /** @hidden */
  26013. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26014. /** @hidden */
  26015. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26016. /** @hidden */
  26017. _getVRProjectionMatrix(): Matrix;
  26018. protected _updateCameraRotationMatrix(): void;
  26019. protected _updateWebVRCameraRotationMatrix(): void;
  26020. /**
  26021. * This function MUST be overwritten by the different WebVR cameras available.
  26022. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26023. * @hidden
  26024. */
  26025. _getWebVRProjectionMatrix(): Matrix;
  26026. /**
  26027. * This function MUST be overwritten by the different WebVR cameras available.
  26028. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26029. * @hidden
  26030. */
  26031. _getWebVRViewMatrix(): Matrix;
  26032. /** @hidden */
  26033. setCameraRigParameter(name: string, value: any): void;
  26034. /**
  26035. * needs to be overridden by children so sub has required properties to be copied
  26036. * @hidden
  26037. */
  26038. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26039. /**
  26040. * May need to be overridden by children
  26041. * @hidden
  26042. */
  26043. _updateRigCameras(): void;
  26044. /** @hidden */
  26045. _setupInputs(): void;
  26046. /**
  26047. * Serialiaze the camera setup to a json represention
  26048. * @returns the JSON representation
  26049. */
  26050. serialize(): any;
  26051. /**
  26052. * Clones the current camera.
  26053. * @param name The cloned camera name
  26054. * @returns the cloned camera
  26055. */
  26056. clone(name: string): Camera;
  26057. /**
  26058. * Gets the direction of the camera relative to a given local axis.
  26059. * @param localAxis Defines the reference axis to provide a relative direction.
  26060. * @return the direction
  26061. */
  26062. getDirection(localAxis: Vector3): Vector3;
  26063. /**
  26064. * Returns the current camera absolute rotation
  26065. */
  26066. get absoluteRotation(): Quaternion;
  26067. /**
  26068. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26069. * @param localAxis Defines the reference axis to provide a relative direction.
  26070. * @param result Defines the vector to store the result in
  26071. */
  26072. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26073. /**
  26074. * Gets a camera constructor for a given camera type
  26075. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26076. * @param name The name of the camera the result will be able to instantiate
  26077. * @param scene The scene the result will construct the camera in
  26078. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26079. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26080. * @returns a factory method to construc the camera
  26081. */
  26082. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26083. /**
  26084. * Compute the world matrix of the camera.
  26085. * @returns the camera world matrix
  26086. */
  26087. computeWorldMatrix(): Matrix;
  26088. /**
  26089. * Parse a JSON and creates the camera from the parsed information
  26090. * @param parsedCamera The JSON to parse
  26091. * @param scene The scene to instantiate the camera in
  26092. * @returns the newly constructed camera
  26093. */
  26094. static Parse(parsedCamera: any, scene: Scene): Camera;
  26095. }
  26096. }
  26097. declare module BABYLON {
  26098. /**
  26099. * Class containing static functions to help procedurally build meshes
  26100. */
  26101. export class DiscBuilder {
  26102. /**
  26103. * Creates a plane polygonal mesh. By default, this is a disc
  26104. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26105. * * 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
  26106. * * 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
  26107. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26108. * * 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
  26109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26110. * @param name defines the name of the mesh
  26111. * @param options defines the options used to create the mesh
  26112. * @param scene defines the hosting scene
  26113. * @returns the plane polygonal mesh
  26114. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26115. */
  26116. static CreateDisc(name: string, options: {
  26117. radius?: number;
  26118. tessellation?: number;
  26119. arc?: number;
  26120. updatable?: boolean;
  26121. sideOrientation?: number;
  26122. frontUVs?: Vector4;
  26123. backUVs?: Vector4;
  26124. }, scene?: Nullable<Scene>): Mesh;
  26125. }
  26126. }
  26127. declare module BABYLON {
  26128. /**
  26129. * Options to be used when creating a FresnelParameters.
  26130. */
  26131. export type IFresnelParametersCreationOptions = {
  26132. /**
  26133. * Define the color used on edges (grazing angle)
  26134. */
  26135. leftColor?: Color3;
  26136. /**
  26137. * Define the color used on center
  26138. */
  26139. rightColor?: Color3;
  26140. /**
  26141. * Define bias applied to computed fresnel term
  26142. */
  26143. bias?: number;
  26144. /**
  26145. * Defined the power exponent applied to fresnel term
  26146. */
  26147. power?: number;
  26148. /**
  26149. * Define if the fresnel effect is enable or not.
  26150. */
  26151. isEnabled?: boolean;
  26152. };
  26153. /**
  26154. * Serialized format for FresnelParameters.
  26155. */
  26156. export type IFresnelParametersSerialized = {
  26157. /**
  26158. * Define the color used on edges (grazing angle) [as an array]
  26159. */
  26160. leftColor: number[];
  26161. /**
  26162. * Define the color used on center [as an array]
  26163. */
  26164. rightColor: number[];
  26165. /**
  26166. * Define bias applied to computed fresnel term
  26167. */
  26168. bias: number;
  26169. /**
  26170. * Defined the power exponent applied to fresnel term
  26171. */
  26172. power?: number;
  26173. /**
  26174. * Define if the fresnel effect is enable or not.
  26175. */
  26176. isEnabled: boolean;
  26177. };
  26178. /**
  26179. * This represents all the required information to add a fresnel effect on a material:
  26180. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26181. */
  26182. export class FresnelParameters {
  26183. private _isEnabled;
  26184. /**
  26185. * Define if the fresnel effect is enable or not.
  26186. */
  26187. get isEnabled(): boolean;
  26188. set isEnabled(value: boolean);
  26189. /**
  26190. * Define the color used on edges (grazing angle)
  26191. */
  26192. leftColor: Color3;
  26193. /**
  26194. * Define the color used on center
  26195. */
  26196. rightColor: Color3;
  26197. /**
  26198. * Define bias applied to computed fresnel term
  26199. */
  26200. bias: number;
  26201. /**
  26202. * Defined the power exponent applied to fresnel term
  26203. */
  26204. power: number;
  26205. /**
  26206. * Creates a new FresnelParameters object.
  26207. *
  26208. * @param options provide your own settings to optionally to override defaults
  26209. */
  26210. constructor(options?: IFresnelParametersCreationOptions);
  26211. /**
  26212. * Clones the current fresnel and its valuues
  26213. * @returns a clone fresnel configuration
  26214. */
  26215. clone(): FresnelParameters;
  26216. /**
  26217. * Determines equality between FresnelParameters objects
  26218. * @param otherFresnelParameters defines the second operand
  26219. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  26220. */
  26221. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  26222. /**
  26223. * Serializes the current fresnel parameters to a JSON representation.
  26224. * @return the JSON serialization
  26225. */
  26226. serialize(): IFresnelParametersSerialized;
  26227. /**
  26228. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26229. * @param parsedFresnelParameters Define the JSON representation
  26230. * @returns the parsed parameters
  26231. */
  26232. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  26233. }
  26234. }
  26235. declare module BABYLON {
  26236. /**
  26237. * Base class of materials working in push mode in babylon JS
  26238. * @hidden
  26239. */
  26240. export class PushMaterial extends Material {
  26241. protected _activeEffect: Effect;
  26242. protected _normalMatrix: Matrix;
  26243. /**
  26244. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26245. * This means that the material can keep using a previous shader while a new one is being compiled.
  26246. * This is mostly used when shader parallel compilation is supported (true by default)
  26247. */
  26248. allowShaderHotSwapping: boolean;
  26249. constructor(name: string, scene: Scene);
  26250. getEffect(): Effect;
  26251. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26252. /**
  26253. * Binds the given world matrix to the active effect
  26254. *
  26255. * @param world the matrix to bind
  26256. */
  26257. bindOnlyWorldMatrix(world: Matrix): void;
  26258. /**
  26259. * Binds the given normal matrix to the active effect
  26260. *
  26261. * @param normalMatrix the matrix to bind
  26262. */
  26263. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26264. bind(world: Matrix, mesh?: Mesh): void;
  26265. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26266. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26267. }
  26268. }
  26269. declare module BABYLON {
  26270. /**
  26271. * This groups all the flags used to control the materials channel.
  26272. */
  26273. export class MaterialFlags {
  26274. private static _DiffuseTextureEnabled;
  26275. /**
  26276. * Are diffuse textures enabled in the application.
  26277. */
  26278. static get DiffuseTextureEnabled(): boolean;
  26279. static set DiffuseTextureEnabled(value: boolean);
  26280. private static _AmbientTextureEnabled;
  26281. /**
  26282. * Are ambient textures enabled in the application.
  26283. */
  26284. static get AmbientTextureEnabled(): boolean;
  26285. static set AmbientTextureEnabled(value: boolean);
  26286. private static _OpacityTextureEnabled;
  26287. /**
  26288. * Are opacity textures enabled in the application.
  26289. */
  26290. static get OpacityTextureEnabled(): boolean;
  26291. static set OpacityTextureEnabled(value: boolean);
  26292. private static _ReflectionTextureEnabled;
  26293. /**
  26294. * Are reflection textures enabled in the application.
  26295. */
  26296. static get ReflectionTextureEnabled(): boolean;
  26297. static set ReflectionTextureEnabled(value: boolean);
  26298. private static _EmissiveTextureEnabled;
  26299. /**
  26300. * Are emissive textures enabled in the application.
  26301. */
  26302. static get EmissiveTextureEnabled(): boolean;
  26303. static set EmissiveTextureEnabled(value: boolean);
  26304. private static _SpecularTextureEnabled;
  26305. /**
  26306. * Are specular textures enabled in the application.
  26307. */
  26308. static get SpecularTextureEnabled(): boolean;
  26309. static set SpecularTextureEnabled(value: boolean);
  26310. private static _BumpTextureEnabled;
  26311. /**
  26312. * Are bump textures enabled in the application.
  26313. */
  26314. static get BumpTextureEnabled(): boolean;
  26315. static set BumpTextureEnabled(value: boolean);
  26316. private static _LightmapTextureEnabled;
  26317. /**
  26318. * Are lightmap textures enabled in the application.
  26319. */
  26320. static get LightmapTextureEnabled(): boolean;
  26321. static set LightmapTextureEnabled(value: boolean);
  26322. private static _RefractionTextureEnabled;
  26323. /**
  26324. * Are refraction textures enabled in the application.
  26325. */
  26326. static get RefractionTextureEnabled(): boolean;
  26327. static set RefractionTextureEnabled(value: boolean);
  26328. private static _ColorGradingTextureEnabled;
  26329. /**
  26330. * Are color grading textures enabled in the application.
  26331. */
  26332. static get ColorGradingTextureEnabled(): boolean;
  26333. static set ColorGradingTextureEnabled(value: boolean);
  26334. private static _FresnelEnabled;
  26335. /**
  26336. * Are fresnels enabled in the application.
  26337. */
  26338. static get FresnelEnabled(): boolean;
  26339. static set FresnelEnabled(value: boolean);
  26340. private static _ClearCoatTextureEnabled;
  26341. /**
  26342. * Are clear coat textures enabled in the application.
  26343. */
  26344. static get ClearCoatTextureEnabled(): boolean;
  26345. static set ClearCoatTextureEnabled(value: boolean);
  26346. private static _ClearCoatBumpTextureEnabled;
  26347. /**
  26348. * Are clear coat bump textures enabled in the application.
  26349. */
  26350. static get ClearCoatBumpTextureEnabled(): boolean;
  26351. static set ClearCoatBumpTextureEnabled(value: boolean);
  26352. private static _ClearCoatTintTextureEnabled;
  26353. /**
  26354. * Are clear coat tint textures enabled in the application.
  26355. */
  26356. static get ClearCoatTintTextureEnabled(): boolean;
  26357. static set ClearCoatTintTextureEnabled(value: boolean);
  26358. private static _SheenTextureEnabled;
  26359. /**
  26360. * Are sheen textures enabled in the application.
  26361. */
  26362. static get SheenTextureEnabled(): boolean;
  26363. static set SheenTextureEnabled(value: boolean);
  26364. private static _AnisotropicTextureEnabled;
  26365. /**
  26366. * Are anisotropic textures enabled in the application.
  26367. */
  26368. static get AnisotropicTextureEnabled(): boolean;
  26369. static set AnisotropicTextureEnabled(value: boolean);
  26370. private static _ThicknessTextureEnabled;
  26371. /**
  26372. * Are thickness textures enabled in the application.
  26373. */
  26374. static get ThicknessTextureEnabled(): boolean;
  26375. static set ThicknessTextureEnabled(value: boolean);
  26376. }
  26377. }
  26378. declare module BABYLON {
  26379. /** @hidden */
  26380. export var defaultFragmentDeclaration: {
  26381. name: string;
  26382. shader: string;
  26383. };
  26384. }
  26385. declare module BABYLON {
  26386. /** @hidden */
  26387. export var defaultUboDeclaration: {
  26388. name: string;
  26389. shader: string;
  26390. };
  26391. }
  26392. declare module BABYLON {
  26393. /** @hidden */
  26394. export var lightFragmentDeclaration: {
  26395. name: string;
  26396. shader: string;
  26397. };
  26398. }
  26399. declare module BABYLON {
  26400. /** @hidden */
  26401. export var lightUboDeclaration: {
  26402. name: string;
  26403. shader: string;
  26404. };
  26405. }
  26406. declare module BABYLON {
  26407. /** @hidden */
  26408. export var lightsFragmentFunctions: {
  26409. name: string;
  26410. shader: string;
  26411. };
  26412. }
  26413. declare module BABYLON {
  26414. /** @hidden */
  26415. export var shadowsFragmentFunctions: {
  26416. name: string;
  26417. shader: string;
  26418. };
  26419. }
  26420. declare module BABYLON {
  26421. /** @hidden */
  26422. export var fresnelFunction: {
  26423. name: string;
  26424. shader: string;
  26425. };
  26426. }
  26427. declare module BABYLON {
  26428. /** @hidden */
  26429. export var reflectionFunction: {
  26430. name: string;
  26431. shader: string;
  26432. };
  26433. }
  26434. declare module BABYLON {
  26435. /** @hidden */
  26436. export var bumpFragmentFunctions: {
  26437. name: string;
  26438. shader: string;
  26439. };
  26440. }
  26441. declare module BABYLON {
  26442. /** @hidden */
  26443. export var logDepthDeclaration: {
  26444. name: string;
  26445. shader: string;
  26446. };
  26447. }
  26448. declare module BABYLON {
  26449. /** @hidden */
  26450. export var bumpFragment: {
  26451. name: string;
  26452. shader: string;
  26453. };
  26454. }
  26455. declare module BABYLON {
  26456. /** @hidden */
  26457. export var depthPrePass: {
  26458. name: string;
  26459. shader: string;
  26460. };
  26461. }
  26462. declare module BABYLON {
  26463. /** @hidden */
  26464. export var lightFragment: {
  26465. name: string;
  26466. shader: string;
  26467. };
  26468. }
  26469. declare module BABYLON {
  26470. /** @hidden */
  26471. export var logDepthFragment: {
  26472. name: string;
  26473. shader: string;
  26474. };
  26475. }
  26476. declare module BABYLON {
  26477. /** @hidden */
  26478. export var defaultPixelShader: {
  26479. name: string;
  26480. shader: string;
  26481. };
  26482. }
  26483. declare module BABYLON {
  26484. /** @hidden */
  26485. export var defaultVertexDeclaration: {
  26486. name: string;
  26487. shader: string;
  26488. };
  26489. }
  26490. declare module BABYLON {
  26491. /** @hidden */
  26492. export var bumpVertexDeclaration: {
  26493. name: string;
  26494. shader: string;
  26495. };
  26496. }
  26497. declare module BABYLON {
  26498. /** @hidden */
  26499. export var bumpVertex: {
  26500. name: string;
  26501. shader: string;
  26502. };
  26503. }
  26504. declare module BABYLON {
  26505. /** @hidden */
  26506. export var fogVertex: {
  26507. name: string;
  26508. shader: string;
  26509. };
  26510. }
  26511. declare module BABYLON {
  26512. /** @hidden */
  26513. export var shadowsVertex: {
  26514. name: string;
  26515. shader: string;
  26516. };
  26517. }
  26518. declare module BABYLON {
  26519. /** @hidden */
  26520. export var pointCloudVertex: {
  26521. name: string;
  26522. shader: string;
  26523. };
  26524. }
  26525. declare module BABYLON {
  26526. /** @hidden */
  26527. export var logDepthVertex: {
  26528. name: string;
  26529. shader: string;
  26530. };
  26531. }
  26532. declare module BABYLON {
  26533. /** @hidden */
  26534. export var defaultVertexShader: {
  26535. name: string;
  26536. shader: string;
  26537. };
  26538. }
  26539. declare module BABYLON {
  26540. /** @hidden */
  26541. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26542. MAINUV1: boolean;
  26543. MAINUV2: boolean;
  26544. DIFFUSE: boolean;
  26545. DIFFUSEDIRECTUV: number;
  26546. AMBIENT: boolean;
  26547. AMBIENTDIRECTUV: number;
  26548. OPACITY: boolean;
  26549. OPACITYDIRECTUV: number;
  26550. OPACITYRGB: boolean;
  26551. REFLECTION: boolean;
  26552. EMISSIVE: boolean;
  26553. EMISSIVEDIRECTUV: number;
  26554. SPECULAR: boolean;
  26555. SPECULARDIRECTUV: number;
  26556. BUMP: boolean;
  26557. BUMPDIRECTUV: number;
  26558. PARALLAX: boolean;
  26559. PARALLAXOCCLUSION: boolean;
  26560. SPECULAROVERALPHA: boolean;
  26561. CLIPPLANE: boolean;
  26562. CLIPPLANE2: boolean;
  26563. CLIPPLANE3: boolean;
  26564. CLIPPLANE4: boolean;
  26565. CLIPPLANE5: boolean;
  26566. CLIPPLANE6: boolean;
  26567. ALPHATEST: boolean;
  26568. DEPTHPREPASS: boolean;
  26569. ALPHAFROMDIFFUSE: boolean;
  26570. POINTSIZE: boolean;
  26571. FOG: boolean;
  26572. SPECULARTERM: boolean;
  26573. DIFFUSEFRESNEL: boolean;
  26574. OPACITYFRESNEL: boolean;
  26575. REFLECTIONFRESNEL: boolean;
  26576. REFRACTIONFRESNEL: boolean;
  26577. EMISSIVEFRESNEL: boolean;
  26578. FRESNEL: boolean;
  26579. NORMAL: boolean;
  26580. UV1: boolean;
  26581. UV2: boolean;
  26582. VERTEXCOLOR: boolean;
  26583. VERTEXALPHA: boolean;
  26584. NUM_BONE_INFLUENCERS: number;
  26585. BonesPerMesh: number;
  26586. BONETEXTURE: boolean;
  26587. INSTANCES: boolean;
  26588. GLOSSINESS: boolean;
  26589. ROUGHNESS: boolean;
  26590. EMISSIVEASILLUMINATION: boolean;
  26591. LINKEMISSIVEWITHDIFFUSE: boolean;
  26592. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26593. LIGHTMAP: boolean;
  26594. LIGHTMAPDIRECTUV: number;
  26595. OBJECTSPACE_NORMALMAP: boolean;
  26596. USELIGHTMAPASSHADOWMAP: boolean;
  26597. REFLECTIONMAP_3D: boolean;
  26598. REFLECTIONMAP_SPHERICAL: boolean;
  26599. REFLECTIONMAP_PLANAR: boolean;
  26600. REFLECTIONMAP_CUBIC: boolean;
  26601. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26602. REFLECTIONMAP_PROJECTION: boolean;
  26603. REFLECTIONMAP_SKYBOX: boolean;
  26604. REFLECTIONMAP_EXPLICIT: boolean;
  26605. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26606. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26607. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26608. INVERTCUBICMAP: boolean;
  26609. LOGARITHMICDEPTH: boolean;
  26610. REFRACTION: boolean;
  26611. REFRACTIONMAP_3D: boolean;
  26612. REFLECTIONOVERALPHA: boolean;
  26613. TWOSIDEDLIGHTING: boolean;
  26614. SHADOWFLOAT: boolean;
  26615. MORPHTARGETS: boolean;
  26616. MORPHTARGETS_NORMAL: boolean;
  26617. MORPHTARGETS_TANGENT: boolean;
  26618. MORPHTARGETS_UV: boolean;
  26619. NUM_MORPH_INFLUENCERS: number;
  26620. NONUNIFORMSCALING: boolean;
  26621. PREMULTIPLYALPHA: boolean;
  26622. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  26623. ALPHABLEND: boolean;
  26624. IMAGEPROCESSING: boolean;
  26625. VIGNETTE: boolean;
  26626. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26627. VIGNETTEBLENDMODEOPAQUE: boolean;
  26628. TONEMAPPING: boolean;
  26629. TONEMAPPING_ACES: boolean;
  26630. CONTRAST: boolean;
  26631. COLORCURVES: boolean;
  26632. COLORGRADING: boolean;
  26633. COLORGRADING3D: boolean;
  26634. SAMPLER3DGREENDEPTH: boolean;
  26635. SAMPLER3DBGRMAP: boolean;
  26636. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26637. MULTIVIEW: boolean;
  26638. /**
  26639. * If the reflection texture on this material is in linear color space
  26640. * @hidden
  26641. */
  26642. IS_REFLECTION_LINEAR: boolean;
  26643. /**
  26644. * If the refraction texture on this material is in linear color space
  26645. * @hidden
  26646. */
  26647. IS_REFRACTION_LINEAR: boolean;
  26648. EXPOSURE: boolean;
  26649. constructor();
  26650. setReflectionMode(modeToEnable: string): void;
  26651. }
  26652. /**
  26653. * This is the default material used in Babylon. It is the best trade off between quality
  26654. * and performances.
  26655. * @see http://doc.babylonjs.com/babylon101/materials
  26656. */
  26657. export class StandardMaterial extends PushMaterial {
  26658. private _diffuseTexture;
  26659. /**
  26660. * The basic texture of the material as viewed under a light.
  26661. */
  26662. diffuseTexture: Nullable<BaseTexture>;
  26663. private _ambientTexture;
  26664. /**
  26665. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26666. */
  26667. ambientTexture: Nullable<BaseTexture>;
  26668. private _opacityTexture;
  26669. /**
  26670. * Define the transparency of the material from a texture.
  26671. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26672. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26673. */
  26674. opacityTexture: Nullable<BaseTexture>;
  26675. private _reflectionTexture;
  26676. /**
  26677. * Define the texture used to display the reflection.
  26678. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26679. */
  26680. reflectionTexture: Nullable<BaseTexture>;
  26681. private _emissiveTexture;
  26682. /**
  26683. * Define texture of the material as if self lit.
  26684. * This will be mixed in the final result even in the absence of light.
  26685. */
  26686. emissiveTexture: Nullable<BaseTexture>;
  26687. private _specularTexture;
  26688. /**
  26689. * Define how the color and intensity of the highlight given by the light in the material.
  26690. */
  26691. specularTexture: Nullable<BaseTexture>;
  26692. private _bumpTexture;
  26693. /**
  26694. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26695. * 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.
  26696. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26697. */
  26698. bumpTexture: Nullable<BaseTexture>;
  26699. private _lightmapTexture;
  26700. /**
  26701. * Complex lighting can be computationally expensive to compute at runtime.
  26702. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26703. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26704. */
  26705. lightmapTexture: Nullable<BaseTexture>;
  26706. private _refractionTexture;
  26707. /**
  26708. * Define the texture used to display the refraction.
  26709. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26710. */
  26711. refractionTexture: Nullable<BaseTexture>;
  26712. /**
  26713. * The color of the material lit by the environmental background lighting.
  26714. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26715. */
  26716. ambientColor: Color3;
  26717. /**
  26718. * The basic color of the material as viewed under a light.
  26719. */
  26720. diffuseColor: Color3;
  26721. /**
  26722. * Define how the color and intensity of the highlight given by the light in the material.
  26723. */
  26724. specularColor: Color3;
  26725. /**
  26726. * Define the color of the material as if self lit.
  26727. * This will be mixed in the final result even in the absence of light.
  26728. */
  26729. emissiveColor: Color3;
  26730. /**
  26731. * Defines how sharp are the highlights in the material.
  26732. * The bigger the value the sharper giving a more glossy feeling to the result.
  26733. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26734. */
  26735. specularPower: number;
  26736. private _useAlphaFromDiffuseTexture;
  26737. /**
  26738. * Does the transparency come from the diffuse texture alpha channel.
  26739. */
  26740. useAlphaFromDiffuseTexture: boolean;
  26741. private _useEmissiveAsIllumination;
  26742. /**
  26743. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26744. */
  26745. useEmissiveAsIllumination: boolean;
  26746. private _linkEmissiveWithDiffuse;
  26747. /**
  26748. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26749. * the emissive level when the final color is close to one.
  26750. */
  26751. linkEmissiveWithDiffuse: boolean;
  26752. private _useSpecularOverAlpha;
  26753. /**
  26754. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26755. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26756. */
  26757. useSpecularOverAlpha: boolean;
  26758. private _useReflectionOverAlpha;
  26759. /**
  26760. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26761. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26762. */
  26763. useReflectionOverAlpha: boolean;
  26764. private _disableLighting;
  26765. /**
  26766. * Does lights from the scene impacts this material.
  26767. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26768. */
  26769. disableLighting: boolean;
  26770. private _useObjectSpaceNormalMap;
  26771. /**
  26772. * Allows using an object space normal map (instead of tangent space).
  26773. */
  26774. useObjectSpaceNormalMap: boolean;
  26775. private _useParallax;
  26776. /**
  26777. * Is parallax enabled or not.
  26778. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26779. */
  26780. useParallax: boolean;
  26781. private _useParallaxOcclusion;
  26782. /**
  26783. * Is parallax occlusion enabled or not.
  26784. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26785. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26786. */
  26787. useParallaxOcclusion: boolean;
  26788. /**
  26789. * 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.
  26790. */
  26791. parallaxScaleBias: number;
  26792. private _roughness;
  26793. /**
  26794. * Helps to define how blurry the reflections should appears in the material.
  26795. */
  26796. roughness: number;
  26797. /**
  26798. * In case of refraction, define the value of the index of refraction.
  26799. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26800. */
  26801. indexOfRefraction: number;
  26802. /**
  26803. * Invert the refraction texture alongside the y axis.
  26804. * It can be useful with procedural textures or probe for instance.
  26805. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26806. */
  26807. invertRefractionY: boolean;
  26808. /**
  26809. * Defines the alpha limits in alpha test mode.
  26810. */
  26811. alphaCutOff: number;
  26812. private _useLightmapAsShadowmap;
  26813. /**
  26814. * In case of light mapping, define whether the map contains light or shadow informations.
  26815. */
  26816. useLightmapAsShadowmap: boolean;
  26817. private _diffuseFresnelParameters;
  26818. /**
  26819. * Define the diffuse fresnel parameters of the material.
  26820. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26821. */
  26822. diffuseFresnelParameters: FresnelParameters;
  26823. private _opacityFresnelParameters;
  26824. /**
  26825. * Define the opacity fresnel parameters of the material.
  26826. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26827. */
  26828. opacityFresnelParameters: FresnelParameters;
  26829. private _reflectionFresnelParameters;
  26830. /**
  26831. * Define the reflection fresnel parameters of the material.
  26832. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26833. */
  26834. reflectionFresnelParameters: FresnelParameters;
  26835. private _refractionFresnelParameters;
  26836. /**
  26837. * Define the refraction fresnel parameters of the material.
  26838. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26839. */
  26840. refractionFresnelParameters: FresnelParameters;
  26841. private _emissiveFresnelParameters;
  26842. /**
  26843. * Define the emissive fresnel parameters of the material.
  26844. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26845. */
  26846. emissiveFresnelParameters: FresnelParameters;
  26847. private _useReflectionFresnelFromSpecular;
  26848. /**
  26849. * If true automatically deducts the fresnels values from the material specularity.
  26850. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26851. */
  26852. useReflectionFresnelFromSpecular: boolean;
  26853. private _useGlossinessFromSpecularMapAlpha;
  26854. /**
  26855. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26856. */
  26857. useGlossinessFromSpecularMapAlpha: boolean;
  26858. private _maxSimultaneousLights;
  26859. /**
  26860. * Defines the maximum number of lights that can be used in the material
  26861. */
  26862. maxSimultaneousLights: number;
  26863. private _invertNormalMapX;
  26864. /**
  26865. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26866. */
  26867. invertNormalMapX: boolean;
  26868. private _invertNormalMapY;
  26869. /**
  26870. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26871. */
  26872. invertNormalMapY: boolean;
  26873. private _twoSidedLighting;
  26874. /**
  26875. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26876. */
  26877. twoSidedLighting: boolean;
  26878. /**
  26879. * Default configuration related to image processing available in the standard Material.
  26880. */
  26881. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26882. /**
  26883. * Gets the image processing configuration used either in this material.
  26884. */
  26885. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  26886. /**
  26887. * Sets the Default image processing configuration used either in the this material.
  26888. *
  26889. * If sets to null, the scene one is in use.
  26890. */
  26891. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  26892. /**
  26893. * Keep track of the image processing observer to allow dispose and replace.
  26894. */
  26895. private _imageProcessingObserver;
  26896. /**
  26897. * Attaches a new image processing configuration to the Standard Material.
  26898. * @param configuration
  26899. */
  26900. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26901. /**
  26902. * Gets wether the color curves effect is enabled.
  26903. */
  26904. get cameraColorCurvesEnabled(): boolean;
  26905. /**
  26906. * Sets wether the color curves effect is enabled.
  26907. */
  26908. set cameraColorCurvesEnabled(value: boolean);
  26909. /**
  26910. * Gets wether the color grading effect is enabled.
  26911. */
  26912. get cameraColorGradingEnabled(): boolean;
  26913. /**
  26914. * Gets wether the color grading effect is enabled.
  26915. */
  26916. set cameraColorGradingEnabled(value: boolean);
  26917. /**
  26918. * Gets wether tonemapping is enabled or not.
  26919. */
  26920. get cameraToneMappingEnabled(): boolean;
  26921. /**
  26922. * Sets wether tonemapping is enabled or not
  26923. */
  26924. set cameraToneMappingEnabled(value: boolean);
  26925. /**
  26926. * The camera exposure used on this material.
  26927. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26928. * This corresponds to a photographic exposure.
  26929. */
  26930. get cameraExposure(): number;
  26931. /**
  26932. * The camera exposure used on this material.
  26933. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26934. * This corresponds to a photographic exposure.
  26935. */
  26936. set cameraExposure(value: number);
  26937. /**
  26938. * Gets The camera contrast used on this material.
  26939. */
  26940. get cameraContrast(): number;
  26941. /**
  26942. * Sets The camera contrast used on this material.
  26943. */
  26944. set cameraContrast(value: number);
  26945. /**
  26946. * Gets the Color Grading 2D Lookup Texture.
  26947. */
  26948. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  26949. /**
  26950. * Sets the Color Grading 2D Lookup Texture.
  26951. */
  26952. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  26953. /**
  26954. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26955. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26956. * 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;
  26957. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26958. */
  26959. get cameraColorCurves(): Nullable<ColorCurves>;
  26960. /**
  26961. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26962. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26963. * 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;
  26964. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26965. */
  26966. set cameraColorCurves(value: Nullable<ColorCurves>);
  26967. /**
  26968. * Custom callback helping to override the default shader used in the material.
  26969. */
  26970. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines, attributes?: string[]) => string;
  26971. protected _renderTargets: SmartArray<RenderTargetTexture>;
  26972. protected _worldViewProjectionMatrix: Matrix;
  26973. protected _globalAmbientColor: Color3;
  26974. protected _useLogarithmicDepth: boolean;
  26975. protected _rebuildInParallel: boolean;
  26976. /**
  26977. * Instantiates a new standard material.
  26978. * This is the default material used in Babylon. It is the best trade off between quality
  26979. * and performances.
  26980. * @see http://doc.babylonjs.com/babylon101/materials
  26981. * @param name Define the name of the material in the scene
  26982. * @param scene Define the scene the material belong to
  26983. */
  26984. constructor(name: string, scene: Scene);
  26985. /**
  26986. * Gets a boolean indicating that current material needs to register RTT
  26987. */
  26988. get hasRenderTargetTextures(): boolean;
  26989. /**
  26990. * Gets the current class name of the material e.g. "StandardMaterial"
  26991. * Mainly use in serialization.
  26992. * @returns the class name
  26993. */
  26994. getClassName(): string;
  26995. /**
  26996. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  26997. * You can try switching to logarithmic depth.
  26998. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  26999. */
  27000. get useLogarithmicDepth(): boolean;
  27001. set useLogarithmicDepth(value: boolean);
  27002. /**
  27003. * Specifies if the material will require alpha blending
  27004. * @returns a boolean specifying if alpha blending is needed
  27005. */
  27006. needAlphaBlending(): boolean;
  27007. /**
  27008. * Specifies if this material should be rendered in alpha test mode
  27009. * @returns a boolean specifying if an alpha test is needed.
  27010. */
  27011. needAlphaTesting(): boolean;
  27012. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27013. /**
  27014. * Get the texture used for alpha test purpose.
  27015. * @returns the diffuse texture in case of the standard material.
  27016. */
  27017. getAlphaTestTexture(): Nullable<BaseTexture>;
  27018. /**
  27019. * Get if the submesh is ready to be used and all its information available.
  27020. * Child classes can use it to update shaders
  27021. * @param mesh defines the mesh to check
  27022. * @param subMesh defines which submesh to check
  27023. * @param useInstances specifies that instances should be used
  27024. * @returns a boolean indicating that the submesh is ready or not
  27025. */
  27026. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27027. /**
  27028. * Builds the material UBO layouts.
  27029. * Used internally during the effect preparation.
  27030. */
  27031. buildUniformLayout(): void;
  27032. /**
  27033. * Unbinds the material from the mesh
  27034. */
  27035. unbind(): void;
  27036. /**
  27037. * Binds the submesh to this material by preparing the effect and shader to draw
  27038. * @param world defines the world transformation matrix
  27039. * @param mesh defines the mesh containing the submesh
  27040. * @param subMesh defines the submesh to bind the material to
  27041. */
  27042. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27043. /**
  27044. * Get the list of animatables in the material.
  27045. * @returns the list of animatables object used in the material
  27046. */
  27047. getAnimatables(): IAnimatable[];
  27048. /**
  27049. * Gets the active textures from the material
  27050. * @returns an array of textures
  27051. */
  27052. getActiveTextures(): BaseTexture[];
  27053. /**
  27054. * Specifies if the material uses a texture
  27055. * @param texture defines the texture to check against the material
  27056. * @returns a boolean specifying if the material uses the texture
  27057. */
  27058. hasTexture(texture: BaseTexture): boolean;
  27059. /**
  27060. * Disposes the material
  27061. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27062. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27063. */
  27064. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27065. /**
  27066. * Makes a duplicate of the material, and gives it a new name
  27067. * @param name defines the new name for the duplicated material
  27068. * @returns the cloned material
  27069. */
  27070. clone(name: string): StandardMaterial;
  27071. /**
  27072. * Serializes this material in a JSON representation
  27073. * @returns the serialized material object
  27074. */
  27075. serialize(): any;
  27076. /**
  27077. * Creates a standard material from parsed material data
  27078. * @param source defines the JSON representation of the material
  27079. * @param scene defines the hosting scene
  27080. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27081. * @returns a new standard material
  27082. */
  27083. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27084. /**
  27085. * Are diffuse textures enabled in the application.
  27086. */
  27087. static get DiffuseTextureEnabled(): boolean;
  27088. static set DiffuseTextureEnabled(value: boolean);
  27089. /**
  27090. * Are ambient textures enabled in the application.
  27091. */
  27092. static get AmbientTextureEnabled(): boolean;
  27093. static set AmbientTextureEnabled(value: boolean);
  27094. /**
  27095. * Are opacity textures enabled in the application.
  27096. */
  27097. static get OpacityTextureEnabled(): boolean;
  27098. static set OpacityTextureEnabled(value: boolean);
  27099. /**
  27100. * Are reflection textures enabled in the application.
  27101. */
  27102. static get ReflectionTextureEnabled(): boolean;
  27103. static set ReflectionTextureEnabled(value: boolean);
  27104. /**
  27105. * Are emissive textures enabled in the application.
  27106. */
  27107. static get EmissiveTextureEnabled(): boolean;
  27108. static set EmissiveTextureEnabled(value: boolean);
  27109. /**
  27110. * Are specular textures enabled in the application.
  27111. */
  27112. static get SpecularTextureEnabled(): boolean;
  27113. static set SpecularTextureEnabled(value: boolean);
  27114. /**
  27115. * Are bump textures enabled in the application.
  27116. */
  27117. static get BumpTextureEnabled(): boolean;
  27118. static set BumpTextureEnabled(value: boolean);
  27119. /**
  27120. * Are lightmap textures enabled in the application.
  27121. */
  27122. static get LightmapTextureEnabled(): boolean;
  27123. static set LightmapTextureEnabled(value: boolean);
  27124. /**
  27125. * Are refraction textures enabled in the application.
  27126. */
  27127. static get RefractionTextureEnabled(): boolean;
  27128. static set RefractionTextureEnabled(value: boolean);
  27129. /**
  27130. * Are color grading textures enabled in the application.
  27131. */
  27132. static get ColorGradingTextureEnabled(): boolean;
  27133. static set ColorGradingTextureEnabled(value: boolean);
  27134. /**
  27135. * Are fresnels enabled in the application.
  27136. */
  27137. static get FresnelEnabled(): boolean;
  27138. static set FresnelEnabled(value: boolean);
  27139. }
  27140. }
  27141. declare module BABYLON {
  27142. /**
  27143. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27144. *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.
  27145. * The SPS is also a particle system. It provides some methods to manage the particles.
  27146. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27147. *
  27148. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27149. */
  27150. export class SolidParticleSystem implements IDisposable {
  27151. /**
  27152. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27153. * Example : var p = SPS.particles[i];
  27154. */
  27155. particles: SolidParticle[];
  27156. /**
  27157. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27158. */
  27159. nbParticles: number;
  27160. /**
  27161. * If the particles must ever face the camera (default false). Useful for planar particles.
  27162. */
  27163. billboard: boolean;
  27164. /**
  27165. * Recompute normals when adding a shape
  27166. */
  27167. recomputeNormals: boolean;
  27168. /**
  27169. * This a counter ofr your own usage. It's not set by any SPS functions.
  27170. */
  27171. counter: number;
  27172. /**
  27173. * The SPS name. This name is also given to the underlying mesh.
  27174. */
  27175. name: string;
  27176. /**
  27177. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27178. */
  27179. mesh: Mesh;
  27180. /**
  27181. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27182. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27183. */
  27184. vars: any;
  27185. /**
  27186. * This array is populated when the SPS is set as 'pickable'.
  27187. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27188. * Each element of this array is an object `{idx: int, faceId: int}`.
  27189. * `idx` is the picked particle index in the `SPS.particles` array
  27190. * `faceId` is the picked face index counted within this particle.
  27191. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  27192. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  27193. * Use the method SPS.pickedParticle(pickingInfo) instead.
  27194. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27195. */
  27196. pickedParticles: {
  27197. idx: number;
  27198. faceId: number;
  27199. }[];
  27200. /**
  27201. * This array is populated when the SPS is set as 'pickable'
  27202. * Each key of this array is a submesh index.
  27203. * Each element of this array is a second array defined like this :
  27204. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  27205. * Each element of this second array is an object `{idx: int, faceId: int}`.
  27206. * `idx` is the picked particle index in the `SPS.particles` array
  27207. * `faceId` is the picked face index counted within this particle.
  27208. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  27209. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27210. */
  27211. pickedBySubMesh: {
  27212. idx: number;
  27213. faceId: number;
  27214. }[][];
  27215. /**
  27216. * This array is populated when `enableDepthSort` is set to true.
  27217. * Each element of this array is an instance of the class DepthSortedParticle.
  27218. */
  27219. depthSortedParticles: DepthSortedParticle[];
  27220. /**
  27221. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27222. * @hidden
  27223. */
  27224. _bSphereOnly: boolean;
  27225. /**
  27226. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27227. * @hidden
  27228. */
  27229. _bSphereRadiusFactor: number;
  27230. private _scene;
  27231. private _positions;
  27232. private _indices;
  27233. private _normals;
  27234. private _colors;
  27235. private _uvs;
  27236. private _indices32;
  27237. private _positions32;
  27238. private _normals32;
  27239. private _fixedNormal32;
  27240. private _colors32;
  27241. private _uvs32;
  27242. private _index;
  27243. private _updatable;
  27244. private _pickable;
  27245. private _isVisibilityBoxLocked;
  27246. private _alwaysVisible;
  27247. private _depthSort;
  27248. private _expandable;
  27249. private _shapeCounter;
  27250. private _copy;
  27251. private _color;
  27252. private _computeParticleColor;
  27253. private _computeParticleTexture;
  27254. private _computeParticleRotation;
  27255. private _computeParticleVertex;
  27256. private _computeBoundingBox;
  27257. private _depthSortParticles;
  27258. private _camera;
  27259. private _mustUnrotateFixedNormals;
  27260. private _particlesIntersect;
  27261. private _needs32Bits;
  27262. private _isNotBuilt;
  27263. private _lastParticleId;
  27264. private _idxOfId;
  27265. private _multimaterialEnabled;
  27266. private _useModelMaterial;
  27267. private _indicesByMaterial;
  27268. private _materialIndexes;
  27269. private _depthSortFunction;
  27270. private _materialSortFunction;
  27271. private _materials;
  27272. private _multimaterial;
  27273. private _materialIndexesById;
  27274. private _defaultMaterial;
  27275. private _autoUpdateSubMeshes;
  27276. /**
  27277. * Creates a SPS (Solid Particle System) object.
  27278. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27279. * @param scene (Scene) is the scene in which the SPS is added.
  27280. * @param options defines the options of the sps e.g.
  27281. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27282. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27283. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27284. * * 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.
  27285. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27286. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27287. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27288. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27289. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27290. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27291. */
  27292. constructor(name: string, scene: Scene, options?: {
  27293. updatable?: boolean;
  27294. isPickable?: boolean;
  27295. enableDepthSort?: boolean;
  27296. particleIntersection?: boolean;
  27297. boundingSphereOnly?: boolean;
  27298. bSphereRadiusFactor?: number;
  27299. expandable?: boolean;
  27300. useModelMaterial?: boolean;
  27301. enableMultiMaterial?: boolean;
  27302. });
  27303. /**
  27304. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27305. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27306. * @returns the created mesh
  27307. */
  27308. buildMesh(): Mesh;
  27309. /**
  27310. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27311. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27312. * Thus the particles generated from `digest()` have their property `position` set yet.
  27313. * @param mesh ( Mesh ) is the mesh to be digested
  27314. * @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
  27315. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27316. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27317. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27318. * @returns the current SPS
  27319. */
  27320. digest(mesh: Mesh, options?: {
  27321. facetNb?: number;
  27322. number?: number;
  27323. delta?: number;
  27324. storage?: [];
  27325. }): SolidParticleSystem;
  27326. /**
  27327. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27328. * @hidden
  27329. */
  27330. private _unrotateFixedNormals;
  27331. /**
  27332. * Resets the temporary working copy particle
  27333. * @hidden
  27334. */
  27335. private _resetCopy;
  27336. /**
  27337. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27338. * @param p the current index in the positions array to be updated
  27339. * @param ind the current index in the indices array
  27340. * @param shape a Vector3 array, the shape geometry
  27341. * @param positions the positions array to be updated
  27342. * @param meshInd the shape indices array
  27343. * @param indices the indices array to be updated
  27344. * @param meshUV the shape uv array
  27345. * @param uvs the uv array to be updated
  27346. * @param meshCol the shape color array
  27347. * @param colors the color array to be updated
  27348. * @param meshNor the shape normals array
  27349. * @param normals the normals array to be updated
  27350. * @param idx the particle index
  27351. * @param idxInShape the particle index in its shape
  27352. * @param options the addShape() method passed options
  27353. * @model the particle model
  27354. * @hidden
  27355. */
  27356. private _meshBuilder;
  27357. /**
  27358. * Returns a shape Vector3 array from positions float array
  27359. * @param positions float array
  27360. * @returns a vector3 array
  27361. * @hidden
  27362. */
  27363. private _posToShape;
  27364. /**
  27365. * Returns a shapeUV array from a float uvs (array deep copy)
  27366. * @param uvs as a float array
  27367. * @returns a shapeUV array
  27368. * @hidden
  27369. */
  27370. private _uvsToShapeUV;
  27371. /**
  27372. * Adds a new particle object in the particles array
  27373. * @param idx particle index in particles array
  27374. * @param id particle id
  27375. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27376. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27377. * @param model particle ModelShape object
  27378. * @param shapeId model shape identifier
  27379. * @param idxInShape index of the particle in the current model
  27380. * @param bInfo model bounding info object
  27381. * @param storage target storage array, if any
  27382. * @hidden
  27383. */
  27384. private _addParticle;
  27385. /**
  27386. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27387. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27388. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27389. * @param nb (positive integer) the number of particles to be created from this model
  27390. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27391. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27392. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27393. * @returns the number of shapes in the system
  27394. */
  27395. addShape(mesh: Mesh, nb: number, options?: {
  27396. positionFunction?: any;
  27397. vertexFunction?: any;
  27398. storage?: [];
  27399. }): number;
  27400. /**
  27401. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27402. * @hidden
  27403. */
  27404. private _rebuildParticle;
  27405. /**
  27406. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27407. * @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.
  27408. * @returns the SPS.
  27409. */
  27410. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27411. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27412. * Returns an array with the removed particles.
  27413. * 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.
  27414. * The SPS can't be empty so at least one particle needs to remain in place.
  27415. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27416. * @param start index of the first particle to remove
  27417. * @param end index of the last particle to remove (included)
  27418. * @returns an array populated with the removed particles
  27419. */
  27420. removeParticles(start: number, end: number): SolidParticle[];
  27421. /**
  27422. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27423. * @param solidParticleArray an array populated with Solid Particles objects
  27424. * @returns the SPS
  27425. */
  27426. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27427. /**
  27428. * Creates a new particle and modifies the SPS mesh geometry :
  27429. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27430. * - calls _addParticle() to populate the particle array
  27431. * factorized code from addShape() and insertParticlesFromArray()
  27432. * @param idx particle index in the particles array
  27433. * @param i particle index in its shape
  27434. * @param modelShape particle ModelShape object
  27435. * @param shape shape vertex array
  27436. * @param meshInd shape indices array
  27437. * @param meshUV shape uv array
  27438. * @param meshCol shape color array
  27439. * @param meshNor shape normals array
  27440. * @param bbInfo shape bounding info
  27441. * @param storage target particle storage
  27442. * @options addShape() passed options
  27443. * @hidden
  27444. */
  27445. private _insertNewParticle;
  27446. /**
  27447. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27448. * This method calls `updateParticle()` for each particle of the SPS.
  27449. * For an animated SPS, it is usually called within the render loop.
  27450. * 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.
  27451. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27452. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27453. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27454. * @returns the SPS.
  27455. */
  27456. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27457. /**
  27458. * Disposes the SPS.
  27459. */
  27460. dispose(): void;
  27461. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  27462. * idx is the particle index in the SPS
  27463. * faceId is the picked face index counted within this particle.
  27464. * Returns null if the pickInfo can't identify a picked particle.
  27465. * @param pickingInfo (PickingInfo object)
  27466. * @returns {idx: number, faceId: number} or null
  27467. */
  27468. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  27469. idx: number;
  27470. faceId: number;
  27471. }>;
  27472. /**
  27473. * Returns a SolidParticle object from its identifier : particle.id
  27474. * @param id (integer) the particle Id
  27475. * @returns the searched particle or null if not found in the SPS.
  27476. */
  27477. getParticleById(id: number): Nullable<SolidParticle>;
  27478. /**
  27479. * Returns a new array populated with the particles having the passed shapeId.
  27480. * @param shapeId (integer) the shape identifier
  27481. * @returns a new solid particle array
  27482. */
  27483. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27484. /**
  27485. * Populates the passed array "ref" with the particles having the passed shapeId.
  27486. * @param shapeId the shape identifier
  27487. * @returns the SPS
  27488. * @param ref
  27489. */
  27490. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27491. /**
  27492. * Computes the required SubMeshes according the materials assigned to the particles.
  27493. * @returns the solid particle system.
  27494. * Does nothing if called before the SPS mesh is built.
  27495. */
  27496. computeSubMeshes(): SolidParticleSystem;
  27497. /**
  27498. * Sorts the solid particles by material when MultiMaterial is enabled.
  27499. * Updates the indices32 array.
  27500. * Updates the indicesByMaterial array.
  27501. * Updates the mesh indices array.
  27502. * @returns the SPS
  27503. * @hidden
  27504. */
  27505. private _sortParticlesByMaterial;
  27506. /**
  27507. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27508. * @hidden
  27509. */
  27510. private _setMaterialIndexesById;
  27511. /**
  27512. * Returns an array with unique values of Materials from the passed array
  27513. * @param array the material array to be checked and filtered
  27514. * @hidden
  27515. */
  27516. private _filterUniqueMaterialId;
  27517. /**
  27518. * Sets a new Standard Material as _defaultMaterial if not already set.
  27519. * @hidden
  27520. */
  27521. private _setDefaultMaterial;
  27522. /**
  27523. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27524. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27525. * @returns the SPS.
  27526. */
  27527. refreshVisibleSize(): SolidParticleSystem;
  27528. /**
  27529. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27530. * @param size the size (float) of the visibility box
  27531. * note : this doesn't lock the SPS mesh bounding box.
  27532. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27533. */
  27534. setVisibilityBox(size: number): void;
  27535. /**
  27536. * Gets whether the SPS as always visible or not
  27537. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27538. */
  27539. get isAlwaysVisible(): boolean;
  27540. /**
  27541. * Sets the SPS as always visible or not
  27542. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27543. */
  27544. set isAlwaysVisible(val: boolean);
  27545. /**
  27546. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27547. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27548. */
  27549. set isVisibilityBoxLocked(val: boolean);
  27550. /**
  27551. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27552. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27553. */
  27554. get isVisibilityBoxLocked(): boolean;
  27555. /**
  27556. * Tells to `setParticles()` to compute the particle rotations or not.
  27557. * Default value : true. The SPS is faster when it's set to false.
  27558. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27559. */
  27560. set computeParticleRotation(val: boolean);
  27561. /**
  27562. * Tells to `setParticles()` to compute the particle colors or not.
  27563. * Default value : true. The SPS is faster when it's set to false.
  27564. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27565. */
  27566. set computeParticleColor(val: boolean);
  27567. set computeParticleTexture(val: boolean);
  27568. /**
  27569. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27570. * Default value : false. The SPS is faster when it's set to false.
  27571. * Note : the particle custom vertex positions aren't stored values.
  27572. */
  27573. set computeParticleVertex(val: boolean);
  27574. /**
  27575. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27576. */
  27577. set computeBoundingBox(val: boolean);
  27578. /**
  27579. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27580. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27581. * Default : `true`
  27582. */
  27583. set depthSortParticles(val: boolean);
  27584. /**
  27585. * Gets if `setParticles()` computes the particle rotations or not.
  27586. * Default value : true. The SPS is faster when it's set to false.
  27587. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27588. */
  27589. get computeParticleRotation(): boolean;
  27590. /**
  27591. * Gets if `setParticles()` computes the particle colors or not.
  27592. * Default value : true. The SPS is faster when it's set to false.
  27593. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27594. */
  27595. get computeParticleColor(): boolean;
  27596. /**
  27597. * Gets if `setParticles()` computes the particle textures or not.
  27598. * Default value : true. The SPS is faster when it's set to false.
  27599. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27600. */
  27601. get computeParticleTexture(): boolean;
  27602. /**
  27603. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27604. * Default value : false. The SPS is faster when it's set to false.
  27605. * Note : the particle custom vertex positions aren't stored values.
  27606. */
  27607. get computeParticleVertex(): boolean;
  27608. /**
  27609. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27610. */
  27611. get computeBoundingBox(): boolean;
  27612. /**
  27613. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27614. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27615. * Default : `true`
  27616. */
  27617. get depthSortParticles(): boolean;
  27618. /**
  27619. * Gets if the SPS is created as expandable at construction time.
  27620. * Default : `false`
  27621. */
  27622. get expandable(): boolean;
  27623. /**
  27624. * Gets if the SPS supports the Multi Materials
  27625. */
  27626. get multimaterialEnabled(): boolean;
  27627. /**
  27628. * Gets if the SPS uses the model materials for its own multimaterial.
  27629. */
  27630. get useModelMaterial(): boolean;
  27631. /**
  27632. * The SPS used material array.
  27633. */
  27634. get materials(): Material[];
  27635. /**
  27636. * Sets the SPS MultiMaterial from the passed materials.
  27637. * Note : the passed array is internally copied and not used then by reference.
  27638. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27639. */
  27640. setMultiMaterial(materials: Material[]): void;
  27641. /**
  27642. * The SPS computed multimaterial object
  27643. */
  27644. get multimaterial(): MultiMaterial;
  27645. set multimaterial(mm: MultiMaterial);
  27646. /**
  27647. * If the subMeshes must be updated on the next call to setParticles()
  27648. */
  27649. get autoUpdateSubMeshes(): boolean;
  27650. set autoUpdateSubMeshes(val: boolean);
  27651. /**
  27652. * This function does nothing. It may be overwritten to set all the particle first values.
  27653. * The SPS doesn't call this function, you may have to call it by your own.
  27654. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27655. */
  27656. initParticles(): void;
  27657. /**
  27658. * This function does nothing. It may be overwritten to recycle a particle.
  27659. * The SPS doesn't call this function, you may have to call it by your own.
  27660. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27661. * @param particle The particle to recycle
  27662. * @returns the recycled particle
  27663. */
  27664. recycleParticle(particle: SolidParticle): SolidParticle;
  27665. /**
  27666. * Updates a particle : this function should be overwritten by the user.
  27667. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27668. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27669. * @example : just set a particle position or velocity and recycle conditions
  27670. * @param particle The particle to update
  27671. * @returns the updated particle
  27672. */
  27673. updateParticle(particle: SolidParticle): SolidParticle;
  27674. /**
  27675. * Updates a vertex of a particle : it can be overwritten by the user.
  27676. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27677. * @param particle the current particle
  27678. * @param vertex the current index of the current particle
  27679. * @param pt the index of the current vertex in the particle shape
  27680. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27681. * @example : just set a vertex particle position
  27682. * @returns the updated vertex
  27683. */
  27684. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27685. /**
  27686. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27687. * This does nothing and may be overwritten by the user.
  27688. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27689. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27690. * @param update the boolean update value actually passed to setParticles()
  27691. */
  27692. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27693. /**
  27694. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27695. * This will be passed three parameters.
  27696. * This does nothing and may be overwritten by the user.
  27697. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27698. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27699. * @param update the boolean update value actually passed to setParticles()
  27700. */
  27701. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27702. }
  27703. }
  27704. declare module BABYLON {
  27705. /**
  27706. * Represents one particle of a solid particle system.
  27707. */
  27708. export class SolidParticle {
  27709. /**
  27710. * particle global index
  27711. */
  27712. idx: number;
  27713. /**
  27714. * particle identifier
  27715. */
  27716. id: number;
  27717. /**
  27718. * The color of the particle
  27719. */
  27720. color: Nullable<Color4>;
  27721. /**
  27722. * The world space position of the particle.
  27723. */
  27724. position: Vector3;
  27725. /**
  27726. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27727. */
  27728. rotation: Vector3;
  27729. /**
  27730. * The world space rotation quaternion of the particle.
  27731. */
  27732. rotationQuaternion: Nullable<Quaternion>;
  27733. /**
  27734. * The scaling of the particle.
  27735. */
  27736. scaling: Vector3;
  27737. /**
  27738. * The uvs of the particle.
  27739. */
  27740. uvs: Vector4;
  27741. /**
  27742. * The current speed of the particle.
  27743. */
  27744. velocity: Vector3;
  27745. /**
  27746. * The pivot point in the particle local space.
  27747. */
  27748. pivot: Vector3;
  27749. /**
  27750. * Must the particle be translated from its pivot point in its local space ?
  27751. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27752. * Default : false
  27753. */
  27754. translateFromPivot: boolean;
  27755. /**
  27756. * Is the particle active or not ?
  27757. */
  27758. alive: boolean;
  27759. /**
  27760. * Is the particle visible or not ?
  27761. */
  27762. isVisible: boolean;
  27763. /**
  27764. * Index of this particle in the global "positions" array (Internal use)
  27765. * @hidden
  27766. */
  27767. _pos: number;
  27768. /**
  27769. * @hidden Index of this particle in the global "indices" array (Internal use)
  27770. */
  27771. _ind: number;
  27772. /**
  27773. * @hidden ModelShape of this particle (Internal use)
  27774. */
  27775. _model: ModelShape;
  27776. /**
  27777. * ModelShape id of this particle
  27778. */
  27779. shapeId: number;
  27780. /**
  27781. * Index of the particle in its shape id
  27782. */
  27783. idxInShape: number;
  27784. /**
  27785. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27786. */
  27787. _modelBoundingInfo: BoundingInfo;
  27788. /**
  27789. * @hidden Particle BoundingInfo object (Internal use)
  27790. */
  27791. _boundingInfo: BoundingInfo;
  27792. /**
  27793. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27794. */
  27795. _sps: SolidParticleSystem;
  27796. /**
  27797. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27798. */
  27799. _stillInvisible: boolean;
  27800. /**
  27801. * @hidden Last computed particle rotation matrix
  27802. */
  27803. _rotationMatrix: number[];
  27804. /**
  27805. * Parent particle Id, if any.
  27806. * Default null.
  27807. */
  27808. parentId: Nullable<number>;
  27809. /**
  27810. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27811. */
  27812. materialIndex: Nullable<number>;
  27813. /**
  27814. * Custom object or properties.
  27815. */
  27816. props: Nullable<any>;
  27817. /**
  27818. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27819. * The possible values are :
  27820. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27821. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27822. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27823. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27824. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27825. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27826. * */
  27827. cullingStrategy: number;
  27828. /**
  27829. * @hidden Internal global position in the SPS.
  27830. */
  27831. _globalPosition: Vector3;
  27832. /**
  27833. * Creates a Solid Particle object.
  27834. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27835. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27836. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27837. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27838. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27839. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27840. * @param shapeId (integer) is the model shape identifier in the SPS.
  27841. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27842. * @param sps defines the sps it is associated to
  27843. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27844. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27845. */
  27846. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27847. /**
  27848. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27849. * @param target the particle target
  27850. * @returns the current particle
  27851. */
  27852. copyToRef(target: SolidParticle): SolidParticle;
  27853. /**
  27854. * Legacy support, changed scale to scaling
  27855. */
  27856. get scale(): Vector3;
  27857. /**
  27858. * Legacy support, changed scale to scaling
  27859. */
  27860. set scale(scale: Vector3);
  27861. /**
  27862. * Legacy support, changed quaternion to rotationQuaternion
  27863. */
  27864. get quaternion(): Nullable<Quaternion>;
  27865. /**
  27866. * Legacy support, changed quaternion to rotationQuaternion
  27867. */
  27868. set quaternion(q: Nullable<Quaternion>);
  27869. /**
  27870. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27871. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27872. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27873. * @returns true if it intersects
  27874. */
  27875. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27876. /**
  27877. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27878. * A particle is in the frustum if its bounding box intersects the frustum
  27879. * @param frustumPlanes defines the frustum to test
  27880. * @returns true if the particle is in the frustum planes
  27881. */
  27882. isInFrustum(frustumPlanes: Plane[]): boolean;
  27883. /**
  27884. * get the rotation matrix of the particle
  27885. * @hidden
  27886. */
  27887. getRotationMatrix(m: Matrix): void;
  27888. }
  27889. /**
  27890. * Represents the shape of the model used by one particle of a solid particle system.
  27891. * SPS internal tool, don't use it manually.
  27892. */
  27893. export class ModelShape {
  27894. /**
  27895. * The shape id
  27896. * @hidden
  27897. */
  27898. shapeID: number;
  27899. /**
  27900. * flat array of model positions (internal use)
  27901. * @hidden
  27902. */
  27903. _shape: Vector3[];
  27904. /**
  27905. * flat array of model UVs (internal use)
  27906. * @hidden
  27907. */
  27908. _shapeUV: number[];
  27909. /**
  27910. * color array of the model
  27911. * @hidden
  27912. */
  27913. _shapeColors: number[];
  27914. /**
  27915. * indices array of the model
  27916. * @hidden
  27917. */
  27918. _indices: number[];
  27919. /**
  27920. * normals array of the model
  27921. * @hidden
  27922. */
  27923. _normals: number[];
  27924. /**
  27925. * length of the shape in the model indices array (internal use)
  27926. * @hidden
  27927. */
  27928. _indicesLength: number;
  27929. /**
  27930. * Custom position function (internal use)
  27931. * @hidden
  27932. */
  27933. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27934. /**
  27935. * Custom vertex function (internal use)
  27936. * @hidden
  27937. */
  27938. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  27939. /**
  27940. * Model material (internal use)
  27941. * @hidden
  27942. */
  27943. _material: Nullable<Material>;
  27944. /**
  27945. * 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.
  27946. * SPS internal tool, don't use it manually.
  27947. * @hidden
  27948. */
  27949. 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>);
  27950. }
  27951. /**
  27952. * Represents a Depth Sorted Particle in the solid particle system.
  27953. * @hidden
  27954. */
  27955. export class DepthSortedParticle {
  27956. /**
  27957. * Particle index
  27958. */
  27959. idx: number;
  27960. /**
  27961. * Index of the particle in the "indices" array
  27962. */
  27963. ind: number;
  27964. /**
  27965. * Length of the particle shape in the "indices" array
  27966. */
  27967. indicesLength: number;
  27968. /**
  27969. * Squared distance from the particle to the camera
  27970. */
  27971. sqDistance: number;
  27972. /**
  27973. * Material index when used with MultiMaterials
  27974. */
  27975. materialIndex: number;
  27976. /**
  27977. * Creates a new sorted particle
  27978. * @param materialIndex
  27979. */
  27980. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  27981. }
  27982. }
  27983. declare module BABYLON {
  27984. /**
  27985. * @hidden
  27986. */
  27987. export class _MeshCollisionData {
  27988. _checkCollisions: boolean;
  27989. _collisionMask: number;
  27990. _collisionGroup: number;
  27991. _surroundingMeshes: Nullable<AbstractMesh[]>;
  27992. _collider: Nullable<Collider>;
  27993. _oldPositionForCollisions: Vector3;
  27994. _diffPositionForCollisions: Vector3;
  27995. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  27996. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  27997. }
  27998. }
  27999. declare module BABYLON {
  28000. /** @hidden */
  28001. class _FacetDataStorage {
  28002. facetPositions: Vector3[];
  28003. facetNormals: Vector3[];
  28004. facetPartitioning: number[][];
  28005. facetNb: number;
  28006. partitioningSubdivisions: number;
  28007. partitioningBBoxRatio: number;
  28008. facetDataEnabled: boolean;
  28009. facetParameters: any;
  28010. bbSize: Vector3;
  28011. subDiv: {
  28012. max: number;
  28013. X: number;
  28014. Y: number;
  28015. Z: number;
  28016. };
  28017. facetDepthSort: boolean;
  28018. facetDepthSortEnabled: boolean;
  28019. depthSortedIndices: IndicesArray;
  28020. depthSortedFacets: {
  28021. ind: number;
  28022. sqDistance: number;
  28023. }[];
  28024. facetDepthSortFunction: (f1: {
  28025. ind: number;
  28026. sqDistance: number;
  28027. }, f2: {
  28028. ind: number;
  28029. sqDistance: number;
  28030. }) => number;
  28031. facetDepthSortFrom: Vector3;
  28032. facetDepthSortOrigin: Vector3;
  28033. invertedMatrix: Matrix;
  28034. }
  28035. /**
  28036. * @hidden
  28037. **/
  28038. class _InternalAbstractMeshDataInfo {
  28039. _hasVertexAlpha: boolean;
  28040. _useVertexColors: boolean;
  28041. _numBoneInfluencers: number;
  28042. _applyFog: boolean;
  28043. _receiveShadows: boolean;
  28044. _facetData: _FacetDataStorage;
  28045. _visibility: number;
  28046. _skeleton: Nullable<Skeleton>;
  28047. _layerMask: number;
  28048. _computeBonesUsingShaders: boolean;
  28049. _isActive: boolean;
  28050. _onlyForInstances: boolean;
  28051. _isActiveIntermediate: boolean;
  28052. _onlyForInstancesIntermediate: boolean;
  28053. _actAsRegularMesh: boolean;
  28054. }
  28055. /**
  28056. * Class used to store all common mesh properties
  28057. */
  28058. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28059. /** No occlusion */
  28060. static OCCLUSION_TYPE_NONE: number;
  28061. /** Occlusion set to optimisitic */
  28062. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28063. /** Occlusion set to strict */
  28064. static OCCLUSION_TYPE_STRICT: number;
  28065. /** Use an accurante occlusion algorithm */
  28066. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28067. /** Use a conservative occlusion algorithm */
  28068. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28069. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28070. * Test order :
  28071. * Is the bounding sphere outside the frustum ?
  28072. * If not, are the bounding box vertices outside the frustum ?
  28073. * It not, then the cullable object is in the frustum.
  28074. */
  28075. static readonly CULLINGSTRATEGY_STANDARD: number;
  28076. /** Culling strategy : Bounding Sphere Only.
  28077. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28078. * It's also less accurate than the standard because some not visible objects can still be selected.
  28079. * Test : is the bounding sphere outside the frustum ?
  28080. * If not, then the cullable object is in the frustum.
  28081. */
  28082. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28083. /** Culling strategy : Optimistic Inclusion.
  28084. * This in an inclusion test first, then the standard exclusion test.
  28085. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28086. * 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.
  28087. * Anyway, it's as accurate as the standard strategy.
  28088. * Test :
  28089. * Is the cullable object bounding sphere center in the frustum ?
  28090. * If not, apply the default culling strategy.
  28091. */
  28092. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28093. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28094. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28095. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28096. * 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.
  28097. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28098. * Test :
  28099. * Is the cullable object bounding sphere center in the frustum ?
  28100. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28101. */
  28102. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28103. /**
  28104. * No billboard
  28105. */
  28106. static get BILLBOARDMODE_NONE(): number;
  28107. /** Billboard on X axis */
  28108. static get BILLBOARDMODE_X(): number;
  28109. /** Billboard on Y axis */
  28110. static get BILLBOARDMODE_Y(): number;
  28111. /** Billboard on Z axis */
  28112. static get BILLBOARDMODE_Z(): number;
  28113. /** Billboard on all axes */
  28114. static get BILLBOARDMODE_ALL(): number;
  28115. /** Billboard on using position instead of orientation */
  28116. static get BILLBOARDMODE_USE_POSITION(): number;
  28117. /** @hidden */
  28118. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28119. /**
  28120. * The culling strategy to use to check whether the mesh must be rendered or not.
  28121. * This value can be changed at any time and will be used on the next render mesh selection.
  28122. * The possible values are :
  28123. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28124. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28125. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28126. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28127. * Please read each static variable documentation to get details about the culling process.
  28128. * */
  28129. cullingStrategy: number;
  28130. /**
  28131. * Gets the number of facets in the mesh
  28132. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28133. */
  28134. get facetNb(): number;
  28135. /**
  28136. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28137. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28138. */
  28139. get partitioningSubdivisions(): number;
  28140. set partitioningSubdivisions(nb: number);
  28141. /**
  28142. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28143. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28144. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28145. */
  28146. get partitioningBBoxRatio(): number;
  28147. set partitioningBBoxRatio(ratio: number);
  28148. /**
  28149. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28150. * Works only for updatable meshes.
  28151. * Doesn't work with multi-materials
  28152. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28153. */
  28154. get mustDepthSortFacets(): boolean;
  28155. set mustDepthSortFacets(sort: boolean);
  28156. /**
  28157. * The location (Vector3) where the facet depth sort must be computed from.
  28158. * By default, the active camera position.
  28159. * Used only when facet depth sort is enabled
  28160. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28161. */
  28162. get facetDepthSortFrom(): Vector3;
  28163. set facetDepthSortFrom(location: Vector3);
  28164. /**
  28165. * gets a boolean indicating if facetData is enabled
  28166. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28167. */
  28168. get isFacetDataEnabled(): boolean;
  28169. /** @hidden */
  28170. _updateNonUniformScalingState(value: boolean): boolean;
  28171. /**
  28172. * An event triggered when this mesh collides with another one
  28173. */
  28174. onCollideObservable: Observable<AbstractMesh>;
  28175. /** Set a function to call when this mesh collides with another one */
  28176. set onCollide(callback: () => void);
  28177. /**
  28178. * An event triggered when the collision's position changes
  28179. */
  28180. onCollisionPositionChangeObservable: Observable<Vector3>;
  28181. /** Set a function to call when the collision's position changes */
  28182. set onCollisionPositionChange(callback: () => void);
  28183. /**
  28184. * An event triggered when material is changed
  28185. */
  28186. onMaterialChangedObservable: Observable<AbstractMesh>;
  28187. /**
  28188. * Gets or sets the orientation for POV movement & rotation
  28189. */
  28190. definedFacingForward: boolean;
  28191. /** @hidden */
  28192. _occlusionQuery: Nullable<WebGLQuery>;
  28193. /** @hidden */
  28194. _renderingGroup: Nullable<RenderingGroup>;
  28195. /**
  28196. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28197. */
  28198. get visibility(): number;
  28199. /**
  28200. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28201. */
  28202. set visibility(value: number);
  28203. /** Gets or sets the alpha index used to sort transparent meshes
  28204. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28205. */
  28206. alphaIndex: number;
  28207. /**
  28208. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28209. */
  28210. isVisible: boolean;
  28211. /**
  28212. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28213. */
  28214. isPickable: boolean;
  28215. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28216. showSubMeshesBoundingBox: boolean;
  28217. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28218. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28219. */
  28220. isBlocker: boolean;
  28221. /**
  28222. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28223. */
  28224. enablePointerMoveEvents: boolean;
  28225. /**
  28226. * Specifies the rendering group id for this mesh (0 by default)
  28227. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28228. */
  28229. renderingGroupId: number;
  28230. private _material;
  28231. /** Gets or sets current material */
  28232. get material(): Nullable<Material>;
  28233. set material(value: Nullable<Material>);
  28234. /**
  28235. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28236. * @see http://doc.babylonjs.com/babylon101/shadows
  28237. */
  28238. get receiveShadows(): boolean;
  28239. set receiveShadows(value: boolean);
  28240. /** Defines color to use when rendering outline */
  28241. outlineColor: Color3;
  28242. /** Define width to use when rendering outline */
  28243. outlineWidth: number;
  28244. /** Defines color to use when rendering overlay */
  28245. overlayColor: Color3;
  28246. /** Defines alpha to use when rendering overlay */
  28247. overlayAlpha: number;
  28248. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28249. get hasVertexAlpha(): boolean;
  28250. set hasVertexAlpha(value: boolean);
  28251. /** 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) */
  28252. get useVertexColors(): boolean;
  28253. set useVertexColors(value: boolean);
  28254. /**
  28255. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28256. */
  28257. get computeBonesUsingShaders(): boolean;
  28258. set computeBonesUsingShaders(value: boolean);
  28259. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28260. get numBoneInfluencers(): number;
  28261. set numBoneInfluencers(value: number);
  28262. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28263. get applyFog(): boolean;
  28264. set applyFog(value: boolean);
  28265. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28266. useOctreeForRenderingSelection: boolean;
  28267. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28268. useOctreeForPicking: boolean;
  28269. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28270. useOctreeForCollisions: boolean;
  28271. /**
  28272. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28273. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28274. */
  28275. get layerMask(): number;
  28276. set layerMask(value: number);
  28277. /**
  28278. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28279. */
  28280. alwaysSelectAsActiveMesh: boolean;
  28281. /**
  28282. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28283. */
  28284. doNotSyncBoundingInfo: boolean;
  28285. /**
  28286. * Gets or sets the current action manager
  28287. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28288. */
  28289. actionManager: Nullable<AbstractActionManager>;
  28290. private _meshCollisionData;
  28291. /**
  28292. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28293. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28294. */
  28295. ellipsoid: Vector3;
  28296. /**
  28297. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28298. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28299. */
  28300. ellipsoidOffset: Vector3;
  28301. /**
  28302. * Gets or sets a collision mask used to mask collisions (default is -1).
  28303. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28304. */
  28305. get collisionMask(): number;
  28306. set collisionMask(mask: number);
  28307. /**
  28308. * Gets or sets the current collision group mask (-1 by default).
  28309. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28310. */
  28311. get collisionGroup(): number;
  28312. set collisionGroup(mask: number);
  28313. /**
  28314. * Gets or sets current surrounding meshes (null by default).
  28315. *
  28316. * By default collision detection is tested against every mesh in the scene.
  28317. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  28318. * meshes will be tested for the collision.
  28319. *
  28320. * Note: if set to an empty array no collision will happen when this mesh is moved.
  28321. */
  28322. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  28323. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  28324. /**
  28325. * Defines edge width used when edgesRenderer is enabled
  28326. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28327. */
  28328. edgesWidth: number;
  28329. /**
  28330. * Defines edge color used when edgesRenderer is enabled
  28331. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28332. */
  28333. edgesColor: Color4;
  28334. /** @hidden */
  28335. _edgesRenderer: Nullable<IEdgesRenderer>;
  28336. /** @hidden */
  28337. _masterMesh: Nullable<AbstractMesh>;
  28338. /** @hidden */
  28339. _boundingInfo: Nullable<BoundingInfo>;
  28340. /** @hidden */
  28341. _renderId: number;
  28342. /**
  28343. * Gets or sets the list of subMeshes
  28344. * @see http://doc.babylonjs.com/how_to/multi_materials
  28345. */
  28346. subMeshes: SubMesh[];
  28347. /** @hidden */
  28348. _intersectionsInProgress: AbstractMesh[];
  28349. /** @hidden */
  28350. _unIndexed: boolean;
  28351. /** @hidden */
  28352. _lightSources: Light[];
  28353. /** Gets the list of lights affecting that mesh */
  28354. get lightSources(): Light[];
  28355. /** @hidden */
  28356. get _positions(): Nullable<Vector3[]>;
  28357. /** @hidden */
  28358. _waitingData: {
  28359. lods: Nullable<any>;
  28360. actions: Nullable<any>;
  28361. freezeWorldMatrix: Nullable<boolean>;
  28362. };
  28363. /** @hidden */
  28364. _bonesTransformMatrices: Nullable<Float32Array>;
  28365. /** @hidden */
  28366. _transformMatrixTexture: Nullable<RawTexture>;
  28367. /**
  28368. * Gets or sets a skeleton to apply skining transformations
  28369. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28370. */
  28371. set skeleton(value: Nullable<Skeleton>);
  28372. get skeleton(): Nullable<Skeleton>;
  28373. /**
  28374. * An event triggered when the mesh is rebuilt.
  28375. */
  28376. onRebuildObservable: Observable<AbstractMesh>;
  28377. /**
  28378. * Creates a new AbstractMesh
  28379. * @param name defines the name of the mesh
  28380. * @param scene defines the hosting scene
  28381. */
  28382. constructor(name: string, scene?: Nullable<Scene>);
  28383. /**
  28384. * Returns the string "AbstractMesh"
  28385. * @returns "AbstractMesh"
  28386. */
  28387. getClassName(): string;
  28388. /**
  28389. * Gets a string representation of the current mesh
  28390. * @param fullDetails defines a boolean indicating if full details must be included
  28391. * @returns a string representation of the current mesh
  28392. */
  28393. toString(fullDetails?: boolean): string;
  28394. /**
  28395. * @hidden
  28396. */
  28397. protected _getEffectiveParent(): Nullable<Node>;
  28398. /** @hidden */
  28399. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28400. /** @hidden */
  28401. _rebuild(): void;
  28402. /** @hidden */
  28403. _resyncLightSources(): void;
  28404. /** @hidden */
  28405. _resyncLightSource(light: Light): void;
  28406. /** @hidden */
  28407. _unBindEffect(): void;
  28408. /** @hidden */
  28409. _removeLightSource(light: Light, dispose: boolean): void;
  28410. private _markSubMeshesAsDirty;
  28411. /** @hidden */
  28412. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28413. /** @hidden */
  28414. _markSubMeshesAsAttributesDirty(): void;
  28415. /** @hidden */
  28416. _markSubMeshesAsMiscDirty(): void;
  28417. /**
  28418. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28419. */
  28420. get scaling(): Vector3;
  28421. set scaling(newScaling: Vector3);
  28422. /**
  28423. * Returns true if the mesh is blocked. Implemented by child classes
  28424. */
  28425. get isBlocked(): boolean;
  28426. /**
  28427. * Returns the mesh itself by default. Implemented by child classes
  28428. * @param camera defines the camera to use to pick the right LOD level
  28429. * @returns the currentAbstractMesh
  28430. */
  28431. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28432. /**
  28433. * Returns 0 by default. Implemented by child classes
  28434. * @returns an integer
  28435. */
  28436. getTotalVertices(): number;
  28437. /**
  28438. * Returns a positive integer : the total number of indices in this mesh geometry.
  28439. * @returns the numner of indices or zero if the mesh has no geometry.
  28440. */
  28441. getTotalIndices(): number;
  28442. /**
  28443. * Returns null by default. Implemented by child classes
  28444. * @returns null
  28445. */
  28446. getIndices(): Nullable<IndicesArray>;
  28447. /**
  28448. * Returns the array of the requested vertex data kind. Implemented by child classes
  28449. * @param kind defines the vertex data kind to use
  28450. * @returns null
  28451. */
  28452. getVerticesData(kind: string): Nullable<FloatArray>;
  28453. /**
  28454. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28455. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28456. * Note that a new underlying VertexBuffer object is created each call.
  28457. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28458. * @param kind defines vertex data kind:
  28459. * * VertexBuffer.PositionKind
  28460. * * VertexBuffer.UVKind
  28461. * * VertexBuffer.UV2Kind
  28462. * * VertexBuffer.UV3Kind
  28463. * * VertexBuffer.UV4Kind
  28464. * * VertexBuffer.UV5Kind
  28465. * * VertexBuffer.UV6Kind
  28466. * * VertexBuffer.ColorKind
  28467. * * VertexBuffer.MatricesIndicesKind
  28468. * * VertexBuffer.MatricesIndicesExtraKind
  28469. * * VertexBuffer.MatricesWeightsKind
  28470. * * VertexBuffer.MatricesWeightsExtraKind
  28471. * @param data defines the data source
  28472. * @param updatable defines if the data must be flagged as updatable (or static)
  28473. * @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
  28474. * @returns the current mesh
  28475. */
  28476. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28477. /**
  28478. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28479. * If the mesh has no geometry, it is simply returned as it is.
  28480. * @param kind defines vertex data kind:
  28481. * * VertexBuffer.PositionKind
  28482. * * VertexBuffer.UVKind
  28483. * * VertexBuffer.UV2Kind
  28484. * * VertexBuffer.UV3Kind
  28485. * * VertexBuffer.UV4Kind
  28486. * * VertexBuffer.UV5Kind
  28487. * * VertexBuffer.UV6Kind
  28488. * * VertexBuffer.ColorKind
  28489. * * VertexBuffer.MatricesIndicesKind
  28490. * * VertexBuffer.MatricesIndicesExtraKind
  28491. * * VertexBuffer.MatricesWeightsKind
  28492. * * VertexBuffer.MatricesWeightsExtraKind
  28493. * @param data defines the data source
  28494. * @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
  28495. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28496. * @returns the current mesh
  28497. */
  28498. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28499. /**
  28500. * Sets the mesh indices,
  28501. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28502. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28503. * @param totalVertices Defines the total number of vertices
  28504. * @returns the current mesh
  28505. */
  28506. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28507. /**
  28508. * Gets a boolean indicating if specific vertex data is present
  28509. * @param kind defines the vertex data kind to use
  28510. * @returns true is data kind is present
  28511. */
  28512. isVerticesDataPresent(kind: string): boolean;
  28513. /**
  28514. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28515. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28516. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28517. * @returns a BoundingInfo
  28518. */
  28519. getBoundingInfo(): BoundingInfo;
  28520. /**
  28521. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28522. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28523. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28524. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28525. * @returns the current mesh
  28526. */
  28527. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28528. /**
  28529. * Overwrite the current bounding info
  28530. * @param boundingInfo defines the new bounding info
  28531. * @returns the current mesh
  28532. */
  28533. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28534. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28535. get useBones(): boolean;
  28536. /** @hidden */
  28537. _preActivate(): void;
  28538. /** @hidden */
  28539. _preActivateForIntermediateRendering(renderId: number): void;
  28540. /** @hidden */
  28541. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28542. /** @hidden */
  28543. _postActivate(): void;
  28544. /** @hidden */
  28545. _freeze(): void;
  28546. /** @hidden */
  28547. _unFreeze(): void;
  28548. /**
  28549. * Gets the current world matrix
  28550. * @returns a Matrix
  28551. */
  28552. getWorldMatrix(): Matrix;
  28553. /** @hidden */
  28554. _getWorldMatrixDeterminant(): number;
  28555. /**
  28556. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28557. */
  28558. get isAnInstance(): boolean;
  28559. /**
  28560. * Gets a boolean indicating if this mesh has instances
  28561. */
  28562. get hasInstances(): boolean;
  28563. /**
  28564. * Perform relative position change from the point of view of behind the front of the mesh.
  28565. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28566. * Supports definition of mesh facing forward or backward
  28567. * @param amountRight defines the distance on the right axis
  28568. * @param amountUp defines the distance on the up axis
  28569. * @param amountForward defines the distance on the forward axis
  28570. * @returns the current mesh
  28571. */
  28572. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28573. /**
  28574. * Calculate relative position change from the point of view of behind the front of the mesh.
  28575. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28576. * Supports definition of mesh facing forward or backward
  28577. * @param amountRight defines the distance on the right axis
  28578. * @param amountUp defines the distance on the up axis
  28579. * @param amountForward defines the distance on the forward axis
  28580. * @returns the new displacement vector
  28581. */
  28582. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28583. /**
  28584. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28585. * Supports definition of mesh facing forward or backward
  28586. * @param flipBack defines the flip
  28587. * @param twirlClockwise defines the twirl
  28588. * @param tiltRight defines the tilt
  28589. * @returns the current mesh
  28590. */
  28591. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28592. /**
  28593. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28594. * Supports definition of mesh facing forward or backward.
  28595. * @param flipBack defines the flip
  28596. * @param twirlClockwise defines the twirl
  28597. * @param tiltRight defines the tilt
  28598. * @returns the new rotation vector
  28599. */
  28600. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28601. /**
  28602. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28603. * This means the mesh underlying bounding box and sphere are recomputed.
  28604. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28605. * @returns the current mesh
  28606. */
  28607. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28608. /** @hidden */
  28609. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28610. /** @hidden */
  28611. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28612. /** @hidden */
  28613. _updateBoundingInfo(): AbstractMesh;
  28614. /** @hidden */
  28615. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28616. /** @hidden */
  28617. protected _afterComputeWorldMatrix(): void;
  28618. /** @hidden */
  28619. get _effectiveMesh(): AbstractMesh;
  28620. /**
  28621. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28622. * A mesh is in the frustum if its bounding box intersects the frustum
  28623. * @param frustumPlanes defines the frustum to test
  28624. * @returns true if the mesh is in the frustum planes
  28625. */
  28626. isInFrustum(frustumPlanes: Plane[]): boolean;
  28627. /**
  28628. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28629. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28630. * @param frustumPlanes defines the frustum to test
  28631. * @returns true if the mesh is completely in the frustum planes
  28632. */
  28633. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28634. /**
  28635. * True if the mesh intersects another mesh or a SolidParticle object
  28636. * @param mesh defines a target mesh or SolidParticle to test
  28637. * @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)
  28638. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28639. * @returns true if there is an intersection
  28640. */
  28641. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28642. /**
  28643. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28644. * @param point defines the point to test
  28645. * @returns true if there is an intersection
  28646. */
  28647. intersectsPoint(point: Vector3): boolean;
  28648. /**
  28649. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28650. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28651. */
  28652. get checkCollisions(): boolean;
  28653. set checkCollisions(collisionEnabled: boolean);
  28654. /**
  28655. * Gets Collider object used to compute collisions (not physics)
  28656. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28657. */
  28658. get collider(): Nullable<Collider>;
  28659. /**
  28660. * Move the mesh using collision engine
  28661. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28662. * @param displacement defines the requested displacement vector
  28663. * @returns the current mesh
  28664. */
  28665. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28666. private _onCollisionPositionChange;
  28667. /** @hidden */
  28668. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28669. /** @hidden */
  28670. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28671. /** @hidden */
  28672. _checkCollision(collider: Collider): AbstractMesh;
  28673. /** @hidden */
  28674. _generatePointsArray(): boolean;
  28675. /**
  28676. * Checks if the passed Ray intersects with the mesh
  28677. * @param ray defines the ray to use
  28678. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28679. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28680. * @returns the picking info
  28681. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28682. */
  28683. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28684. /**
  28685. * Clones the current mesh
  28686. * @param name defines the mesh name
  28687. * @param newParent defines the new mesh parent
  28688. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28689. * @returns the new mesh
  28690. */
  28691. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28692. /**
  28693. * Disposes all the submeshes of the current meshnp
  28694. * @returns the current mesh
  28695. */
  28696. releaseSubMeshes(): AbstractMesh;
  28697. /**
  28698. * Releases resources associated with this abstract mesh.
  28699. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28700. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28701. */
  28702. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28703. /**
  28704. * Adds the passed mesh as a child to the current mesh
  28705. * @param mesh defines the child mesh
  28706. * @returns the current mesh
  28707. */
  28708. addChild(mesh: AbstractMesh): AbstractMesh;
  28709. /**
  28710. * Removes the passed mesh from the current mesh children list
  28711. * @param mesh defines the child mesh
  28712. * @returns the current mesh
  28713. */
  28714. removeChild(mesh: AbstractMesh): AbstractMesh;
  28715. /** @hidden */
  28716. private _initFacetData;
  28717. /**
  28718. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28719. * This method can be called within the render loop.
  28720. * 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
  28721. * @returns the current mesh
  28722. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28723. */
  28724. updateFacetData(): AbstractMesh;
  28725. /**
  28726. * Returns the facetLocalNormals array.
  28727. * The normals are expressed in the mesh local spac
  28728. * @returns an array of Vector3
  28729. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28730. */
  28731. getFacetLocalNormals(): Vector3[];
  28732. /**
  28733. * Returns the facetLocalPositions array.
  28734. * The facet positions are expressed in the mesh local space
  28735. * @returns an array of Vector3
  28736. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28737. */
  28738. getFacetLocalPositions(): Vector3[];
  28739. /**
  28740. * Returns the facetLocalPartioning array
  28741. * @returns an array of array of numbers
  28742. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28743. */
  28744. getFacetLocalPartitioning(): number[][];
  28745. /**
  28746. * Returns the i-th facet position in the world system.
  28747. * This method allocates a new Vector3 per call
  28748. * @param i defines the facet index
  28749. * @returns a new Vector3
  28750. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28751. */
  28752. getFacetPosition(i: number): Vector3;
  28753. /**
  28754. * Sets the reference Vector3 with the i-th facet position in the world system
  28755. * @param i defines the facet index
  28756. * @param ref defines the target vector
  28757. * @returns the current mesh
  28758. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28759. */
  28760. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28761. /**
  28762. * Returns the i-th facet normal in the world system.
  28763. * This method allocates a new Vector3 per call
  28764. * @param i defines the facet index
  28765. * @returns a new Vector3
  28766. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28767. */
  28768. getFacetNormal(i: number): Vector3;
  28769. /**
  28770. * Sets the reference Vector3 with the i-th facet normal in the world system
  28771. * @param i defines the facet index
  28772. * @param ref defines the target vector
  28773. * @returns the current mesh
  28774. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28775. */
  28776. getFacetNormalToRef(i: number, ref: Vector3): this;
  28777. /**
  28778. * 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)
  28779. * @param x defines x coordinate
  28780. * @param y defines y coordinate
  28781. * @param z defines z coordinate
  28782. * @returns the array of facet indexes
  28783. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28784. */
  28785. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28786. /**
  28787. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28788. * @param projected sets as the (x,y,z) world projection on the facet
  28789. * @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
  28790. * @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
  28791. * @param x defines x coordinate
  28792. * @param y defines y coordinate
  28793. * @param z defines z coordinate
  28794. * @returns the face index if found (or null instead)
  28795. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28796. */
  28797. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28798. /**
  28799. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28800. * @param projected sets as the (x,y,z) local projection on the facet
  28801. * @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
  28802. * @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
  28803. * @param x defines x coordinate
  28804. * @param y defines y coordinate
  28805. * @param z defines z coordinate
  28806. * @returns the face index if found (or null instead)
  28807. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28808. */
  28809. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28810. /**
  28811. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28812. * @returns the parameters
  28813. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28814. */
  28815. getFacetDataParameters(): any;
  28816. /**
  28817. * Disables the feature FacetData and frees the related memory
  28818. * @returns the current mesh
  28819. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28820. */
  28821. disableFacetData(): AbstractMesh;
  28822. /**
  28823. * Updates the AbstractMesh indices array
  28824. * @param indices defines the data source
  28825. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28826. * @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)
  28827. * @returns the current mesh
  28828. */
  28829. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28830. /**
  28831. * Creates new normals data for the mesh
  28832. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28833. * @returns the current mesh
  28834. */
  28835. createNormals(updatable: boolean): AbstractMesh;
  28836. /**
  28837. * Align the mesh with a normal
  28838. * @param normal defines the normal to use
  28839. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28840. * @returns the current mesh
  28841. */
  28842. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28843. /** @hidden */
  28844. _checkOcclusionQuery(): boolean;
  28845. /**
  28846. * Disables the mesh edge rendering mode
  28847. * @returns the currentAbstractMesh
  28848. */
  28849. disableEdgesRendering(): AbstractMesh;
  28850. /**
  28851. * Enables the edge rendering mode on the mesh.
  28852. * This mode makes the mesh edges visible
  28853. * @param epsilon defines the maximal distance between two angles to detect a face
  28854. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28855. * @returns the currentAbstractMesh
  28856. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28857. */
  28858. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28859. }
  28860. }
  28861. declare module BABYLON {
  28862. /**
  28863. * Interface used to define ActionEvent
  28864. */
  28865. export interface IActionEvent {
  28866. /** The mesh or sprite that triggered the action */
  28867. source: any;
  28868. /** The X mouse cursor position at the time of the event */
  28869. pointerX: number;
  28870. /** The Y mouse cursor position at the time of the event */
  28871. pointerY: number;
  28872. /** The mesh that is currently pointed at (can be null) */
  28873. meshUnderPointer: Nullable<AbstractMesh>;
  28874. /** the original (browser) event that triggered the ActionEvent */
  28875. sourceEvent?: any;
  28876. /** additional data for the event */
  28877. additionalData?: any;
  28878. }
  28879. /**
  28880. * ActionEvent is the event being sent when an action is triggered.
  28881. */
  28882. export class ActionEvent implements IActionEvent {
  28883. /** The mesh or sprite that triggered the action */
  28884. source: any;
  28885. /** The X mouse cursor position at the time of the event */
  28886. pointerX: number;
  28887. /** The Y mouse cursor position at the time of the event */
  28888. pointerY: number;
  28889. /** The mesh that is currently pointed at (can be null) */
  28890. meshUnderPointer: Nullable<AbstractMesh>;
  28891. /** the original (browser) event that triggered the ActionEvent */
  28892. sourceEvent?: any;
  28893. /** additional data for the event */
  28894. additionalData?: any;
  28895. /**
  28896. * Creates a new ActionEvent
  28897. * @param source The mesh or sprite that triggered the action
  28898. * @param pointerX The X mouse cursor position at the time of the event
  28899. * @param pointerY The Y mouse cursor position at the time of the event
  28900. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28901. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28902. * @param additionalData additional data for the event
  28903. */
  28904. constructor(
  28905. /** The mesh or sprite that triggered the action */
  28906. source: any,
  28907. /** The X mouse cursor position at the time of the event */
  28908. pointerX: number,
  28909. /** The Y mouse cursor position at the time of the event */
  28910. pointerY: number,
  28911. /** The mesh that is currently pointed at (can be null) */
  28912. meshUnderPointer: Nullable<AbstractMesh>,
  28913. /** the original (browser) event that triggered the ActionEvent */
  28914. sourceEvent?: any,
  28915. /** additional data for the event */
  28916. additionalData?: any);
  28917. /**
  28918. * Helper function to auto-create an ActionEvent from a source mesh.
  28919. * @param source The source mesh that triggered the event
  28920. * @param evt The original (browser) event
  28921. * @param additionalData additional data for the event
  28922. * @returns the new ActionEvent
  28923. */
  28924. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28925. /**
  28926. * Helper function to auto-create an ActionEvent from a source sprite
  28927. * @param source The source sprite that triggered the event
  28928. * @param scene Scene associated with the sprite
  28929. * @param evt The original (browser) event
  28930. * @param additionalData additional data for the event
  28931. * @returns the new ActionEvent
  28932. */
  28933. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28934. /**
  28935. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28936. * @param scene the scene where the event occurred
  28937. * @param evt The original (browser) event
  28938. * @returns the new ActionEvent
  28939. */
  28940. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  28941. /**
  28942. * Helper function to auto-create an ActionEvent from a primitive
  28943. * @param prim defines the target primitive
  28944. * @param pointerPos defines the pointer position
  28945. * @param evt The original (browser) event
  28946. * @param additionalData additional data for the event
  28947. * @returns the new ActionEvent
  28948. */
  28949. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  28950. }
  28951. }
  28952. declare module BABYLON {
  28953. /**
  28954. * Abstract class used to decouple action Manager from scene and meshes.
  28955. * Do not instantiate.
  28956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28957. */
  28958. export abstract class AbstractActionManager implements IDisposable {
  28959. /** Gets the list of active triggers */
  28960. static Triggers: {
  28961. [key: string]: number;
  28962. };
  28963. /** Gets the cursor to use when hovering items */
  28964. hoverCursor: string;
  28965. /** Gets the list of actions */
  28966. actions: IAction[];
  28967. /**
  28968. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  28969. */
  28970. isRecursive: boolean;
  28971. /**
  28972. * Releases all associated resources
  28973. */
  28974. abstract dispose(): void;
  28975. /**
  28976. * Does this action manager has pointer triggers
  28977. */
  28978. abstract get hasPointerTriggers(): boolean;
  28979. /**
  28980. * Does this action manager has pick triggers
  28981. */
  28982. abstract get hasPickTriggers(): boolean;
  28983. /**
  28984. * Process a specific trigger
  28985. * @param trigger defines the trigger to process
  28986. * @param evt defines the event details to be processed
  28987. */
  28988. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  28989. /**
  28990. * Does this action manager handles actions of any of the given triggers
  28991. * @param triggers defines the triggers to be tested
  28992. * @return a boolean indicating whether one (or more) of the triggers is handled
  28993. */
  28994. abstract hasSpecificTriggers(triggers: number[]): boolean;
  28995. /**
  28996. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  28997. * speed.
  28998. * @param triggerA defines the trigger to be tested
  28999. * @param triggerB defines the trigger to be tested
  29000. * @return a boolean indicating whether one (or more) of the triggers is handled
  29001. */
  29002. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29003. /**
  29004. * Does this action manager handles actions of a given trigger
  29005. * @param trigger defines the trigger to be tested
  29006. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29007. * @return whether the trigger is handled
  29008. */
  29009. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29010. /**
  29011. * Serialize this manager to a JSON object
  29012. * @param name defines the property name to store this manager
  29013. * @returns a JSON representation of this manager
  29014. */
  29015. abstract serialize(name: string): any;
  29016. /**
  29017. * Registers an action to this action manager
  29018. * @param action defines the action to be registered
  29019. * @return the action amended (prepared) after registration
  29020. */
  29021. abstract registerAction(action: IAction): Nullable<IAction>;
  29022. /**
  29023. * Unregisters an action to this action manager
  29024. * @param action defines the action to be unregistered
  29025. * @return a boolean indicating whether the action has been unregistered
  29026. */
  29027. abstract unregisterAction(action: IAction): Boolean;
  29028. /**
  29029. * Does exist one action manager with at least one trigger
  29030. **/
  29031. static get HasTriggers(): boolean;
  29032. /**
  29033. * Does exist one action manager with at least one pick trigger
  29034. **/
  29035. static get HasPickTriggers(): boolean;
  29036. /**
  29037. * Does exist one action manager that handles actions of a given trigger
  29038. * @param trigger defines the trigger to be tested
  29039. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29040. **/
  29041. static HasSpecificTrigger(trigger: number): boolean;
  29042. }
  29043. }
  29044. declare module BABYLON {
  29045. /**
  29046. * Defines how a node can be built from a string name.
  29047. */
  29048. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29049. /**
  29050. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29051. */
  29052. export class Node implements IBehaviorAware<Node> {
  29053. /** @hidden */
  29054. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  29055. private static _NodeConstructors;
  29056. /**
  29057. * Add a new node constructor
  29058. * @param type defines the type name of the node to construct
  29059. * @param constructorFunc defines the constructor function
  29060. */
  29061. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29062. /**
  29063. * Returns a node constructor based on type name
  29064. * @param type defines the type name
  29065. * @param name defines the new node name
  29066. * @param scene defines the hosting scene
  29067. * @param options defines optional options to transmit to constructors
  29068. * @returns the new constructor or null
  29069. */
  29070. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29071. /**
  29072. * Gets or sets the name of the node
  29073. */
  29074. name: string;
  29075. /**
  29076. * Gets or sets the id of the node
  29077. */
  29078. id: string;
  29079. /**
  29080. * Gets or sets the unique id of the node
  29081. */
  29082. uniqueId: number;
  29083. /**
  29084. * Gets or sets a string used to store user defined state for the node
  29085. */
  29086. state: string;
  29087. /**
  29088. * Gets or sets an object used to store user defined information for the node
  29089. */
  29090. metadata: any;
  29091. /**
  29092. * For internal use only. Please do not use.
  29093. */
  29094. reservedDataStore: any;
  29095. /**
  29096. * List of inspectable custom properties (used by the Inspector)
  29097. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29098. */
  29099. inspectableCustomProperties: IInspectable[];
  29100. private _doNotSerialize;
  29101. /**
  29102. * Gets or sets a boolean used to define if the node must be serialized
  29103. */
  29104. get doNotSerialize(): boolean;
  29105. set doNotSerialize(value: boolean);
  29106. /** @hidden */
  29107. _isDisposed: boolean;
  29108. /**
  29109. * Gets a list of Animations associated with the node
  29110. */
  29111. animations: Animation[];
  29112. protected _ranges: {
  29113. [name: string]: Nullable<AnimationRange>;
  29114. };
  29115. /**
  29116. * Callback raised when the node is ready to be used
  29117. */
  29118. onReady: Nullable<(node: Node) => void>;
  29119. private _isEnabled;
  29120. private _isParentEnabled;
  29121. private _isReady;
  29122. /** @hidden */
  29123. _currentRenderId: number;
  29124. private _parentUpdateId;
  29125. /** @hidden */
  29126. _childUpdateId: number;
  29127. /** @hidden */
  29128. _waitingParentId: Nullable<string>;
  29129. /** @hidden */
  29130. _scene: Scene;
  29131. /** @hidden */
  29132. _cache: any;
  29133. private _parentNode;
  29134. private _children;
  29135. /** @hidden */
  29136. _worldMatrix: Matrix;
  29137. /** @hidden */
  29138. _worldMatrixDeterminant: number;
  29139. /** @hidden */
  29140. _worldMatrixDeterminantIsDirty: boolean;
  29141. /** @hidden */
  29142. private _sceneRootNodesIndex;
  29143. /**
  29144. * Gets a boolean indicating if the node has been disposed
  29145. * @returns true if the node was disposed
  29146. */
  29147. isDisposed(): boolean;
  29148. /**
  29149. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29150. * @see https://doc.babylonjs.com/how_to/parenting
  29151. */
  29152. set parent(parent: Nullable<Node>);
  29153. get parent(): Nullable<Node>;
  29154. /** @hidden */
  29155. _addToSceneRootNodes(): void;
  29156. /** @hidden */
  29157. _removeFromSceneRootNodes(): void;
  29158. private _animationPropertiesOverride;
  29159. /**
  29160. * Gets or sets the animation properties override
  29161. */
  29162. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29163. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29164. /**
  29165. * Gets a string idenfifying the name of the class
  29166. * @returns "Node" string
  29167. */
  29168. getClassName(): string;
  29169. /** @hidden */
  29170. readonly _isNode: boolean;
  29171. /**
  29172. * An event triggered when the mesh is disposed
  29173. */
  29174. onDisposeObservable: Observable<Node>;
  29175. private _onDisposeObserver;
  29176. /**
  29177. * Sets a callback that will be raised when the node will be disposed
  29178. */
  29179. set onDispose(callback: () => void);
  29180. /**
  29181. * Creates a new Node
  29182. * @param name the name and id to be given to this node
  29183. * @param scene the scene this node will be added to
  29184. */
  29185. constructor(name: string, scene?: Nullable<Scene>);
  29186. /**
  29187. * Gets the scene of the node
  29188. * @returns a scene
  29189. */
  29190. getScene(): Scene;
  29191. /**
  29192. * Gets the engine of the node
  29193. * @returns a Engine
  29194. */
  29195. getEngine(): Engine;
  29196. private _behaviors;
  29197. /**
  29198. * Attach a behavior to the node
  29199. * @see http://doc.babylonjs.com/features/behaviour
  29200. * @param behavior defines the behavior to attach
  29201. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29202. * @returns the current Node
  29203. */
  29204. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29205. /**
  29206. * Remove an attached behavior
  29207. * @see http://doc.babylonjs.com/features/behaviour
  29208. * @param behavior defines the behavior to attach
  29209. * @returns the current Node
  29210. */
  29211. removeBehavior(behavior: Behavior<Node>): Node;
  29212. /**
  29213. * Gets the list of attached behaviors
  29214. * @see http://doc.babylonjs.com/features/behaviour
  29215. */
  29216. get behaviors(): Behavior<Node>[];
  29217. /**
  29218. * Gets an attached behavior by name
  29219. * @param name defines the name of the behavior to look for
  29220. * @see http://doc.babylonjs.com/features/behaviour
  29221. * @returns null if behavior was not found else the requested behavior
  29222. */
  29223. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29224. /**
  29225. * Returns the latest update of the World matrix
  29226. * @returns a Matrix
  29227. */
  29228. getWorldMatrix(): Matrix;
  29229. /** @hidden */
  29230. _getWorldMatrixDeterminant(): number;
  29231. /**
  29232. * Returns directly the latest state of the mesh World matrix.
  29233. * A Matrix is returned.
  29234. */
  29235. get worldMatrixFromCache(): Matrix;
  29236. /** @hidden */
  29237. _initCache(): void;
  29238. /** @hidden */
  29239. updateCache(force?: boolean): void;
  29240. /** @hidden */
  29241. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29242. /** @hidden */
  29243. _updateCache(ignoreParentClass?: boolean): void;
  29244. /** @hidden */
  29245. _isSynchronized(): boolean;
  29246. /** @hidden */
  29247. _markSyncedWithParent(): void;
  29248. /** @hidden */
  29249. isSynchronizedWithParent(): boolean;
  29250. /** @hidden */
  29251. isSynchronized(): boolean;
  29252. /**
  29253. * Is this node ready to be used/rendered
  29254. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29255. * @return true if the node is ready
  29256. */
  29257. isReady(completeCheck?: boolean): boolean;
  29258. /**
  29259. * Is this node enabled?
  29260. * 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
  29261. * @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
  29262. * @return whether this node (and its parent) is enabled
  29263. */
  29264. isEnabled(checkAncestors?: boolean): boolean;
  29265. /** @hidden */
  29266. protected _syncParentEnabledState(): void;
  29267. /**
  29268. * Set the enabled state of this node
  29269. * @param value defines the new enabled state
  29270. */
  29271. setEnabled(value: boolean): void;
  29272. /**
  29273. * Is this node a descendant of the given node?
  29274. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29275. * @param ancestor defines the parent node to inspect
  29276. * @returns a boolean indicating if this node is a descendant of the given node
  29277. */
  29278. isDescendantOf(ancestor: Node): boolean;
  29279. /** @hidden */
  29280. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29281. /**
  29282. * Will return all nodes that have this node as ascendant
  29283. * @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
  29284. * @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
  29285. * @return all children nodes of all types
  29286. */
  29287. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29288. /**
  29289. * Get all child-meshes of this node
  29290. * @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)
  29291. * @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
  29292. * @returns an array of AbstractMesh
  29293. */
  29294. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29295. /**
  29296. * Get all direct children of this node
  29297. * @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
  29298. * @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)
  29299. * @returns an array of Node
  29300. */
  29301. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29302. /** @hidden */
  29303. _setReady(state: boolean): void;
  29304. /**
  29305. * Get an animation by name
  29306. * @param name defines the name of the animation to look for
  29307. * @returns null if not found else the requested animation
  29308. */
  29309. getAnimationByName(name: string): Nullable<Animation>;
  29310. /**
  29311. * Creates an animation range for this node
  29312. * @param name defines the name of the range
  29313. * @param from defines the starting key
  29314. * @param to defines the end key
  29315. */
  29316. createAnimationRange(name: string, from: number, to: number): void;
  29317. /**
  29318. * Delete a specific animation range
  29319. * @param name defines the name of the range to delete
  29320. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29321. */
  29322. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29323. /**
  29324. * Get an animation range by name
  29325. * @param name defines the name of the animation range to look for
  29326. * @returns null if not found else the requested animation range
  29327. */
  29328. getAnimationRange(name: string): Nullable<AnimationRange>;
  29329. /**
  29330. * Gets the list of all animation ranges defined on this node
  29331. * @returns an array
  29332. */
  29333. getAnimationRanges(): Nullable<AnimationRange>[];
  29334. /**
  29335. * Will start the animation sequence
  29336. * @param name defines the range frames for animation sequence
  29337. * @param loop defines if the animation should loop (false by default)
  29338. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29339. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29340. * @returns the object created for this animation. If range does not exist, it will return null
  29341. */
  29342. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29343. /**
  29344. * Serialize animation ranges into a JSON compatible object
  29345. * @returns serialization object
  29346. */
  29347. serializeAnimationRanges(): any;
  29348. /**
  29349. * Computes the world matrix of the node
  29350. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29351. * @returns the world matrix
  29352. */
  29353. computeWorldMatrix(force?: boolean): Matrix;
  29354. /**
  29355. * Releases resources associated with this node.
  29356. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29357. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29358. */
  29359. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29360. /**
  29361. * Parse animation range data from a serialization object and store them into a given node
  29362. * @param node defines where to store the animation ranges
  29363. * @param parsedNode defines the serialization object to read data from
  29364. * @param scene defines the hosting scene
  29365. */
  29366. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29367. /**
  29368. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29369. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29370. * @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
  29371. * @returns the new bounding vectors
  29372. */
  29373. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29374. min: Vector3;
  29375. max: Vector3;
  29376. };
  29377. }
  29378. }
  29379. declare module BABYLON {
  29380. /**
  29381. * @hidden
  29382. */
  29383. export class _IAnimationState {
  29384. key: number;
  29385. repeatCount: number;
  29386. workValue?: any;
  29387. loopMode?: number;
  29388. offsetValue?: any;
  29389. highLimitValue?: any;
  29390. }
  29391. /**
  29392. * Class used to store any kind of animation
  29393. */
  29394. export class Animation {
  29395. /**Name of the animation */
  29396. name: string;
  29397. /**Property to animate */
  29398. targetProperty: string;
  29399. /**The frames per second of the animation */
  29400. framePerSecond: number;
  29401. /**The data type of the animation */
  29402. dataType: number;
  29403. /**The loop mode of the animation */
  29404. loopMode?: number | undefined;
  29405. /**Specifies if blending should be enabled */
  29406. enableBlending?: boolean | undefined;
  29407. /**
  29408. * Use matrix interpolation instead of using direct key value when animating matrices
  29409. */
  29410. static AllowMatricesInterpolation: boolean;
  29411. /**
  29412. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29413. */
  29414. static AllowMatrixDecomposeForInterpolation: boolean;
  29415. /**
  29416. * Stores the key frames of the animation
  29417. */
  29418. private _keys;
  29419. /**
  29420. * Stores the easing function of the animation
  29421. */
  29422. private _easingFunction;
  29423. /**
  29424. * @hidden Internal use only
  29425. */
  29426. _runtimeAnimations: RuntimeAnimation[];
  29427. /**
  29428. * The set of event that will be linked to this animation
  29429. */
  29430. private _events;
  29431. /**
  29432. * Stores an array of target property paths
  29433. */
  29434. targetPropertyPath: string[];
  29435. /**
  29436. * Stores the blending speed of the animation
  29437. */
  29438. blendingSpeed: number;
  29439. /**
  29440. * Stores the animation ranges for the animation
  29441. */
  29442. private _ranges;
  29443. /**
  29444. * @hidden Internal use
  29445. */
  29446. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29447. /**
  29448. * Sets up an animation
  29449. * @param property The property to animate
  29450. * @param animationType The animation type to apply
  29451. * @param framePerSecond The frames per second of the animation
  29452. * @param easingFunction The easing function used in the animation
  29453. * @returns The created animation
  29454. */
  29455. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29456. /**
  29457. * Create and start an animation on a node
  29458. * @param name defines the name of the global animation that will be run on all nodes
  29459. * @param node defines the root node where the animation will take place
  29460. * @param targetProperty defines property to animate
  29461. * @param framePerSecond defines the number of frame per second yo use
  29462. * @param totalFrame defines the number of frames in total
  29463. * @param from defines the initial value
  29464. * @param to defines the final value
  29465. * @param loopMode defines which loop mode you want to use (off by default)
  29466. * @param easingFunction defines the easing function to use (linear by default)
  29467. * @param onAnimationEnd defines the callback to call when animation end
  29468. * @returns the animatable created for this animation
  29469. */
  29470. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29471. /**
  29472. * Create and start an animation on a node and its descendants
  29473. * @param name defines the name of the global animation that will be run on all nodes
  29474. * @param node defines the root node where the animation will take place
  29475. * @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
  29476. * @param targetProperty defines property to animate
  29477. * @param framePerSecond defines the number of frame per second to use
  29478. * @param totalFrame defines the number of frames in total
  29479. * @param from defines the initial value
  29480. * @param to defines the final value
  29481. * @param loopMode defines which loop mode you want to use (off by default)
  29482. * @param easingFunction defines the easing function to use (linear by default)
  29483. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29484. * @returns the list of animatables created for all nodes
  29485. * @example https://www.babylonjs-playground.com/#MH0VLI
  29486. */
  29487. 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[]>;
  29488. /**
  29489. * Creates a new animation, merges it with the existing animations and starts it
  29490. * @param name Name of the animation
  29491. * @param node Node which contains the scene that begins the animations
  29492. * @param targetProperty Specifies which property to animate
  29493. * @param framePerSecond The frames per second of the animation
  29494. * @param totalFrame The total number of frames
  29495. * @param from The frame at the beginning of the animation
  29496. * @param to The frame at the end of the animation
  29497. * @param loopMode Specifies the loop mode of the animation
  29498. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29499. * @param onAnimationEnd Callback to run once the animation is complete
  29500. * @returns Nullable animation
  29501. */
  29502. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29503. /**
  29504. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  29505. * @param sourceAnimation defines the Animation containing keyframes to convert
  29506. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  29507. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  29508. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  29509. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  29510. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  29511. */
  29512. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  29513. /**
  29514. * Transition property of an host to the target Value
  29515. * @param property The property to transition
  29516. * @param targetValue The target Value of the property
  29517. * @param host The object where the property to animate belongs
  29518. * @param scene Scene used to run the animation
  29519. * @param frameRate Framerate (in frame/s) to use
  29520. * @param transition The transition type we want to use
  29521. * @param duration The duration of the animation, in milliseconds
  29522. * @param onAnimationEnd Callback trigger at the end of the animation
  29523. * @returns Nullable animation
  29524. */
  29525. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29526. /**
  29527. * Return the array of runtime animations currently using this animation
  29528. */
  29529. get runtimeAnimations(): RuntimeAnimation[];
  29530. /**
  29531. * Specifies if any of the runtime animations are currently running
  29532. */
  29533. get hasRunningRuntimeAnimations(): boolean;
  29534. /**
  29535. * Initializes the animation
  29536. * @param name Name of the animation
  29537. * @param targetProperty Property to animate
  29538. * @param framePerSecond The frames per second of the animation
  29539. * @param dataType The data type of the animation
  29540. * @param loopMode The loop mode of the animation
  29541. * @param enableBlending Specifies if blending should be enabled
  29542. */
  29543. constructor(
  29544. /**Name of the animation */
  29545. name: string,
  29546. /**Property to animate */
  29547. targetProperty: string,
  29548. /**The frames per second of the animation */
  29549. framePerSecond: number,
  29550. /**The data type of the animation */
  29551. dataType: number,
  29552. /**The loop mode of the animation */
  29553. loopMode?: number | undefined,
  29554. /**Specifies if blending should be enabled */
  29555. enableBlending?: boolean | undefined);
  29556. /**
  29557. * Converts the animation to a string
  29558. * @param fullDetails support for multiple levels of logging within scene loading
  29559. * @returns String form of the animation
  29560. */
  29561. toString(fullDetails?: boolean): string;
  29562. /**
  29563. * Add an event to this animation
  29564. * @param event Event to add
  29565. */
  29566. addEvent(event: AnimationEvent): void;
  29567. /**
  29568. * Remove all events found at the given frame
  29569. * @param frame The frame to remove events from
  29570. */
  29571. removeEvents(frame: number): void;
  29572. /**
  29573. * Retrieves all the events from the animation
  29574. * @returns Events from the animation
  29575. */
  29576. getEvents(): AnimationEvent[];
  29577. /**
  29578. * Creates an animation range
  29579. * @param name Name of the animation range
  29580. * @param from Starting frame of the animation range
  29581. * @param to Ending frame of the animation
  29582. */
  29583. createRange(name: string, from: number, to: number): void;
  29584. /**
  29585. * Deletes an animation range by name
  29586. * @param name Name of the animation range to delete
  29587. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29588. */
  29589. deleteRange(name: string, deleteFrames?: boolean): void;
  29590. /**
  29591. * Gets the animation range by name, or null if not defined
  29592. * @param name Name of the animation range
  29593. * @returns Nullable animation range
  29594. */
  29595. getRange(name: string): Nullable<AnimationRange>;
  29596. /**
  29597. * Gets the key frames from the animation
  29598. * @returns The key frames of the animation
  29599. */
  29600. getKeys(): Array<IAnimationKey>;
  29601. /**
  29602. * Gets the highest frame rate of the animation
  29603. * @returns Highest frame rate of the animation
  29604. */
  29605. getHighestFrame(): number;
  29606. /**
  29607. * Gets the easing function of the animation
  29608. * @returns Easing function of the animation
  29609. */
  29610. getEasingFunction(): IEasingFunction;
  29611. /**
  29612. * Sets the easing function of the animation
  29613. * @param easingFunction A custom mathematical formula for animation
  29614. */
  29615. setEasingFunction(easingFunction: EasingFunction): void;
  29616. /**
  29617. * Interpolates a scalar linearly
  29618. * @param startValue Start value of the animation curve
  29619. * @param endValue End value of the animation curve
  29620. * @param gradient Scalar amount to interpolate
  29621. * @returns Interpolated scalar value
  29622. */
  29623. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29624. /**
  29625. * Interpolates a scalar cubically
  29626. * @param startValue Start value of the animation curve
  29627. * @param outTangent End tangent of the animation
  29628. * @param endValue End value of the animation curve
  29629. * @param inTangent Start tangent of the animation curve
  29630. * @param gradient Scalar amount to interpolate
  29631. * @returns Interpolated scalar value
  29632. */
  29633. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29634. /**
  29635. * Interpolates a quaternion using a spherical linear interpolation
  29636. * @param startValue Start value of the animation curve
  29637. * @param endValue End value of the animation curve
  29638. * @param gradient Scalar amount to interpolate
  29639. * @returns Interpolated quaternion value
  29640. */
  29641. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29642. /**
  29643. * Interpolates a quaternion cubically
  29644. * @param startValue Start value of the animation curve
  29645. * @param outTangent End tangent of the animation curve
  29646. * @param endValue End value of the animation curve
  29647. * @param inTangent Start tangent of the animation curve
  29648. * @param gradient Scalar amount to interpolate
  29649. * @returns Interpolated quaternion value
  29650. */
  29651. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29652. /**
  29653. * Interpolates a Vector3 linearl
  29654. * @param startValue Start value of the animation curve
  29655. * @param endValue End value of the animation curve
  29656. * @param gradient Scalar amount to interpolate
  29657. * @returns Interpolated scalar value
  29658. */
  29659. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29660. /**
  29661. * Interpolates a Vector3 cubically
  29662. * @param startValue Start value of the animation curve
  29663. * @param outTangent End tangent of the animation
  29664. * @param endValue End value of the animation curve
  29665. * @param inTangent Start tangent of the animation curve
  29666. * @param gradient Scalar amount to interpolate
  29667. * @returns InterpolatedVector3 value
  29668. */
  29669. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29670. /**
  29671. * Interpolates a Vector2 linearly
  29672. * @param startValue Start value of the animation curve
  29673. * @param endValue End value of the animation curve
  29674. * @param gradient Scalar amount to interpolate
  29675. * @returns Interpolated Vector2 value
  29676. */
  29677. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29678. /**
  29679. * Interpolates a Vector2 cubically
  29680. * @param startValue Start value of the animation curve
  29681. * @param outTangent End tangent of the animation
  29682. * @param endValue End value of the animation curve
  29683. * @param inTangent Start tangent of the animation curve
  29684. * @param gradient Scalar amount to interpolate
  29685. * @returns Interpolated Vector2 value
  29686. */
  29687. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29688. /**
  29689. * Interpolates a size linearly
  29690. * @param startValue Start value of the animation curve
  29691. * @param endValue End value of the animation curve
  29692. * @param gradient Scalar amount to interpolate
  29693. * @returns Interpolated Size value
  29694. */
  29695. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29696. /**
  29697. * Interpolates a Color3 linearly
  29698. * @param startValue Start value of the animation curve
  29699. * @param endValue End value of the animation curve
  29700. * @param gradient Scalar amount to interpolate
  29701. * @returns Interpolated Color3 value
  29702. */
  29703. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29704. /**
  29705. * Interpolates a Color4 linearly
  29706. * @param startValue Start value of the animation curve
  29707. * @param endValue End value of the animation curve
  29708. * @param gradient Scalar amount to interpolate
  29709. * @returns Interpolated Color3 value
  29710. */
  29711. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29712. /**
  29713. * @hidden Internal use only
  29714. */
  29715. _getKeyValue(value: any): any;
  29716. /**
  29717. * @hidden Internal use only
  29718. */
  29719. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29720. /**
  29721. * Defines the function to use to interpolate matrices
  29722. * @param startValue defines the start matrix
  29723. * @param endValue defines the end matrix
  29724. * @param gradient defines the gradient between both matrices
  29725. * @param result defines an optional target matrix where to store the interpolation
  29726. * @returns the interpolated matrix
  29727. */
  29728. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29729. /**
  29730. * Makes a copy of the animation
  29731. * @returns Cloned animation
  29732. */
  29733. clone(): Animation;
  29734. /**
  29735. * Sets the key frames of the animation
  29736. * @param values The animation key frames to set
  29737. */
  29738. setKeys(values: Array<IAnimationKey>): void;
  29739. /**
  29740. * Serializes the animation to an object
  29741. * @returns Serialized object
  29742. */
  29743. serialize(): any;
  29744. /**
  29745. * Float animation type
  29746. */
  29747. static readonly ANIMATIONTYPE_FLOAT: number;
  29748. /**
  29749. * Vector3 animation type
  29750. */
  29751. static readonly ANIMATIONTYPE_VECTOR3: number;
  29752. /**
  29753. * Quaternion animation type
  29754. */
  29755. static readonly ANIMATIONTYPE_QUATERNION: number;
  29756. /**
  29757. * Matrix animation type
  29758. */
  29759. static readonly ANIMATIONTYPE_MATRIX: number;
  29760. /**
  29761. * Color3 animation type
  29762. */
  29763. static readonly ANIMATIONTYPE_COLOR3: number;
  29764. /**
  29765. * Color3 animation type
  29766. */
  29767. static readonly ANIMATIONTYPE_COLOR4: number;
  29768. /**
  29769. * Vector2 animation type
  29770. */
  29771. static readonly ANIMATIONTYPE_VECTOR2: number;
  29772. /**
  29773. * Size animation type
  29774. */
  29775. static readonly ANIMATIONTYPE_SIZE: number;
  29776. /**
  29777. * Relative Loop Mode
  29778. */
  29779. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29780. /**
  29781. * Cycle Loop Mode
  29782. */
  29783. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29784. /**
  29785. * Constant Loop Mode
  29786. */
  29787. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29788. /** @hidden */
  29789. static _UniversalLerp(left: any, right: any, amount: number): any;
  29790. /**
  29791. * Parses an animation object and creates an animation
  29792. * @param parsedAnimation Parsed animation object
  29793. * @returns Animation object
  29794. */
  29795. static Parse(parsedAnimation: any): Animation;
  29796. /**
  29797. * Appends the serialized animations from the source animations
  29798. * @param source Source containing the animations
  29799. * @param destination Target to store the animations
  29800. */
  29801. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29802. }
  29803. }
  29804. declare module BABYLON {
  29805. /**
  29806. * Interface containing an array of animations
  29807. */
  29808. export interface IAnimatable {
  29809. /**
  29810. * Array of animations
  29811. */
  29812. animations: Nullable<Array<Animation>>;
  29813. }
  29814. }
  29815. declare module BABYLON {
  29816. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29817. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29818. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29819. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29820. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29821. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29822. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29823. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29824. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29825. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29826. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29827. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29828. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29829. /**
  29830. * Decorator used to define property that can be serialized as reference to a camera
  29831. * @param sourceName defines the name of the property to decorate
  29832. */
  29833. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29834. /**
  29835. * Class used to help serialization objects
  29836. */
  29837. export class SerializationHelper {
  29838. /** @hidden */
  29839. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29840. /** @hidden */
  29841. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29842. /** @hidden */
  29843. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29844. /** @hidden */
  29845. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29846. /**
  29847. * Appends the serialized animations from the source animations
  29848. * @param source Source containing the animations
  29849. * @param destination Target to store the animations
  29850. */
  29851. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29852. /**
  29853. * Static function used to serialized a specific entity
  29854. * @param entity defines the entity to serialize
  29855. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29856. * @returns a JSON compatible object representing the serialization of the entity
  29857. */
  29858. static Serialize<T>(entity: T, serializationObject?: any): any;
  29859. /**
  29860. * Creates a new entity from a serialization data object
  29861. * @param creationFunction defines a function used to instanciated the new entity
  29862. * @param source defines the source serialization data
  29863. * @param scene defines the hosting scene
  29864. * @param rootUrl defines the root url for resources
  29865. * @returns a new entity
  29866. */
  29867. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29868. /**
  29869. * Clones an object
  29870. * @param creationFunction defines the function used to instanciate the new object
  29871. * @param source defines the source object
  29872. * @returns the cloned object
  29873. */
  29874. static Clone<T>(creationFunction: () => T, source: T): T;
  29875. /**
  29876. * Instanciates a new object based on a source one (some data will be shared between both object)
  29877. * @param creationFunction defines the function used to instanciate the new object
  29878. * @param source defines the source object
  29879. * @returns the new object
  29880. */
  29881. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29882. }
  29883. }
  29884. declare module BABYLON {
  29885. /**
  29886. * Class used to manipulate GUIDs
  29887. */
  29888. export class GUID {
  29889. /**
  29890. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29891. * Be aware Math.random() could cause collisions, but:
  29892. * "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"
  29893. * @returns a pseudo random id
  29894. */
  29895. static RandomId(): string;
  29896. }
  29897. }
  29898. declare module BABYLON {
  29899. /**
  29900. * Base class of all the textures in babylon.
  29901. * It groups all the common properties the materials, post process, lights... might need
  29902. * in order to make a correct use of the texture.
  29903. */
  29904. export class BaseTexture implements IAnimatable {
  29905. /**
  29906. * Default anisotropic filtering level for the application.
  29907. * It is set to 4 as a good tradeoff between perf and quality.
  29908. */
  29909. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29910. /**
  29911. * Gets or sets the unique id of the texture
  29912. */
  29913. uniqueId: number;
  29914. /**
  29915. * Define the name of the texture.
  29916. */
  29917. name: string;
  29918. /**
  29919. * Gets or sets an object used to store user defined information.
  29920. */
  29921. metadata: any;
  29922. /**
  29923. * For internal use only. Please do not use.
  29924. */
  29925. reservedDataStore: any;
  29926. private _hasAlpha;
  29927. /**
  29928. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29929. */
  29930. set hasAlpha(value: boolean);
  29931. get hasAlpha(): boolean;
  29932. /**
  29933. * Defines if the alpha value should be determined via the rgb values.
  29934. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29935. */
  29936. getAlphaFromRGB: boolean;
  29937. /**
  29938. * Intensity or strength of the texture.
  29939. * It is commonly used by materials to fine tune the intensity of the texture
  29940. */
  29941. level: number;
  29942. /**
  29943. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29944. * This is part of the texture as textures usually maps to one uv set.
  29945. */
  29946. coordinatesIndex: number;
  29947. private _coordinatesMode;
  29948. /**
  29949. * How a texture is mapped.
  29950. *
  29951. * | Value | Type | Description |
  29952. * | ----- | ----------------------------------- | ----------- |
  29953. * | 0 | EXPLICIT_MODE | |
  29954. * | 1 | SPHERICAL_MODE | |
  29955. * | 2 | PLANAR_MODE | |
  29956. * | 3 | CUBIC_MODE | |
  29957. * | 4 | PROJECTION_MODE | |
  29958. * | 5 | SKYBOX_MODE | |
  29959. * | 6 | INVCUBIC_MODE | |
  29960. * | 7 | EQUIRECTANGULAR_MODE | |
  29961. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  29962. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  29963. */
  29964. set coordinatesMode(value: number);
  29965. get coordinatesMode(): number;
  29966. /**
  29967. * | Value | Type | Description |
  29968. * | ----- | ------------------ | ----------- |
  29969. * | 0 | CLAMP_ADDRESSMODE | |
  29970. * | 1 | WRAP_ADDRESSMODE | |
  29971. * | 2 | MIRROR_ADDRESSMODE | |
  29972. */
  29973. wrapU: number;
  29974. /**
  29975. * | Value | Type | Description |
  29976. * | ----- | ------------------ | ----------- |
  29977. * | 0 | CLAMP_ADDRESSMODE | |
  29978. * | 1 | WRAP_ADDRESSMODE | |
  29979. * | 2 | MIRROR_ADDRESSMODE | |
  29980. */
  29981. wrapV: number;
  29982. /**
  29983. * | Value | Type | Description |
  29984. * | ----- | ------------------ | ----------- |
  29985. * | 0 | CLAMP_ADDRESSMODE | |
  29986. * | 1 | WRAP_ADDRESSMODE | |
  29987. * | 2 | MIRROR_ADDRESSMODE | |
  29988. */
  29989. wrapR: number;
  29990. /**
  29991. * With compliant hardware and browser (supporting anisotropic filtering)
  29992. * this defines the level of anisotropic filtering in the texture.
  29993. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29994. */
  29995. anisotropicFilteringLevel: number;
  29996. /**
  29997. * Define if the texture is a cube texture or if false a 2d texture.
  29998. */
  29999. get isCube(): boolean;
  30000. set isCube(value: boolean);
  30001. /**
  30002. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30003. */
  30004. get is3D(): boolean;
  30005. set is3D(value: boolean);
  30006. /**
  30007. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30008. */
  30009. get is2DArray(): boolean;
  30010. set is2DArray(value: boolean);
  30011. /**
  30012. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30013. * HDR texture are usually stored in linear space.
  30014. * This only impacts the PBR and Background materials
  30015. */
  30016. gammaSpace: boolean;
  30017. /**
  30018. * Gets or sets whether or not the texture contains RGBD data.
  30019. */
  30020. get isRGBD(): boolean;
  30021. set isRGBD(value: boolean);
  30022. /**
  30023. * Is Z inverted in the texture (useful in a cube texture).
  30024. */
  30025. invertZ: boolean;
  30026. /**
  30027. * Are mip maps generated for this texture or not.
  30028. */
  30029. get noMipmap(): boolean;
  30030. /**
  30031. * @hidden
  30032. */
  30033. lodLevelInAlpha: boolean;
  30034. /**
  30035. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30036. */
  30037. get lodGenerationOffset(): number;
  30038. set lodGenerationOffset(value: number);
  30039. /**
  30040. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30041. */
  30042. get lodGenerationScale(): number;
  30043. set lodGenerationScale(value: number);
  30044. /**
  30045. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30046. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30047. * average roughness values.
  30048. */
  30049. get linearSpecularLOD(): boolean;
  30050. set linearSpecularLOD(value: boolean);
  30051. /**
  30052. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30053. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30054. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30055. */
  30056. get irradianceTexture(): Nullable<BaseTexture>;
  30057. set irradianceTexture(value: Nullable<BaseTexture>);
  30058. /**
  30059. * Define if the texture is a render target.
  30060. */
  30061. isRenderTarget: boolean;
  30062. /**
  30063. * Define the unique id of the texture in the scene.
  30064. */
  30065. get uid(): string;
  30066. /**
  30067. * Return a string representation of the texture.
  30068. * @returns the texture as a string
  30069. */
  30070. toString(): string;
  30071. /**
  30072. * Get the class name of the texture.
  30073. * @returns "BaseTexture"
  30074. */
  30075. getClassName(): string;
  30076. /**
  30077. * Define the list of animation attached to the texture.
  30078. */
  30079. animations: Animation[];
  30080. /**
  30081. * An event triggered when the texture is disposed.
  30082. */
  30083. onDisposeObservable: Observable<BaseTexture>;
  30084. private _onDisposeObserver;
  30085. /**
  30086. * Callback triggered when the texture has been disposed.
  30087. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30088. */
  30089. set onDispose(callback: () => void);
  30090. /**
  30091. * Define the current state of the loading sequence when in delayed load mode.
  30092. */
  30093. delayLoadState: number;
  30094. private _scene;
  30095. /** @hidden */
  30096. _texture: Nullable<InternalTexture>;
  30097. private _uid;
  30098. /**
  30099. * Define if the texture is preventinga material to render or not.
  30100. * If not and the texture is not ready, the engine will use a default black texture instead.
  30101. */
  30102. get isBlocking(): boolean;
  30103. /**
  30104. * Instantiates a new BaseTexture.
  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. * @param scene Define the scene the texture blongs to
  30109. */
  30110. constructor(scene: Nullable<Scene>);
  30111. /**
  30112. * Get the scene the texture belongs to.
  30113. * @returns the scene or null if undefined
  30114. */
  30115. getScene(): Nullable<Scene>;
  30116. /**
  30117. * Get the texture transform matrix used to offset tile the texture for istance.
  30118. * @returns the transformation matrix
  30119. */
  30120. getTextureMatrix(): Matrix;
  30121. /**
  30122. * Get the texture reflection matrix used to rotate/transform the reflection.
  30123. * @returns the reflection matrix
  30124. */
  30125. getReflectionTextureMatrix(): Matrix;
  30126. /**
  30127. * Get the underlying lower level texture from Babylon.
  30128. * @returns the insternal texture
  30129. */
  30130. getInternalTexture(): Nullable<InternalTexture>;
  30131. /**
  30132. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30133. * @returns true if ready or not blocking
  30134. */
  30135. isReadyOrNotBlocking(): boolean;
  30136. /**
  30137. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30138. * @returns true if fully ready
  30139. */
  30140. isReady(): boolean;
  30141. private _cachedSize;
  30142. /**
  30143. * Get the size of the texture.
  30144. * @returns the texture size.
  30145. */
  30146. getSize(): ISize;
  30147. /**
  30148. * Get the base size of the texture.
  30149. * It can be different from the size if the texture has been resized for POT for instance
  30150. * @returns the base size
  30151. */
  30152. getBaseSize(): ISize;
  30153. /**
  30154. * Update the sampling mode of the texture.
  30155. * Default is Trilinear mode.
  30156. *
  30157. * | Value | Type | Description |
  30158. * | ----- | ------------------ | ----------- |
  30159. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30160. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30161. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30162. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30163. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30164. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30165. * | 7 | NEAREST_LINEAR | |
  30166. * | 8 | NEAREST_NEAREST | |
  30167. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30168. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30169. * | 11 | LINEAR_LINEAR | |
  30170. * | 12 | LINEAR_NEAREST | |
  30171. *
  30172. * > _mag_: magnification filter (close to the viewer)
  30173. * > _min_: minification filter (far from the viewer)
  30174. * > _mip_: filter used between mip map levels
  30175. *@param samplingMode Define the new sampling mode of the texture
  30176. */
  30177. updateSamplingMode(samplingMode: number): void;
  30178. /**
  30179. * Scales the texture if is `canRescale()`
  30180. * @param ratio the resize factor we want to use to rescale
  30181. */
  30182. scale(ratio: number): void;
  30183. /**
  30184. * Get if the texture can rescale.
  30185. */
  30186. get canRescale(): boolean;
  30187. /** @hidden */
  30188. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30189. /** @hidden */
  30190. _rebuild(): void;
  30191. /**
  30192. * Triggers the load sequence in delayed load mode.
  30193. */
  30194. delayLoad(): void;
  30195. /**
  30196. * Clones the texture.
  30197. * @returns the cloned texture
  30198. */
  30199. clone(): Nullable<BaseTexture>;
  30200. /**
  30201. * Get the texture underlying type (INT, FLOAT...)
  30202. */
  30203. get textureType(): number;
  30204. /**
  30205. * Get the texture underlying format (RGB, RGBA...)
  30206. */
  30207. get textureFormat(): number;
  30208. /**
  30209. * Indicates that textures need to be re-calculated for all materials
  30210. */
  30211. protected _markAllSubMeshesAsTexturesDirty(): void;
  30212. /**
  30213. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30214. * This will returns an RGBA array buffer containing either in values (0-255) or
  30215. * float values (0-1) depending of the underlying buffer type.
  30216. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30217. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30218. * @param buffer defines a user defined buffer to fill with data (can be null)
  30219. * @returns The Array buffer containing the pixels data.
  30220. */
  30221. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30222. /**
  30223. * Release and destroy the underlying lower level texture aka internalTexture.
  30224. */
  30225. releaseInternalTexture(): void;
  30226. /** @hidden */
  30227. get _lodTextureHigh(): Nullable<BaseTexture>;
  30228. /** @hidden */
  30229. get _lodTextureMid(): Nullable<BaseTexture>;
  30230. /** @hidden */
  30231. get _lodTextureLow(): Nullable<BaseTexture>;
  30232. /**
  30233. * Dispose the texture and release its associated resources.
  30234. */
  30235. dispose(): void;
  30236. /**
  30237. * Serialize the texture into a JSON representation that can be parsed later on.
  30238. * @returns the JSON representation of the texture
  30239. */
  30240. serialize(): any;
  30241. /**
  30242. * Helper function to be called back once a list of texture contains only ready textures.
  30243. * @param textures Define the list of textures to wait for
  30244. * @param callback Define the callback triggered once the entire list will be ready
  30245. */
  30246. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30247. }
  30248. }
  30249. declare module BABYLON {
  30250. /**
  30251. * Options to be used when creating an effect.
  30252. */
  30253. export interface IEffectCreationOptions {
  30254. /**
  30255. * Atrributes that will be used in the shader.
  30256. */
  30257. attributes: string[];
  30258. /**
  30259. * Uniform varible names that will be set in the shader.
  30260. */
  30261. uniformsNames: string[];
  30262. /**
  30263. * Uniform buffer variable names that will be set in the shader.
  30264. */
  30265. uniformBuffersNames: string[];
  30266. /**
  30267. * Sampler texture variable names that will be set in the shader.
  30268. */
  30269. samplers: string[];
  30270. /**
  30271. * Define statements that will be set in the shader.
  30272. */
  30273. defines: any;
  30274. /**
  30275. * Possible fallbacks for this effect to improve performance when needed.
  30276. */
  30277. fallbacks: Nullable<IEffectFallbacks>;
  30278. /**
  30279. * Callback that will be called when the shader is compiled.
  30280. */
  30281. onCompiled: Nullable<(effect: Effect) => void>;
  30282. /**
  30283. * Callback that will be called if an error occurs during shader compilation.
  30284. */
  30285. onError: Nullable<(effect: Effect, errors: string) => void>;
  30286. /**
  30287. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30288. */
  30289. indexParameters?: any;
  30290. /**
  30291. * Max number of lights that can be used in the shader.
  30292. */
  30293. maxSimultaneousLights?: number;
  30294. /**
  30295. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30296. */
  30297. transformFeedbackVaryings?: Nullable<string[]>;
  30298. }
  30299. /**
  30300. * Effect containing vertex and fragment shader that can be executed on an object.
  30301. */
  30302. export class Effect implements IDisposable {
  30303. /**
  30304. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30305. */
  30306. static ShadersRepository: string;
  30307. /**
  30308. * Enable logging of the shader code when a compilation error occurs
  30309. */
  30310. static LogShaderCodeOnCompilationError: boolean;
  30311. /**
  30312. * Name of the effect.
  30313. */
  30314. name: any;
  30315. /**
  30316. * String container all the define statements that should be set on the shader.
  30317. */
  30318. defines: string;
  30319. /**
  30320. * Callback that will be called when the shader is compiled.
  30321. */
  30322. onCompiled: Nullable<(effect: Effect) => void>;
  30323. /**
  30324. * Callback that will be called if an error occurs during shader compilation.
  30325. */
  30326. onError: Nullable<(effect: Effect, errors: string) => void>;
  30327. /**
  30328. * Callback that will be called when effect is bound.
  30329. */
  30330. onBind: Nullable<(effect: Effect) => void>;
  30331. /**
  30332. * Unique ID of the effect.
  30333. */
  30334. uniqueId: number;
  30335. /**
  30336. * Observable that will be called when the shader is compiled.
  30337. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30338. */
  30339. onCompileObservable: Observable<Effect>;
  30340. /**
  30341. * Observable that will be called if an error occurs during shader compilation.
  30342. */
  30343. onErrorObservable: Observable<Effect>;
  30344. /** @hidden */
  30345. _onBindObservable: Nullable<Observable<Effect>>;
  30346. /**
  30347. * @hidden
  30348. * Specifies if the effect was previously ready
  30349. */
  30350. _wasPreviouslyReady: boolean;
  30351. /**
  30352. * Observable that will be called when effect is bound.
  30353. */
  30354. get onBindObservable(): Observable<Effect>;
  30355. /** @hidden */
  30356. _bonesComputationForcedToCPU: boolean;
  30357. private static _uniqueIdSeed;
  30358. private _engine;
  30359. private _uniformBuffersNames;
  30360. private _uniformsNames;
  30361. private _samplerList;
  30362. private _samplers;
  30363. private _isReady;
  30364. private _compilationError;
  30365. private _allFallbacksProcessed;
  30366. private _attributesNames;
  30367. private _attributes;
  30368. private _attributeLocationByName;
  30369. private _uniforms;
  30370. /**
  30371. * Key for the effect.
  30372. * @hidden
  30373. */
  30374. _key: string;
  30375. private _indexParameters;
  30376. private _fallbacks;
  30377. private _vertexSourceCode;
  30378. private _fragmentSourceCode;
  30379. private _vertexSourceCodeOverride;
  30380. private _fragmentSourceCodeOverride;
  30381. private _transformFeedbackVaryings;
  30382. /**
  30383. * Compiled shader to webGL program.
  30384. * @hidden
  30385. */
  30386. _pipelineContext: Nullable<IPipelineContext>;
  30387. private _valueCache;
  30388. private static _baseCache;
  30389. /**
  30390. * Instantiates an effect.
  30391. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30392. * @param baseName Name of the effect.
  30393. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30394. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30395. * @param samplers List of sampler variables that will be passed to the shader.
  30396. * @param engine Engine to be used to render the effect
  30397. * @param defines Define statements to be added to the shader.
  30398. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30399. * @param onCompiled Callback that will be called when the shader is compiled.
  30400. * @param onError Callback that will be called if an error occurs during shader compilation.
  30401. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30402. */
  30403. 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);
  30404. private _useFinalCode;
  30405. /**
  30406. * Unique key for this effect
  30407. */
  30408. get key(): string;
  30409. /**
  30410. * If the effect has been compiled and prepared.
  30411. * @returns if the effect is compiled and prepared.
  30412. */
  30413. isReady(): boolean;
  30414. private _isReadyInternal;
  30415. /**
  30416. * The engine the effect was initialized with.
  30417. * @returns the engine.
  30418. */
  30419. getEngine(): Engine;
  30420. /**
  30421. * The pipeline context for this effect
  30422. * @returns the associated pipeline context
  30423. */
  30424. getPipelineContext(): Nullable<IPipelineContext>;
  30425. /**
  30426. * The set of names of attribute variables for the shader.
  30427. * @returns An array of attribute names.
  30428. */
  30429. getAttributesNames(): string[];
  30430. /**
  30431. * Returns the attribute at the given index.
  30432. * @param index The index of the attribute.
  30433. * @returns The location of the attribute.
  30434. */
  30435. getAttributeLocation(index: number): number;
  30436. /**
  30437. * Returns the attribute based on the name of the variable.
  30438. * @param name of the attribute to look up.
  30439. * @returns the attribute location.
  30440. */
  30441. getAttributeLocationByName(name: string): number;
  30442. /**
  30443. * The number of attributes.
  30444. * @returns the numnber of attributes.
  30445. */
  30446. getAttributesCount(): number;
  30447. /**
  30448. * Gets the index of a uniform variable.
  30449. * @param uniformName of the uniform to look up.
  30450. * @returns the index.
  30451. */
  30452. getUniformIndex(uniformName: string): number;
  30453. /**
  30454. * Returns the attribute based on the name of the variable.
  30455. * @param uniformName of the uniform to look up.
  30456. * @returns the location of the uniform.
  30457. */
  30458. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30459. /**
  30460. * Returns an array of sampler variable names
  30461. * @returns The array of sampler variable neames.
  30462. */
  30463. getSamplers(): string[];
  30464. /**
  30465. * The error from the last compilation.
  30466. * @returns the error string.
  30467. */
  30468. getCompilationError(): string;
  30469. /**
  30470. * Gets a boolean indicating that all fallbacks were used during compilation
  30471. * @returns true if all fallbacks were used
  30472. */
  30473. allFallbacksProcessed(): boolean;
  30474. /**
  30475. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30476. * @param func The callback to be used.
  30477. */
  30478. executeWhenCompiled(func: (effect: Effect) => void): void;
  30479. private _checkIsReady;
  30480. private _loadShader;
  30481. /**
  30482. * Recompiles the webGL program
  30483. * @param vertexSourceCode The source code for the vertex shader.
  30484. * @param fragmentSourceCode The source code for the fragment shader.
  30485. * @param onCompiled Callback called when completed.
  30486. * @param onError Callback called on error.
  30487. * @hidden
  30488. */
  30489. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30490. /**
  30491. * Prepares the effect
  30492. * @hidden
  30493. */
  30494. _prepareEffect(): void;
  30495. private _getShaderCodeAndErrorLine;
  30496. private _processCompilationErrors;
  30497. /**
  30498. * Checks if the effect is supported. (Must be called after compilation)
  30499. */
  30500. get isSupported(): boolean;
  30501. /**
  30502. * Binds a texture to the engine to be used as output of the shader.
  30503. * @param channel Name of the output variable.
  30504. * @param texture Texture to bind.
  30505. * @hidden
  30506. */
  30507. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30508. /**
  30509. * Sets a texture on the engine to be used in the shader.
  30510. * @param channel Name of the sampler variable.
  30511. * @param texture Texture to set.
  30512. */
  30513. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30514. /**
  30515. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30516. * @param channel Name of the sampler variable.
  30517. * @param texture Texture to set.
  30518. */
  30519. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30520. /**
  30521. * Sets an array of textures on the engine to be used in the shader.
  30522. * @param channel Name of the variable.
  30523. * @param textures Textures to set.
  30524. */
  30525. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30526. /**
  30527. * 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)
  30528. * @param channel Name of the sampler variable.
  30529. * @param postProcess Post process to get the input texture from.
  30530. */
  30531. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30532. /**
  30533. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30534. * 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)
  30535. * @param channel Name of the sampler variable.
  30536. * @param postProcess Post process to get the output texture from.
  30537. */
  30538. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30539. /** @hidden */
  30540. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30541. /** @hidden */
  30542. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30543. /** @hidden */
  30544. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30545. /** @hidden */
  30546. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30547. /**
  30548. * Binds a buffer to a uniform.
  30549. * @param buffer Buffer to bind.
  30550. * @param name Name of the uniform variable to bind to.
  30551. */
  30552. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30553. /**
  30554. * Binds block to a uniform.
  30555. * @param blockName Name of the block to bind.
  30556. * @param index Index to bind.
  30557. */
  30558. bindUniformBlock(blockName: string, index: number): void;
  30559. /**
  30560. * Sets an interger value on a uniform variable.
  30561. * @param uniformName Name of the variable.
  30562. * @param value Value to be set.
  30563. * @returns this effect.
  30564. */
  30565. setInt(uniformName: string, value: number): Effect;
  30566. /**
  30567. * Sets an int array on a uniform variable.
  30568. * @param uniformName Name of the variable.
  30569. * @param array array to be set.
  30570. * @returns this effect.
  30571. */
  30572. setIntArray(uniformName: string, array: Int32Array): Effect;
  30573. /**
  30574. * 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)
  30575. * @param uniformName Name of the variable.
  30576. * @param array array to be set.
  30577. * @returns this effect.
  30578. */
  30579. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30580. /**
  30581. * 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)
  30582. * @param uniformName Name of the variable.
  30583. * @param array array to be set.
  30584. * @returns this effect.
  30585. */
  30586. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30587. /**
  30588. * 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)
  30589. * @param uniformName Name of the variable.
  30590. * @param array array to be set.
  30591. * @returns this effect.
  30592. */
  30593. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30594. /**
  30595. * Sets an float array on a uniform variable.
  30596. * @param uniformName Name of the variable.
  30597. * @param array array to be set.
  30598. * @returns this effect.
  30599. */
  30600. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30601. /**
  30602. * 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)
  30603. * @param uniformName Name of the variable.
  30604. * @param array array to be set.
  30605. * @returns this effect.
  30606. */
  30607. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30608. /**
  30609. * 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)
  30610. * @param uniformName Name of the variable.
  30611. * @param array array to be set.
  30612. * @returns this effect.
  30613. */
  30614. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30615. /**
  30616. * 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)
  30617. * @param uniformName Name of the variable.
  30618. * @param array array to be set.
  30619. * @returns this effect.
  30620. */
  30621. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30622. /**
  30623. * Sets an array on a uniform variable.
  30624. * @param uniformName Name of the variable.
  30625. * @param array array to be set.
  30626. * @returns this effect.
  30627. */
  30628. setArray(uniformName: string, array: number[]): Effect;
  30629. /**
  30630. * 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)
  30631. * @param uniformName Name of the variable.
  30632. * @param array array to be set.
  30633. * @returns this effect.
  30634. */
  30635. setArray2(uniformName: string, array: number[]): Effect;
  30636. /**
  30637. * 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)
  30638. * @param uniformName Name of the variable.
  30639. * @param array array to be set.
  30640. * @returns this effect.
  30641. */
  30642. setArray3(uniformName: string, array: number[]): Effect;
  30643. /**
  30644. * 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)
  30645. * @param uniformName Name of the variable.
  30646. * @param array array to be set.
  30647. * @returns this effect.
  30648. */
  30649. setArray4(uniformName: string, array: number[]): Effect;
  30650. /**
  30651. * Sets matrices on a uniform variable.
  30652. * @param uniformName Name of the variable.
  30653. * @param matrices matrices to be set.
  30654. * @returns this effect.
  30655. */
  30656. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30657. /**
  30658. * Sets matrix on a uniform variable.
  30659. * @param uniformName Name of the variable.
  30660. * @param matrix matrix to be set.
  30661. * @returns this effect.
  30662. */
  30663. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30664. /**
  30665. * 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)
  30666. * @param uniformName Name of the variable.
  30667. * @param matrix matrix to be set.
  30668. * @returns this effect.
  30669. */
  30670. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30671. /**
  30672. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30673. * @param uniformName Name of the variable.
  30674. * @param matrix matrix to be set.
  30675. * @returns this effect.
  30676. */
  30677. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30678. /**
  30679. * Sets a float on a uniform variable.
  30680. * @param uniformName Name of the variable.
  30681. * @param value value to be set.
  30682. * @returns this effect.
  30683. */
  30684. setFloat(uniformName: string, value: number): Effect;
  30685. /**
  30686. * Sets a boolean on a uniform variable.
  30687. * @param uniformName Name of the variable.
  30688. * @param bool value to be set.
  30689. * @returns this effect.
  30690. */
  30691. setBool(uniformName: string, bool: boolean): Effect;
  30692. /**
  30693. * Sets a Vector2 on a uniform variable.
  30694. * @param uniformName Name of the variable.
  30695. * @param vector2 vector2 to be set.
  30696. * @returns this effect.
  30697. */
  30698. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30699. /**
  30700. * Sets a float2 on a uniform variable.
  30701. * @param uniformName Name of the variable.
  30702. * @param x First float in float2.
  30703. * @param y Second float in float2.
  30704. * @returns this effect.
  30705. */
  30706. setFloat2(uniformName: string, x: number, y: number): Effect;
  30707. /**
  30708. * Sets a Vector3 on a uniform variable.
  30709. * @param uniformName Name of the variable.
  30710. * @param vector3 Value to be set.
  30711. * @returns this effect.
  30712. */
  30713. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30714. /**
  30715. * Sets a float3 on a uniform variable.
  30716. * @param uniformName Name of the variable.
  30717. * @param x First float in float3.
  30718. * @param y Second float in float3.
  30719. * @param z Third float in float3.
  30720. * @returns this effect.
  30721. */
  30722. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30723. /**
  30724. * Sets a Vector4 on a uniform variable.
  30725. * @param uniformName Name of the variable.
  30726. * @param vector4 Value to be set.
  30727. * @returns this effect.
  30728. */
  30729. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30730. /**
  30731. * Sets a float4 on a uniform variable.
  30732. * @param uniformName Name of the variable.
  30733. * @param x First float in float4.
  30734. * @param y Second float in float4.
  30735. * @param z Third float in float4.
  30736. * @param w Fourth float in float4.
  30737. * @returns this effect.
  30738. */
  30739. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30740. /**
  30741. * Sets a Color3 on a uniform variable.
  30742. * @param uniformName Name of the variable.
  30743. * @param color3 Value to be set.
  30744. * @returns this effect.
  30745. */
  30746. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30747. /**
  30748. * Sets a Color4 on a uniform variable.
  30749. * @param uniformName Name of the variable.
  30750. * @param color3 Value to be set.
  30751. * @param alpha Alpha value to be set.
  30752. * @returns this effect.
  30753. */
  30754. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30755. /**
  30756. * Sets a Color4 on a uniform variable
  30757. * @param uniformName defines the name of the variable
  30758. * @param color4 defines the value to be set
  30759. * @returns this effect.
  30760. */
  30761. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30762. /** Release all associated resources */
  30763. dispose(): void;
  30764. /**
  30765. * This function will add a new shader to the shader store
  30766. * @param name the name of the shader
  30767. * @param pixelShader optional pixel shader content
  30768. * @param vertexShader optional vertex shader content
  30769. */
  30770. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30771. /**
  30772. * Store of each shader (The can be looked up using effect.key)
  30773. */
  30774. static ShadersStore: {
  30775. [key: string]: string;
  30776. };
  30777. /**
  30778. * Store of each included file for a shader (The can be looked up using effect.key)
  30779. */
  30780. static IncludesShadersStore: {
  30781. [key: string]: string;
  30782. };
  30783. /**
  30784. * Resets the cache of effects.
  30785. */
  30786. static ResetCache(): void;
  30787. }
  30788. }
  30789. declare module BABYLON {
  30790. /**
  30791. * Interface used to describe the capabilities of the engine relatively to the current browser
  30792. */
  30793. export interface EngineCapabilities {
  30794. /** Maximum textures units per fragment shader */
  30795. maxTexturesImageUnits: number;
  30796. /** Maximum texture units per vertex shader */
  30797. maxVertexTextureImageUnits: number;
  30798. /** Maximum textures units in the entire pipeline */
  30799. maxCombinedTexturesImageUnits: number;
  30800. /** Maximum texture size */
  30801. maxTextureSize: number;
  30802. /** Maximum texture samples */
  30803. maxSamples?: number;
  30804. /** Maximum cube texture size */
  30805. maxCubemapTextureSize: number;
  30806. /** Maximum render texture size */
  30807. maxRenderTextureSize: number;
  30808. /** Maximum number of vertex attributes */
  30809. maxVertexAttribs: number;
  30810. /** Maximum number of varyings */
  30811. maxVaryingVectors: number;
  30812. /** Maximum number of uniforms per vertex shader */
  30813. maxVertexUniformVectors: number;
  30814. /** Maximum number of uniforms per fragment shader */
  30815. maxFragmentUniformVectors: number;
  30816. /** Defines if standard derivates (dx/dy) are supported */
  30817. standardDerivatives: boolean;
  30818. /** Defines if s3tc texture compression is supported */
  30819. s3tc?: WEBGL_compressed_texture_s3tc;
  30820. /** Defines if pvrtc texture compression is supported */
  30821. pvrtc: any;
  30822. /** Defines if etc1 texture compression is supported */
  30823. etc1: any;
  30824. /** Defines if etc2 texture compression is supported */
  30825. etc2: any;
  30826. /** Defines if astc texture compression is supported */
  30827. astc: any;
  30828. /** Defines if float textures are supported */
  30829. textureFloat: boolean;
  30830. /** Defines if vertex array objects are supported */
  30831. vertexArrayObject: boolean;
  30832. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30833. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30834. /** Gets the maximum level of anisotropy supported */
  30835. maxAnisotropy: number;
  30836. /** Defines if instancing is supported */
  30837. instancedArrays: boolean;
  30838. /** Defines if 32 bits indices are supported */
  30839. uintIndices: boolean;
  30840. /** Defines if high precision shaders are supported */
  30841. highPrecisionShaderSupported: boolean;
  30842. /** Defines if depth reading in the fragment shader is supported */
  30843. fragmentDepthSupported: boolean;
  30844. /** Defines if float texture linear filtering is supported*/
  30845. textureFloatLinearFiltering: boolean;
  30846. /** Defines if rendering to float textures is supported */
  30847. textureFloatRender: boolean;
  30848. /** Defines if half float textures are supported*/
  30849. textureHalfFloat: boolean;
  30850. /** Defines if half float texture linear filtering is supported*/
  30851. textureHalfFloatLinearFiltering: boolean;
  30852. /** Defines if rendering to half float textures is supported */
  30853. textureHalfFloatRender: boolean;
  30854. /** Defines if textureLOD shader command is supported */
  30855. textureLOD: boolean;
  30856. /** Defines if draw buffers extension is supported */
  30857. drawBuffersExtension: boolean;
  30858. /** Defines if depth textures are supported */
  30859. depthTextureExtension: boolean;
  30860. /** Defines if float color buffer are supported */
  30861. colorBufferFloat: boolean;
  30862. /** Gets disjoint timer query extension (null if not supported) */
  30863. timerQuery?: EXT_disjoint_timer_query;
  30864. /** Defines if timestamp can be used with timer query */
  30865. canUseTimestampForTimerQuery: boolean;
  30866. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30867. multiview?: any;
  30868. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30869. oculusMultiview?: any;
  30870. /** Function used to let the system compiles shaders in background */
  30871. parallelShaderCompile?: {
  30872. COMPLETION_STATUS_KHR: number;
  30873. };
  30874. /** Max number of texture samples for MSAA */
  30875. maxMSAASamples: number;
  30876. /** Defines if the blend min max extension is supported */
  30877. blendMinMax: boolean;
  30878. }
  30879. }
  30880. declare module BABYLON {
  30881. /**
  30882. * @hidden
  30883. **/
  30884. export class DepthCullingState {
  30885. private _isDepthTestDirty;
  30886. private _isDepthMaskDirty;
  30887. private _isDepthFuncDirty;
  30888. private _isCullFaceDirty;
  30889. private _isCullDirty;
  30890. private _isZOffsetDirty;
  30891. private _isFrontFaceDirty;
  30892. private _depthTest;
  30893. private _depthMask;
  30894. private _depthFunc;
  30895. private _cull;
  30896. private _cullFace;
  30897. private _zOffset;
  30898. private _frontFace;
  30899. /**
  30900. * Initializes the state.
  30901. */
  30902. constructor();
  30903. get isDirty(): boolean;
  30904. get zOffset(): number;
  30905. set zOffset(value: number);
  30906. get cullFace(): Nullable<number>;
  30907. set cullFace(value: Nullable<number>);
  30908. get cull(): Nullable<boolean>;
  30909. set cull(value: Nullable<boolean>);
  30910. get depthFunc(): Nullable<number>;
  30911. set depthFunc(value: Nullable<number>);
  30912. get depthMask(): boolean;
  30913. set depthMask(value: boolean);
  30914. get depthTest(): boolean;
  30915. set depthTest(value: boolean);
  30916. get frontFace(): Nullable<number>;
  30917. set frontFace(value: Nullable<number>);
  30918. reset(): void;
  30919. apply(gl: WebGLRenderingContext): void;
  30920. }
  30921. }
  30922. declare module BABYLON {
  30923. /**
  30924. * @hidden
  30925. **/
  30926. export class StencilState {
  30927. /** 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 */
  30928. static readonly ALWAYS: number;
  30929. /** Passed to stencilOperation to specify that stencil value must be kept */
  30930. static readonly KEEP: number;
  30931. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30932. static readonly REPLACE: number;
  30933. private _isStencilTestDirty;
  30934. private _isStencilMaskDirty;
  30935. private _isStencilFuncDirty;
  30936. private _isStencilOpDirty;
  30937. private _stencilTest;
  30938. private _stencilMask;
  30939. private _stencilFunc;
  30940. private _stencilFuncRef;
  30941. private _stencilFuncMask;
  30942. private _stencilOpStencilFail;
  30943. private _stencilOpDepthFail;
  30944. private _stencilOpStencilDepthPass;
  30945. get isDirty(): boolean;
  30946. get stencilFunc(): number;
  30947. set stencilFunc(value: number);
  30948. get stencilFuncRef(): number;
  30949. set stencilFuncRef(value: number);
  30950. get stencilFuncMask(): number;
  30951. set stencilFuncMask(value: number);
  30952. get stencilOpStencilFail(): number;
  30953. set stencilOpStencilFail(value: number);
  30954. get stencilOpDepthFail(): number;
  30955. set stencilOpDepthFail(value: number);
  30956. get stencilOpStencilDepthPass(): number;
  30957. set stencilOpStencilDepthPass(value: number);
  30958. get stencilMask(): number;
  30959. set stencilMask(value: number);
  30960. get stencilTest(): boolean;
  30961. set stencilTest(value: boolean);
  30962. constructor();
  30963. reset(): void;
  30964. apply(gl: WebGLRenderingContext): void;
  30965. }
  30966. }
  30967. declare module BABYLON {
  30968. /**
  30969. * @hidden
  30970. **/
  30971. export class AlphaState {
  30972. private _isAlphaBlendDirty;
  30973. private _isBlendFunctionParametersDirty;
  30974. private _isBlendEquationParametersDirty;
  30975. private _isBlendConstantsDirty;
  30976. private _alphaBlend;
  30977. private _blendFunctionParameters;
  30978. private _blendEquationParameters;
  30979. private _blendConstants;
  30980. /**
  30981. * Initializes the state.
  30982. */
  30983. constructor();
  30984. get isDirty(): boolean;
  30985. get alphaBlend(): boolean;
  30986. set alphaBlend(value: boolean);
  30987. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  30988. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  30989. setAlphaEquationParameters(rgb: number, alpha: number): void;
  30990. reset(): void;
  30991. apply(gl: WebGLRenderingContext): void;
  30992. }
  30993. }
  30994. declare module BABYLON {
  30995. /** @hidden */
  30996. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30997. attributeProcessor(attribute: string): string;
  30998. varyingProcessor(varying: string, isFragment: boolean): string;
  30999. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31000. }
  31001. }
  31002. declare module BABYLON {
  31003. /**
  31004. * Interface for attribute information associated with buffer instanciation
  31005. */
  31006. export interface InstancingAttributeInfo {
  31007. /**
  31008. * Name of the GLSL attribute
  31009. * if attribute index is not specified, this is used to retrieve the index from the effect
  31010. */
  31011. attributeName: string;
  31012. /**
  31013. * Index/offset of the attribute in the vertex shader
  31014. * if not specified, this will be computes from the name.
  31015. */
  31016. index?: number;
  31017. /**
  31018. * size of the attribute, 1, 2, 3 or 4
  31019. */
  31020. attributeSize: number;
  31021. /**
  31022. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31023. */
  31024. offset: number;
  31025. /**
  31026. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31027. * default to 1
  31028. */
  31029. divisor?: number;
  31030. /**
  31031. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31032. * default is FLOAT
  31033. */
  31034. attributeType?: number;
  31035. /**
  31036. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31037. */
  31038. normalized?: boolean;
  31039. }
  31040. }
  31041. declare module BABYLON {
  31042. interface ThinEngine {
  31043. /**
  31044. * Update a video texture
  31045. * @param texture defines the texture to update
  31046. * @param video defines the video element to use
  31047. * @param invertY defines if data must be stored with Y axis inverted
  31048. */
  31049. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31050. }
  31051. }
  31052. declare module BABYLON {
  31053. /**
  31054. * Settings for finer control over video usage
  31055. */
  31056. export interface VideoTextureSettings {
  31057. /**
  31058. * Applies `autoplay` to video, if specified
  31059. */
  31060. autoPlay?: boolean;
  31061. /**
  31062. * Applies `loop` to video, if specified
  31063. */
  31064. loop?: boolean;
  31065. /**
  31066. * Automatically updates internal texture from video at every frame in the render loop
  31067. */
  31068. autoUpdateTexture: boolean;
  31069. /**
  31070. * Image src displayed during the video loading or until the user interacts with the video.
  31071. */
  31072. poster?: string;
  31073. }
  31074. /**
  31075. * If you want to display a video in your scene, this is the special texture for that.
  31076. * This special texture works similar to other textures, with the exception of a few parameters.
  31077. * @see https://doc.babylonjs.com/how_to/video_texture
  31078. */
  31079. export class VideoTexture extends Texture {
  31080. /**
  31081. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31082. */
  31083. readonly autoUpdateTexture: boolean;
  31084. /**
  31085. * The video instance used by the texture internally
  31086. */
  31087. readonly video: HTMLVideoElement;
  31088. private _onUserActionRequestedObservable;
  31089. /**
  31090. * Event triggerd when a dom action is required by the user to play the video.
  31091. * This happens due to recent changes in browser policies preventing video to auto start.
  31092. */
  31093. get onUserActionRequestedObservable(): Observable<Texture>;
  31094. private _generateMipMaps;
  31095. private _engine;
  31096. private _stillImageCaptured;
  31097. private _displayingPosterTexture;
  31098. private _settings;
  31099. private _createInternalTextureOnEvent;
  31100. private _frameId;
  31101. private _currentSrc;
  31102. /**
  31103. * Creates a video texture.
  31104. * If you want to display a video in your scene, this is the special texture for that.
  31105. * This special texture works similar to other textures, with the exception of a few parameters.
  31106. * @see https://doc.babylonjs.com/how_to/video_texture
  31107. * @param name optional name, will detect from video source, if not defined
  31108. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31109. * @param scene is obviously the current scene.
  31110. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31111. * @param invertY is false by default but can be used to invert video on Y axis
  31112. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31113. * @param settings allows finer control over video usage
  31114. */
  31115. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31116. private _getName;
  31117. private _getVideo;
  31118. private _createInternalTexture;
  31119. private reset;
  31120. /**
  31121. * @hidden Internal method to initiate `update`.
  31122. */
  31123. _rebuild(): void;
  31124. /**
  31125. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31126. */
  31127. update(): void;
  31128. /**
  31129. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31130. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31131. */
  31132. updateTexture(isVisible: boolean): void;
  31133. protected _updateInternalTexture: () => void;
  31134. /**
  31135. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31136. * @param url New url.
  31137. */
  31138. updateURL(url: string): void;
  31139. /**
  31140. * Clones the texture.
  31141. * @returns the cloned texture
  31142. */
  31143. clone(): VideoTexture;
  31144. /**
  31145. * Dispose the texture and release its associated resources.
  31146. */
  31147. dispose(): void;
  31148. /**
  31149. * Creates a video texture straight from a stream.
  31150. * @param scene Define the scene the texture should be created in
  31151. * @param stream Define the stream the texture should be created from
  31152. * @returns The created video texture as a promise
  31153. */
  31154. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31155. /**
  31156. * Creates a video texture straight from your WebCam video feed.
  31157. * @param scene Define the scene the texture should be created in
  31158. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31159. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31160. * @returns The created video texture as a promise
  31161. */
  31162. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31163. minWidth: number;
  31164. maxWidth: number;
  31165. minHeight: number;
  31166. maxHeight: number;
  31167. deviceId: string;
  31168. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31169. /**
  31170. * Creates a video texture straight from your WebCam video feed.
  31171. * @param scene Define the scene the texture should be created in
  31172. * @param onReady Define a callback to triggered once the texture will be ready
  31173. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31174. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31175. */
  31176. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31177. minWidth: number;
  31178. maxWidth: number;
  31179. minHeight: number;
  31180. maxHeight: number;
  31181. deviceId: string;
  31182. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31183. }
  31184. }
  31185. declare module BABYLON {
  31186. /**
  31187. * Defines the interface used by objects working like Scene
  31188. * @hidden
  31189. */
  31190. export interface ISceneLike {
  31191. _addPendingData(data: any): void;
  31192. _removePendingData(data: any): void;
  31193. offlineProvider: IOfflineProvider;
  31194. }
  31195. /** Interface defining initialization parameters for Engine class */
  31196. export interface EngineOptions extends WebGLContextAttributes {
  31197. /**
  31198. * Defines if the engine should no exceed a specified device ratio
  31199. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31200. */
  31201. limitDeviceRatio?: number;
  31202. /**
  31203. * Defines if webvr should be enabled automatically
  31204. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31205. */
  31206. autoEnableWebVR?: boolean;
  31207. /**
  31208. * Defines if webgl2 should be turned off even if supported
  31209. * @see http://doc.babylonjs.com/features/webgl2
  31210. */
  31211. disableWebGL2Support?: boolean;
  31212. /**
  31213. * Defines if webaudio should be initialized as well
  31214. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31215. */
  31216. audioEngine?: boolean;
  31217. /**
  31218. * Defines if animations should run using a deterministic lock step
  31219. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31220. */
  31221. deterministicLockstep?: boolean;
  31222. /** Defines the maximum steps to use with deterministic lock step mode */
  31223. lockstepMaxSteps?: number;
  31224. /** Defines the seconds between each deterministic lock step */
  31225. timeStep?: number;
  31226. /**
  31227. * Defines that engine should ignore context lost events
  31228. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31229. */
  31230. doNotHandleContextLost?: boolean;
  31231. /**
  31232. * Defines that engine should ignore modifying touch action attribute and style
  31233. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31234. */
  31235. doNotHandleTouchAction?: boolean;
  31236. /**
  31237. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31238. */
  31239. useHighPrecisionFloats?: boolean;
  31240. }
  31241. /**
  31242. * The base engine class (root of all engines)
  31243. */
  31244. export class ThinEngine {
  31245. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31246. static ExceptionList: ({
  31247. key: string;
  31248. capture: string;
  31249. captureConstraint: number;
  31250. targets: string[];
  31251. } | {
  31252. key: string;
  31253. capture: null;
  31254. captureConstraint: null;
  31255. targets: string[];
  31256. })[];
  31257. /** @hidden */
  31258. static _TextureLoaders: IInternalTextureLoader[];
  31259. /**
  31260. * Returns the current npm package of the sdk
  31261. */
  31262. static get NpmPackage(): string;
  31263. /**
  31264. * Returns the current version of the framework
  31265. */
  31266. static get Version(): string;
  31267. /**
  31268. * Returns a string describing the current engine
  31269. */
  31270. get description(): string;
  31271. /**
  31272. * Gets or sets the epsilon value used by collision engine
  31273. */
  31274. static CollisionsEpsilon: number;
  31275. /**
  31276. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31277. */
  31278. static get ShadersRepository(): string;
  31279. static set ShadersRepository(value: string);
  31280. /** @hidden */
  31281. _shaderProcessor: IShaderProcessor;
  31282. /**
  31283. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31284. */
  31285. forcePOTTextures: boolean;
  31286. /**
  31287. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31288. */
  31289. isFullscreen: boolean;
  31290. /**
  31291. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31292. */
  31293. cullBackFaces: boolean;
  31294. /**
  31295. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31296. */
  31297. renderEvenInBackground: boolean;
  31298. /**
  31299. * Gets or sets a boolean indicating that cache can be kept between frames
  31300. */
  31301. preventCacheWipeBetweenFrames: boolean;
  31302. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31303. validateShaderPrograms: boolean;
  31304. /**
  31305. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31306. * This can provide greater z depth for distant objects.
  31307. */
  31308. useReverseDepthBuffer: boolean;
  31309. /**
  31310. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31311. */
  31312. disableUniformBuffers: boolean;
  31313. /** @hidden */
  31314. _uniformBuffers: UniformBuffer[];
  31315. /**
  31316. * Gets a boolean indicating that the engine supports uniform buffers
  31317. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31318. */
  31319. get supportsUniformBuffers(): boolean;
  31320. /** @hidden */
  31321. _gl: WebGLRenderingContext;
  31322. /** @hidden */
  31323. _webGLVersion: number;
  31324. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31325. protected _windowIsBackground: boolean;
  31326. protected _creationOptions: EngineOptions;
  31327. protected _highPrecisionShadersAllowed: boolean;
  31328. /** @hidden */
  31329. get _shouldUseHighPrecisionShader(): boolean;
  31330. /**
  31331. * Gets a boolean indicating that only power of 2 textures are supported
  31332. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31333. */
  31334. get needPOTTextures(): boolean;
  31335. /** @hidden */
  31336. _badOS: boolean;
  31337. /** @hidden */
  31338. _badDesktopOS: boolean;
  31339. private _hardwareScalingLevel;
  31340. /** @hidden */
  31341. _caps: EngineCapabilities;
  31342. private _isStencilEnable;
  31343. private _glVersion;
  31344. private _glRenderer;
  31345. private _glVendor;
  31346. /** @hidden */
  31347. _videoTextureSupported: boolean;
  31348. protected _renderingQueueLaunched: boolean;
  31349. protected _activeRenderLoops: (() => void)[];
  31350. /**
  31351. * Observable signaled when a context lost event is raised
  31352. */
  31353. onContextLostObservable: Observable<ThinEngine>;
  31354. /**
  31355. * Observable signaled when a context restored event is raised
  31356. */
  31357. onContextRestoredObservable: Observable<ThinEngine>;
  31358. private _onContextLost;
  31359. private _onContextRestored;
  31360. protected _contextWasLost: boolean;
  31361. /** @hidden */
  31362. _doNotHandleContextLost: boolean;
  31363. /**
  31364. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31365. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31366. */
  31367. get doNotHandleContextLost(): boolean;
  31368. set doNotHandleContextLost(value: boolean);
  31369. /**
  31370. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31371. */
  31372. disableVertexArrayObjects: boolean;
  31373. /** @hidden */
  31374. protected _colorWrite: boolean;
  31375. /** @hidden */
  31376. protected _colorWriteChanged: boolean;
  31377. /** @hidden */
  31378. protected _depthCullingState: DepthCullingState;
  31379. /** @hidden */
  31380. protected _stencilState: StencilState;
  31381. /** @hidden */
  31382. _alphaState: AlphaState;
  31383. /** @hidden */
  31384. _alphaMode: number;
  31385. /** @hidden */
  31386. _alphaEquation: number;
  31387. /** @hidden */
  31388. _internalTexturesCache: InternalTexture[];
  31389. /** @hidden */
  31390. protected _activeChannel: number;
  31391. private _currentTextureChannel;
  31392. /** @hidden */
  31393. protected _boundTexturesCache: {
  31394. [key: string]: Nullable<InternalTexture>;
  31395. };
  31396. /** @hidden */
  31397. protected _currentEffect: Nullable<Effect>;
  31398. /** @hidden */
  31399. protected _currentProgram: Nullable<WebGLProgram>;
  31400. private _compiledEffects;
  31401. private _vertexAttribArraysEnabled;
  31402. /** @hidden */
  31403. protected _cachedViewport: Nullable<IViewportLike>;
  31404. private _cachedVertexArrayObject;
  31405. /** @hidden */
  31406. protected _cachedVertexBuffers: any;
  31407. /** @hidden */
  31408. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31409. /** @hidden */
  31410. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31411. /** @hidden */
  31412. _currentRenderTarget: Nullable<InternalTexture>;
  31413. private _uintIndicesCurrentlySet;
  31414. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31415. /** @hidden */
  31416. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31417. private _currentBufferPointers;
  31418. private _currentInstanceLocations;
  31419. private _currentInstanceBuffers;
  31420. private _textureUnits;
  31421. /** @hidden */
  31422. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31423. /** @hidden */
  31424. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31425. /** @hidden */
  31426. _boundRenderFunction: any;
  31427. private _vaoRecordInProgress;
  31428. private _mustWipeVertexAttributes;
  31429. private _emptyTexture;
  31430. private _emptyCubeTexture;
  31431. private _emptyTexture3D;
  31432. private _emptyTexture2DArray;
  31433. /** @hidden */
  31434. _frameHandler: number;
  31435. private _nextFreeTextureSlots;
  31436. private _maxSimultaneousTextures;
  31437. private _activeRequests;
  31438. /** @hidden */
  31439. _transformTextureUrl: Nullable<(url: string) => string>;
  31440. protected get _supportsHardwareTextureRescaling(): boolean;
  31441. private _framebufferDimensionsObject;
  31442. /**
  31443. * sets the object from which width and height will be taken from when getting render width and height
  31444. * Will fallback to the gl object
  31445. * @param dimensions the framebuffer width and height that will be used.
  31446. */
  31447. set framebufferDimensionsObject(dimensions: Nullable<{
  31448. framebufferWidth: number;
  31449. framebufferHeight: number;
  31450. }>);
  31451. /**
  31452. * Gets the current viewport
  31453. */
  31454. get currentViewport(): Nullable<IViewportLike>;
  31455. /**
  31456. * Gets the default empty texture
  31457. */
  31458. get emptyTexture(): InternalTexture;
  31459. /**
  31460. * Gets the default empty 3D texture
  31461. */
  31462. get emptyTexture3D(): InternalTexture;
  31463. /**
  31464. * Gets the default empty 2D array texture
  31465. */
  31466. get emptyTexture2DArray(): InternalTexture;
  31467. /**
  31468. * Gets the default empty cube texture
  31469. */
  31470. get emptyCubeTexture(): InternalTexture;
  31471. /**
  31472. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31473. */
  31474. readonly premultipliedAlpha: boolean;
  31475. /**
  31476. * Observable event triggered before each texture is initialized
  31477. */
  31478. onBeforeTextureInitObservable: Observable<Texture>;
  31479. /**
  31480. * Creates a new engine
  31481. * @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
  31482. * @param antialias defines enable antialiasing (default: false)
  31483. * @param options defines further options to be sent to the getContext() function
  31484. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31485. */
  31486. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31487. private _rebuildInternalTextures;
  31488. private _rebuildEffects;
  31489. /**
  31490. * Gets a boolean indicating if all created effects are ready
  31491. * @returns true if all effects are ready
  31492. */
  31493. areAllEffectsReady(): boolean;
  31494. protected _rebuildBuffers(): void;
  31495. protected _initGLContext(): void;
  31496. /**
  31497. * Gets version of the current webGL context
  31498. */
  31499. get webGLVersion(): number;
  31500. /**
  31501. * Gets a string idenfifying the name of the class
  31502. * @returns "Engine" string
  31503. */
  31504. getClassName(): string;
  31505. /**
  31506. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31507. */
  31508. get isStencilEnable(): boolean;
  31509. /** @hidden */
  31510. _prepareWorkingCanvas(): void;
  31511. /**
  31512. * Reset the texture cache to empty state
  31513. */
  31514. resetTextureCache(): void;
  31515. /**
  31516. * Gets an object containing information about the current webGL context
  31517. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31518. */
  31519. getGlInfo(): {
  31520. vendor: string;
  31521. renderer: string;
  31522. version: string;
  31523. };
  31524. /**
  31525. * Defines the hardware scaling level.
  31526. * By default the hardware scaling level is computed from the window device ratio.
  31527. * 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.
  31528. * @param level defines the level to use
  31529. */
  31530. setHardwareScalingLevel(level: number): void;
  31531. /**
  31532. * Gets the current hardware scaling level.
  31533. * By default the hardware scaling level is computed from the window device ratio.
  31534. * 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.
  31535. * @returns a number indicating the current hardware scaling level
  31536. */
  31537. getHardwareScalingLevel(): number;
  31538. /**
  31539. * Gets the list of loaded textures
  31540. * @returns an array containing all loaded textures
  31541. */
  31542. getLoadedTexturesCache(): InternalTexture[];
  31543. /**
  31544. * Gets the object containing all engine capabilities
  31545. * @returns the EngineCapabilities object
  31546. */
  31547. getCaps(): EngineCapabilities;
  31548. /**
  31549. * stop executing a render loop function and remove it from the execution array
  31550. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31551. */
  31552. stopRenderLoop(renderFunction?: () => void): void;
  31553. /** @hidden */
  31554. _renderLoop(): void;
  31555. /**
  31556. * Gets the HTML canvas attached with the current webGL context
  31557. * @returns a HTML canvas
  31558. */
  31559. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31560. /**
  31561. * Gets host window
  31562. * @returns the host window object
  31563. */
  31564. getHostWindow(): Nullable<Window>;
  31565. /**
  31566. * Gets the current render width
  31567. * @param useScreen defines if screen size must be used (or the current render target if any)
  31568. * @returns a number defining the current render width
  31569. */
  31570. getRenderWidth(useScreen?: boolean): number;
  31571. /**
  31572. * Gets the current render height
  31573. * @param useScreen defines if screen size must be used (or the current render target if any)
  31574. * @returns a number defining the current render height
  31575. */
  31576. getRenderHeight(useScreen?: boolean): number;
  31577. /**
  31578. * Can be used to override the current requestAnimationFrame requester.
  31579. * @hidden
  31580. */
  31581. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31582. /**
  31583. * Register and execute a render loop. The engine can have more than one render function
  31584. * @param renderFunction defines the function to continuously execute
  31585. */
  31586. runRenderLoop(renderFunction: () => void): void;
  31587. /**
  31588. * Clear the current render buffer or the current render target (if any is set up)
  31589. * @param color defines the color to use
  31590. * @param backBuffer defines if the back buffer must be cleared
  31591. * @param depth defines if the depth buffer must be cleared
  31592. * @param stencil defines if the stencil buffer must be cleared
  31593. */
  31594. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31595. private _viewportCached;
  31596. /** @hidden */
  31597. _viewport(x: number, y: number, width: number, height: number): void;
  31598. /**
  31599. * Set the WebGL's viewport
  31600. * @param viewport defines the viewport element to be used
  31601. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31602. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31603. */
  31604. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31605. /**
  31606. * Begin a new frame
  31607. */
  31608. beginFrame(): void;
  31609. /**
  31610. * Enf the current frame
  31611. */
  31612. endFrame(): void;
  31613. /**
  31614. * Resize the view according to the canvas' size
  31615. */
  31616. resize(): void;
  31617. /**
  31618. * Force a specific size of the canvas
  31619. * @param width defines the new canvas' width
  31620. * @param height defines the new canvas' height
  31621. */
  31622. setSize(width: number, height: number): void;
  31623. /**
  31624. * Binds the frame buffer to the specified texture.
  31625. * @param texture The texture to render to or null for the default canvas
  31626. * @param faceIndex The face of the texture to render to in case of cube texture
  31627. * @param requiredWidth The width of the target to render to
  31628. * @param requiredHeight The height of the target to render to
  31629. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31630. * @param lodLevel defines the lod level to bind to the frame buffer
  31631. * @param layer defines the 2d array index to bind to frame buffer to
  31632. */
  31633. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31634. /** @hidden */
  31635. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31636. /**
  31637. * Unbind the current render target texture from the webGL context
  31638. * @param texture defines the render target texture to unbind
  31639. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31640. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31641. */
  31642. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31643. /**
  31644. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31645. */
  31646. flushFramebuffer(): void;
  31647. /**
  31648. * Unbind the current render target and bind the default framebuffer
  31649. */
  31650. restoreDefaultFramebuffer(): void;
  31651. /** @hidden */
  31652. protected _resetVertexBufferBinding(): void;
  31653. /**
  31654. * Creates a vertex buffer
  31655. * @param data the data for the vertex buffer
  31656. * @returns the new WebGL static buffer
  31657. */
  31658. createVertexBuffer(data: DataArray): DataBuffer;
  31659. private _createVertexBuffer;
  31660. /**
  31661. * Creates a dynamic vertex buffer
  31662. * @param data the data for the dynamic vertex buffer
  31663. * @returns the new WebGL dynamic buffer
  31664. */
  31665. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31666. protected _resetIndexBufferBinding(): void;
  31667. /**
  31668. * Creates a new index buffer
  31669. * @param indices defines the content of the index buffer
  31670. * @param updatable defines if the index buffer must be updatable
  31671. * @returns a new webGL buffer
  31672. */
  31673. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31674. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31675. /**
  31676. * Bind a webGL buffer to the webGL context
  31677. * @param buffer defines the buffer to bind
  31678. */
  31679. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31680. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31681. private bindBuffer;
  31682. /**
  31683. * update the bound buffer with the given data
  31684. * @param data defines the data to update
  31685. */
  31686. updateArrayBuffer(data: Float32Array): void;
  31687. private _vertexAttribPointer;
  31688. /** @hidden */
  31689. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  31690. private _bindVertexBuffersAttributes;
  31691. /**
  31692. * Records a vertex array object
  31693. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31694. * @param vertexBuffers defines the list of vertex buffers to store
  31695. * @param indexBuffer defines the index buffer to store
  31696. * @param effect defines the effect to store
  31697. * @returns the new vertex array object
  31698. */
  31699. recordVertexArrayObject(vertexBuffers: {
  31700. [key: string]: VertexBuffer;
  31701. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31702. /**
  31703. * Bind a specific vertex array object
  31704. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31705. * @param vertexArrayObject defines the vertex array object to bind
  31706. * @param indexBuffer defines the index buffer to bind
  31707. */
  31708. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31709. /**
  31710. * Bind webGl buffers directly to the webGL context
  31711. * @param vertexBuffer defines the vertex buffer to bind
  31712. * @param indexBuffer defines the index buffer to bind
  31713. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31714. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31715. * @param effect defines the effect associated with the vertex buffer
  31716. */
  31717. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31718. private _unbindVertexArrayObject;
  31719. /**
  31720. * Bind a list of vertex buffers to the webGL context
  31721. * @param vertexBuffers defines the list of vertex buffers to bind
  31722. * @param indexBuffer defines the index buffer to bind
  31723. * @param effect defines the effect associated with the vertex buffers
  31724. */
  31725. bindBuffers(vertexBuffers: {
  31726. [key: string]: Nullable<VertexBuffer>;
  31727. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31728. /**
  31729. * Unbind all instance attributes
  31730. */
  31731. unbindInstanceAttributes(): void;
  31732. /**
  31733. * Release and free the memory of a vertex array object
  31734. * @param vao defines the vertex array object to delete
  31735. */
  31736. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31737. /** @hidden */
  31738. _releaseBuffer(buffer: DataBuffer): boolean;
  31739. protected _deleteBuffer(buffer: DataBuffer): void;
  31740. /**
  31741. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31742. * @param instancesBuffer defines the webGL buffer to update and bind
  31743. * @param data defines the data to store in the buffer
  31744. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31745. */
  31746. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31747. /**
  31748. * Bind the content of a webGL buffer used with instantiation
  31749. * @param instancesBuffer defines the webGL buffer to bind
  31750. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31751. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  31752. */
  31753. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31754. /**
  31755. * Disable the instance attribute corresponding to the name in parameter
  31756. * @param name defines the name of the attribute to disable
  31757. */
  31758. disableInstanceAttributeByName(name: string): void;
  31759. /**
  31760. * Disable the instance attribute corresponding to the location in parameter
  31761. * @param attributeLocation defines the attribute location of the attribute to disable
  31762. */
  31763. disableInstanceAttribute(attributeLocation: number): void;
  31764. /**
  31765. * Disable the attribute corresponding to the location in parameter
  31766. * @param attributeLocation defines the attribute location of the attribute to disable
  31767. */
  31768. disableAttributeByIndex(attributeLocation: number): void;
  31769. /**
  31770. * Send a draw order
  31771. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31772. * @param indexStart defines the starting index
  31773. * @param indexCount defines the number of index to draw
  31774. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31775. */
  31776. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31777. /**
  31778. * Draw a list of points
  31779. * @param verticesStart defines the index of first vertex to draw
  31780. * @param verticesCount defines the count of vertices to draw
  31781. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31782. */
  31783. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31784. /**
  31785. * Draw a list of unindexed primitives
  31786. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31787. * @param verticesStart defines the index of first vertex to draw
  31788. * @param verticesCount defines the count of vertices to draw
  31789. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31790. */
  31791. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31792. /**
  31793. * Draw a list of indexed primitives
  31794. * @param fillMode defines the primitive to use
  31795. * @param indexStart defines the starting index
  31796. * @param indexCount defines the number of index to draw
  31797. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31798. */
  31799. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31800. /**
  31801. * Draw a list of unindexed primitives
  31802. * @param fillMode defines the primitive to use
  31803. * @param verticesStart defines the index of first vertex to draw
  31804. * @param verticesCount defines the count of vertices to draw
  31805. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31806. */
  31807. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31808. private _drawMode;
  31809. /** @hidden */
  31810. protected _reportDrawCall(): void;
  31811. /** @hidden */
  31812. _releaseEffect(effect: Effect): void;
  31813. /** @hidden */
  31814. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31815. /**
  31816. * Create a new effect (used to store vertex/fragment shaders)
  31817. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31818. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31819. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31820. * @param samplers defines an array of string used to represent textures
  31821. * @param defines defines the string containing the defines to use to compile the shaders
  31822. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31823. * @param onCompiled defines a function to call when the effect creation is successful
  31824. * @param onError defines a function to call when the effect creation has failed
  31825. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31826. * @returns the new Effect
  31827. */
  31828. 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;
  31829. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31830. private _compileShader;
  31831. private _compileRawShader;
  31832. /** @hidden */
  31833. _getShaderSource(shader: WebGLShader): Nullable<string>;
  31834. /**
  31835. * Directly creates a webGL program
  31836. * @param pipelineContext defines the pipeline context to attach to
  31837. * @param vertexCode defines the vertex shader code to use
  31838. * @param fragmentCode defines the fragment shader code to use
  31839. * @param context defines the webGL context to use (if not set, the current one will be used)
  31840. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31841. * @returns the new webGL program
  31842. */
  31843. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31844. /**
  31845. * Creates a webGL program
  31846. * @param pipelineContext defines the pipeline context to attach to
  31847. * @param vertexCode defines the vertex shader code to use
  31848. * @param fragmentCode defines the fragment shader code to use
  31849. * @param defines defines the string containing the defines to use to compile the shaders
  31850. * @param context defines the webGL context to use (if not set, the current one will be used)
  31851. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31852. * @returns the new webGL program
  31853. */
  31854. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31855. /**
  31856. * Creates a new pipeline context
  31857. * @returns the new pipeline
  31858. */
  31859. createPipelineContext(): IPipelineContext;
  31860. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31861. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31862. /** @hidden */
  31863. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31864. /** @hidden */
  31865. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31866. /** @hidden */
  31867. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31868. /**
  31869. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31870. * @param pipelineContext defines the pipeline context to use
  31871. * @param uniformsNames defines the list of uniform names
  31872. * @returns an array of webGL uniform locations
  31873. */
  31874. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31875. /**
  31876. * Gets the lsit of active attributes for a given webGL program
  31877. * @param pipelineContext defines the pipeline context to use
  31878. * @param attributesNames defines the list of attribute names to get
  31879. * @returns an array of indices indicating the offset of each attribute
  31880. */
  31881. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31882. /**
  31883. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31884. * @param effect defines the effect to activate
  31885. */
  31886. enableEffect(effect: Nullable<Effect>): void;
  31887. /**
  31888. * Set the value of an uniform to a number (int)
  31889. * @param uniform defines the webGL uniform location where to store the value
  31890. * @param value defines the int number to store
  31891. */
  31892. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31893. /**
  31894. * Set the value of an uniform to an array of int32
  31895. * @param uniform defines the webGL uniform location where to store the value
  31896. * @param array defines the array of int32 to store
  31897. */
  31898. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31899. /**
  31900. * Set the value of an uniform to an array of int32 (stored as vec2)
  31901. * @param uniform defines the webGL uniform location where to store the value
  31902. * @param array defines the array of int32 to store
  31903. */
  31904. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31905. /**
  31906. * Set the value of an uniform to an array of int32 (stored as vec3)
  31907. * @param uniform defines the webGL uniform location where to store the value
  31908. * @param array defines the array of int32 to store
  31909. */
  31910. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31911. /**
  31912. * Set the value of an uniform to an array of int32 (stored as vec4)
  31913. * @param uniform defines the webGL uniform location where to store the value
  31914. * @param array defines the array of int32 to store
  31915. */
  31916. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31917. /**
  31918. * Set the value of an uniform to an array of number
  31919. * @param uniform defines the webGL uniform location where to store the value
  31920. * @param array defines the array of number to store
  31921. */
  31922. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31923. /**
  31924. * Set the value of an uniform to an array of number (stored as vec2)
  31925. * @param uniform defines the webGL uniform location where to store the value
  31926. * @param array defines the array of number to store
  31927. */
  31928. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31929. /**
  31930. * Set the value of an uniform to an array of number (stored as vec3)
  31931. * @param uniform defines the webGL uniform location where to store the value
  31932. * @param array defines the array of number to store
  31933. */
  31934. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31935. /**
  31936. * Set the value of an uniform to an array of number (stored as vec4)
  31937. * @param uniform defines the webGL uniform location where to store the value
  31938. * @param array defines the array of number to store
  31939. */
  31940. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31941. /**
  31942. * Set the value of an uniform to an array of float32 (stored as matrices)
  31943. * @param uniform defines the webGL uniform location where to store the value
  31944. * @param matrices defines the array of float32 to store
  31945. */
  31946. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31947. /**
  31948. * Set the value of an uniform to a matrix (3x3)
  31949. * @param uniform defines the webGL uniform location where to store the value
  31950. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31951. */
  31952. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31953. /**
  31954. * Set the value of an uniform to a matrix (2x2)
  31955. * @param uniform defines the webGL uniform location where to store the value
  31956. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31957. */
  31958. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31959. /**
  31960. * Set the value of an uniform to a number (float)
  31961. * @param uniform defines the webGL uniform location where to store the value
  31962. * @param value defines the float number to store
  31963. */
  31964. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31965. /**
  31966. * Set the value of an uniform to a vec2
  31967. * @param uniform defines the webGL uniform location where to store the value
  31968. * @param x defines the 1st component of the value
  31969. * @param y defines the 2nd component of the value
  31970. */
  31971. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31972. /**
  31973. * Set the value of an uniform to a vec3
  31974. * @param uniform defines the webGL uniform location where to store the value
  31975. * @param x defines the 1st component of the value
  31976. * @param y defines the 2nd component of the value
  31977. * @param z defines the 3rd component of the value
  31978. */
  31979. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31980. /**
  31981. * Set the value of an uniform to a vec4
  31982. * @param uniform defines the webGL uniform location where to store the value
  31983. * @param x defines the 1st component of the value
  31984. * @param y defines the 2nd component of the value
  31985. * @param z defines the 3rd component of the value
  31986. * @param w defines the 4th component of the value
  31987. */
  31988. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31989. /**
  31990. * Apply all cached states (depth, culling, stencil and alpha)
  31991. */
  31992. applyStates(): void;
  31993. /**
  31994. * Enable or disable color writing
  31995. * @param enable defines the state to set
  31996. */
  31997. setColorWrite(enable: boolean): void;
  31998. /**
  31999. * Gets a boolean indicating if color writing is enabled
  32000. * @returns the current color writing state
  32001. */
  32002. getColorWrite(): boolean;
  32003. /**
  32004. * Gets the depth culling state manager
  32005. */
  32006. get depthCullingState(): DepthCullingState;
  32007. /**
  32008. * Gets the alpha state manager
  32009. */
  32010. get alphaState(): AlphaState;
  32011. /**
  32012. * Gets the stencil state manager
  32013. */
  32014. get stencilState(): StencilState;
  32015. /**
  32016. * Clears the list of texture accessible through engine.
  32017. * This can help preventing texture load conflict due to name collision.
  32018. */
  32019. clearInternalTexturesCache(): void;
  32020. /**
  32021. * Force the entire cache to be cleared
  32022. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32023. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32024. */
  32025. wipeCaches(bruteForce?: boolean): void;
  32026. /** @hidden */
  32027. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32028. min: number;
  32029. mag: number;
  32030. };
  32031. /** @hidden */
  32032. _createTexture(): WebGLTexture;
  32033. /**
  32034. * Usually called from Texture.ts.
  32035. * Passed information to create a WebGLTexture
  32036. * @param url defines a value which contains one of the following:
  32037. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32038. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32039. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32040. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32041. * @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)
  32042. * @param scene needed for loading to the correct scene
  32043. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32044. * @param onLoad optional callback to be called upon successful completion
  32045. * @param onError optional callback to be called upon failure
  32046. * @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
  32047. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32048. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32049. * @param forcedExtension defines the extension to use to pick the right loader
  32050. * @param mimeType defines an optional mime type
  32051. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32052. */
  32053. 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;
  32054. /**
  32055. * Loads an image as an HTMLImageElement.
  32056. * @param input url string, ArrayBuffer, or Blob to load
  32057. * @param onLoad callback called when the image successfully loads
  32058. * @param onError callback called when the image fails to load
  32059. * @param offlineProvider offline provider for caching
  32060. * @param mimeType optional mime type
  32061. * @returns the HTMLImageElement of the loaded image
  32062. * @hidden
  32063. */
  32064. 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>;
  32065. /**
  32066. * @hidden
  32067. */
  32068. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32069. /**
  32070. * Creates a raw texture
  32071. * @param data defines the data to store in the texture
  32072. * @param width defines the width of the texture
  32073. * @param height defines the height of the texture
  32074. * @param format defines the format of the data
  32075. * @param generateMipMaps defines if the engine should generate the mip levels
  32076. * @param invertY defines if data must be stored with Y axis inverted
  32077. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32078. * @param compression defines the compression used (null by default)
  32079. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32080. * @returns the raw texture inside an InternalTexture
  32081. */
  32082. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32083. /**
  32084. * Creates a new raw cube texture
  32085. * @param data defines the array of data to use to create each face
  32086. * @param size defines the size of the textures
  32087. * @param format defines the format of the data
  32088. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32089. * @param generateMipMaps defines if the engine should generate the mip levels
  32090. * @param invertY defines if data must be stored with Y axis inverted
  32091. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32092. * @param compression defines the compression used (null by default)
  32093. * @returns the cube texture as an InternalTexture
  32094. */
  32095. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32096. /**
  32097. * Creates a new raw 3D texture
  32098. * @param data defines the data used to create the texture
  32099. * @param width defines the width of the texture
  32100. * @param height defines the height of the texture
  32101. * @param depth defines the depth of the texture
  32102. * @param format defines the format of the texture
  32103. * @param generateMipMaps defines if the engine must generate mip levels
  32104. * @param invertY defines if data must be stored with Y axis inverted
  32105. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32106. * @param compression defines the compressed used (can be null)
  32107. * @param textureType defines the compressed used (can be null)
  32108. * @returns a new raw 3D texture (stored in an InternalTexture)
  32109. */
  32110. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32111. /**
  32112. * Creates a new raw 2D array texture
  32113. * @param data defines the data used to create the texture
  32114. * @param width defines the width of the texture
  32115. * @param height defines the height of the texture
  32116. * @param depth defines the number of layers of the texture
  32117. * @param format defines the format of the texture
  32118. * @param generateMipMaps defines if the engine must generate mip levels
  32119. * @param invertY defines if data must be stored with Y axis inverted
  32120. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32121. * @param compression defines the compressed used (can be null)
  32122. * @param textureType defines the compressed used (can be null)
  32123. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32124. */
  32125. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32126. private _unpackFlipYCached;
  32127. /**
  32128. * In case you are sharing the context with other applications, it might
  32129. * be interested to not cache the unpack flip y state to ensure a consistent
  32130. * value would be set.
  32131. */
  32132. enableUnpackFlipYCached: boolean;
  32133. /** @hidden */
  32134. _unpackFlipY(value: boolean): void;
  32135. /** @hidden */
  32136. _getUnpackAlignement(): number;
  32137. private _getTextureTarget;
  32138. /**
  32139. * Update the sampling mode of a given texture
  32140. * @param samplingMode defines the required sampling mode
  32141. * @param texture defines the texture to update
  32142. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32143. */
  32144. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32145. /**
  32146. * Update the sampling mode of a given texture
  32147. * @param texture defines the texture to update
  32148. * @param wrapU defines the texture wrap mode of the u coordinates
  32149. * @param wrapV defines the texture wrap mode of the v coordinates
  32150. * @param wrapR defines the texture wrap mode of the r coordinates
  32151. */
  32152. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32153. /** @hidden */
  32154. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32155. width: number;
  32156. height: number;
  32157. layers?: number;
  32158. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32159. /** @hidden */
  32160. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32161. /** @hidden */
  32162. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32163. /**
  32164. * Update a portion of an internal texture
  32165. * @param texture defines the texture to update
  32166. * @param imageData defines the data to store into the texture
  32167. * @param xOffset defines the x coordinates of the update rectangle
  32168. * @param yOffset defines the y coordinates of the update rectangle
  32169. * @param width defines the width of the update rectangle
  32170. * @param height defines the height of the update rectangle
  32171. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32172. * @param lod defines the lod level to update (0 by default)
  32173. */
  32174. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32175. /** @hidden */
  32176. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32177. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32178. private _prepareWebGLTexture;
  32179. /** @hidden */
  32180. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32181. private _getDepthStencilBuffer;
  32182. /** @hidden */
  32183. _releaseFramebufferObjects(texture: InternalTexture): void;
  32184. /** @hidden */
  32185. _releaseTexture(texture: InternalTexture): void;
  32186. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32187. protected _setProgram(program: WebGLProgram): void;
  32188. protected _boundUniforms: {
  32189. [key: number]: WebGLUniformLocation;
  32190. };
  32191. /**
  32192. * Binds an effect to the webGL context
  32193. * @param effect defines the effect to bind
  32194. */
  32195. bindSamplers(effect: Effect): void;
  32196. private _activateCurrentTexture;
  32197. /** @hidden */
  32198. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32199. /** @hidden */
  32200. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32201. /**
  32202. * Unbind all textures from the webGL context
  32203. */
  32204. unbindAllTextures(): void;
  32205. /**
  32206. * Sets a texture to the according uniform.
  32207. * @param channel The texture channel
  32208. * @param uniform The uniform to set
  32209. * @param texture The texture to apply
  32210. */
  32211. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32212. private _bindSamplerUniformToChannel;
  32213. private _getTextureWrapMode;
  32214. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32215. /**
  32216. * Sets an array of texture to the webGL context
  32217. * @param channel defines the channel where the texture array must be set
  32218. * @param uniform defines the associated uniform location
  32219. * @param textures defines the array of textures to bind
  32220. */
  32221. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32222. /** @hidden */
  32223. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32224. private _setTextureParameterFloat;
  32225. private _setTextureParameterInteger;
  32226. /**
  32227. * Unbind all vertex attributes from the webGL context
  32228. */
  32229. unbindAllAttributes(): void;
  32230. /**
  32231. * 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
  32232. */
  32233. releaseEffects(): void;
  32234. /**
  32235. * Dispose and release all associated resources
  32236. */
  32237. dispose(): void;
  32238. /**
  32239. * Attach a new callback raised when context lost event is fired
  32240. * @param callback defines the callback to call
  32241. */
  32242. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32243. /**
  32244. * Attach a new callback raised when context restored event is fired
  32245. * @param callback defines the callback to call
  32246. */
  32247. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32248. /**
  32249. * Get the current error code of the webGL context
  32250. * @returns the error code
  32251. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32252. */
  32253. getError(): number;
  32254. private _canRenderToFloatFramebuffer;
  32255. private _canRenderToHalfFloatFramebuffer;
  32256. private _canRenderToFramebuffer;
  32257. /** @hidden */
  32258. _getWebGLTextureType(type: number): number;
  32259. /** @hidden */
  32260. _getInternalFormat(format: number): number;
  32261. /** @hidden */
  32262. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32263. /** @hidden */
  32264. _getRGBAMultiSampleBufferFormat(type: number): number;
  32265. /** @hidden */
  32266. _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;
  32267. /**
  32268. * Loads a file from a url
  32269. * @param url url to load
  32270. * @param onSuccess callback called when the file successfully loads
  32271. * @param onProgress callback called while file is loading (if the server supports this mode)
  32272. * @param offlineProvider defines the offline provider for caching
  32273. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32274. * @param onError callback called when the file fails to load
  32275. * @returns a file request object
  32276. * @hidden
  32277. */
  32278. 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;
  32279. /**
  32280. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32281. * @param x defines the x coordinate of the rectangle where pixels must be read
  32282. * @param y defines the y coordinate of the rectangle where pixels must be read
  32283. * @param width defines the width of the rectangle where pixels must be read
  32284. * @param height defines the height of the rectangle where pixels must be read
  32285. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32286. * @returns a Uint8Array containing RGBA colors
  32287. */
  32288. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32289. private static _isSupported;
  32290. /**
  32291. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32292. * @returns true if the engine can be created
  32293. * @ignorenaming
  32294. */
  32295. static isSupported(): boolean;
  32296. /**
  32297. * Find the next highest power of two.
  32298. * @param x Number to start search from.
  32299. * @return Next highest power of two.
  32300. */
  32301. static CeilingPOT(x: number): number;
  32302. /**
  32303. * Find the next lowest power of two.
  32304. * @param x Number to start search from.
  32305. * @return Next lowest power of two.
  32306. */
  32307. static FloorPOT(x: number): number;
  32308. /**
  32309. * Find the nearest power of two.
  32310. * @param x Number to start search from.
  32311. * @return Next nearest power of two.
  32312. */
  32313. static NearestPOT(x: number): number;
  32314. /**
  32315. * Get the closest exponent of two
  32316. * @param value defines the value to approximate
  32317. * @param max defines the maximum value to return
  32318. * @param mode defines how to define the closest value
  32319. * @returns closest exponent of two of the given value
  32320. */
  32321. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32322. /**
  32323. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32324. * @param func - the function to be called
  32325. * @param requester - the object that will request the next frame. Falls back to window.
  32326. * @returns frame number
  32327. */
  32328. static QueueNewFrame(func: () => void, requester?: any): number;
  32329. /**
  32330. * Gets host document
  32331. * @returns the host document object
  32332. */
  32333. getHostDocument(): Nullable<Document>;
  32334. }
  32335. }
  32336. declare module BABYLON {
  32337. /**
  32338. * Class representing spherical harmonics coefficients to the 3rd degree
  32339. */
  32340. export class SphericalHarmonics {
  32341. /**
  32342. * Defines whether or not the harmonics have been prescaled for rendering.
  32343. */
  32344. preScaled: boolean;
  32345. /**
  32346. * The l0,0 coefficients of the spherical harmonics
  32347. */
  32348. l00: Vector3;
  32349. /**
  32350. * The l1,-1 coefficients of the spherical harmonics
  32351. */
  32352. l1_1: Vector3;
  32353. /**
  32354. * The l1,0 coefficients of the spherical harmonics
  32355. */
  32356. l10: Vector3;
  32357. /**
  32358. * The l1,1 coefficients of the spherical harmonics
  32359. */
  32360. l11: Vector3;
  32361. /**
  32362. * The l2,-2 coefficients of the spherical harmonics
  32363. */
  32364. l2_2: Vector3;
  32365. /**
  32366. * The l2,-1 coefficients of the spherical harmonics
  32367. */
  32368. l2_1: Vector3;
  32369. /**
  32370. * The l2,0 coefficients of the spherical harmonics
  32371. */
  32372. l20: Vector3;
  32373. /**
  32374. * The l2,1 coefficients of the spherical harmonics
  32375. */
  32376. l21: Vector3;
  32377. /**
  32378. * The l2,2 coefficients of the spherical harmonics
  32379. */
  32380. l22: Vector3;
  32381. /**
  32382. * Adds a light to the spherical harmonics
  32383. * @param direction the direction of the light
  32384. * @param color the color of the light
  32385. * @param deltaSolidAngle the delta solid angle of the light
  32386. */
  32387. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32388. /**
  32389. * Scales the spherical harmonics by the given amount
  32390. * @param scale the amount to scale
  32391. */
  32392. scaleInPlace(scale: number): void;
  32393. /**
  32394. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32395. *
  32396. * ```
  32397. * E_lm = A_l * L_lm
  32398. * ```
  32399. *
  32400. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32401. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32402. * the scaling factors are given in equation 9.
  32403. */
  32404. convertIncidentRadianceToIrradiance(): void;
  32405. /**
  32406. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32407. *
  32408. * ```
  32409. * L = (1/pi) * E * rho
  32410. * ```
  32411. *
  32412. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32413. */
  32414. convertIrradianceToLambertianRadiance(): void;
  32415. /**
  32416. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32417. * required operations at run time.
  32418. *
  32419. * This is simply done by scaling back the SH with Ylm constants parameter.
  32420. * The trigonometric part being applied by the shader at run time.
  32421. */
  32422. preScaleForRendering(): void;
  32423. /**
  32424. * Constructs a spherical harmonics from an array.
  32425. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32426. * @returns the spherical harmonics
  32427. */
  32428. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32429. /**
  32430. * Gets the spherical harmonics from polynomial
  32431. * @param polynomial the spherical polynomial
  32432. * @returns the spherical harmonics
  32433. */
  32434. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32435. }
  32436. /**
  32437. * Class representing spherical polynomial coefficients to the 3rd degree
  32438. */
  32439. export class SphericalPolynomial {
  32440. private _harmonics;
  32441. /**
  32442. * The spherical harmonics used to create the polynomials.
  32443. */
  32444. get preScaledHarmonics(): SphericalHarmonics;
  32445. /**
  32446. * The x coefficients of the spherical polynomial
  32447. */
  32448. x: Vector3;
  32449. /**
  32450. * The y coefficients of the spherical polynomial
  32451. */
  32452. y: Vector3;
  32453. /**
  32454. * The z coefficients of the spherical polynomial
  32455. */
  32456. z: Vector3;
  32457. /**
  32458. * The xx coefficients of the spherical polynomial
  32459. */
  32460. xx: Vector3;
  32461. /**
  32462. * The yy coefficients of the spherical polynomial
  32463. */
  32464. yy: Vector3;
  32465. /**
  32466. * The zz coefficients of the spherical polynomial
  32467. */
  32468. zz: Vector3;
  32469. /**
  32470. * The xy coefficients of the spherical polynomial
  32471. */
  32472. xy: Vector3;
  32473. /**
  32474. * The yz coefficients of the spherical polynomial
  32475. */
  32476. yz: Vector3;
  32477. /**
  32478. * The zx coefficients of the spherical polynomial
  32479. */
  32480. zx: Vector3;
  32481. /**
  32482. * Adds an ambient color to the spherical polynomial
  32483. * @param color the color to add
  32484. */
  32485. addAmbient(color: Color3): void;
  32486. /**
  32487. * Scales the spherical polynomial by the given amount
  32488. * @param scale the amount to scale
  32489. */
  32490. scaleInPlace(scale: number): void;
  32491. /**
  32492. * Gets the spherical polynomial from harmonics
  32493. * @param harmonics the spherical harmonics
  32494. * @returns the spherical polynomial
  32495. */
  32496. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32497. /**
  32498. * Constructs a spherical polynomial from an array.
  32499. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32500. * @returns the spherical polynomial
  32501. */
  32502. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32503. }
  32504. }
  32505. declare module BABYLON {
  32506. /**
  32507. * Defines the source of the internal texture
  32508. */
  32509. export enum InternalTextureSource {
  32510. /**
  32511. * The source of the texture data is unknown
  32512. */
  32513. Unknown = 0,
  32514. /**
  32515. * Texture data comes from an URL
  32516. */
  32517. Url = 1,
  32518. /**
  32519. * Texture data is only used for temporary storage
  32520. */
  32521. Temp = 2,
  32522. /**
  32523. * Texture data comes from raw data (ArrayBuffer)
  32524. */
  32525. Raw = 3,
  32526. /**
  32527. * Texture content is dynamic (video or dynamic texture)
  32528. */
  32529. Dynamic = 4,
  32530. /**
  32531. * Texture content is generated by rendering to it
  32532. */
  32533. RenderTarget = 5,
  32534. /**
  32535. * Texture content is part of a multi render target process
  32536. */
  32537. MultiRenderTarget = 6,
  32538. /**
  32539. * Texture data comes from a cube data file
  32540. */
  32541. Cube = 7,
  32542. /**
  32543. * Texture data comes from a raw cube data
  32544. */
  32545. CubeRaw = 8,
  32546. /**
  32547. * Texture data come from a prefiltered cube data file
  32548. */
  32549. CubePrefiltered = 9,
  32550. /**
  32551. * Texture content is raw 3D data
  32552. */
  32553. Raw3D = 10,
  32554. /**
  32555. * Texture content is raw 2D array data
  32556. */
  32557. Raw2DArray = 11,
  32558. /**
  32559. * Texture content is a depth texture
  32560. */
  32561. Depth = 12,
  32562. /**
  32563. * Texture data comes from a raw cube data encoded with RGBD
  32564. */
  32565. CubeRawRGBD = 13
  32566. }
  32567. /**
  32568. * Class used to store data associated with WebGL texture data for the engine
  32569. * This class should not be used directly
  32570. */
  32571. export class InternalTexture {
  32572. /** @hidden */
  32573. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32574. /**
  32575. * Defines if the texture is ready
  32576. */
  32577. isReady: boolean;
  32578. /**
  32579. * Defines if the texture is a cube texture
  32580. */
  32581. isCube: boolean;
  32582. /**
  32583. * Defines if the texture contains 3D data
  32584. */
  32585. is3D: boolean;
  32586. /**
  32587. * Defines if the texture contains 2D array data
  32588. */
  32589. is2DArray: boolean;
  32590. /**
  32591. * Defines if the texture contains multiview data
  32592. */
  32593. isMultiview: boolean;
  32594. /**
  32595. * Gets the URL used to load this texture
  32596. */
  32597. url: string;
  32598. /**
  32599. * Gets the sampling mode of the texture
  32600. */
  32601. samplingMode: number;
  32602. /**
  32603. * Gets a boolean indicating if the texture needs mipmaps generation
  32604. */
  32605. generateMipMaps: boolean;
  32606. /**
  32607. * Gets the number of samples used by the texture (WebGL2+ only)
  32608. */
  32609. samples: number;
  32610. /**
  32611. * Gets the type of the texture (int, float...)
  32612. */
  32613. type: number;
  32614. /**
  32615. * Gets the format of the texture (RGB, RGBA...)
  32616. */
  32617. format: number;
  32618. /**
  32619. * Observable called when the texture is loaded
  32620. */
  32621. onLoadedObservable: Observable<InternalTexture>;
  32622. /**
  32623. * Gets the width of the texture
  32624. */
  32625. width: number;
  32626. /**
  32627. * Gets the height of the texture
  32628. */
  32629. height: number;
  32630. /**
  32631. * Gets the depth of the texture
  32632. */
  32633. depth: number;
  32634. /**
  32635. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32636. */
  32637. baseWidth: number;
  32638. /**
  32639. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32640. */
  32641. baseHeight: number;
  32642. /**
  32643. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32644. */
  32645. baseDepth: number;
  32646. /**
  32647. * Gets a boolean indicating if the texture is inverted on Y axis
  32648. */
  32649. invertY: boolean;
  32650. /** @hidden */
  32651. _invertVScale: boolean;
  32652. /** @hidden */
  32653. _associatedChannel: number;
  32654. /** @hidden */
  32655. _source: InternalTextureSource;
  32656. /** @hidden */
  32657. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32658. /** @hidden */
  32659. _bufferView: Nullable<ArrayBufferView>;
  32660. /** @hidden */
  32661. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32662. /** @hidden */
  32663. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32664. /** @hidden */
  32665. _size: number;
  32666. /** @hidden */
  32667. _extension: string;
  32668. /** @hidden */
  32669. _files: Nullable<string[]>;
  32670. /** @hidden */
  32671. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32672. /** @hidden */
  32673. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32674. /** @hidden */
  32675. _framebuffer: Nullable<WebGLFramebuffer>;
  32676. /** @hidden */
  32677. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32678. /** @hidden */
  32679. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32680. /** @hidden */
  32681. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32682. /** @hidden */
  32683. _attachments: Nullable<number[]>;
  32684. /** @hidden */
  32685. _cachedCoordinatesMode: Nullable<number>;
  32686. /** @hidden */
  32687. _cachedWrapU: Nullable<number>;
  32688. /** @hidden */
  32689. _cachedWrapV: Nullable<number>;
  32690. /** @hidden */
  32691. _cachedWrapR: Nullable<number>;
  32692. /** @hidden */
  32693. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32694. /** @hidden */
  32695. _isDisabled: boolean;
  32696. /** @hidden */
  32697. _compression: Nullable<string>;
  32698. /** @hidden */
  32699. _generateStencilBuffer: boolean;
  32700. /** @hidden */
  32701. _generateDepthBuffer: boolean;
  32702. /** @hidden */
  32703. _comparisonFunction: number;
  32704. /** @hidden */
  32705. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32706. /** @hidden */
  32707. _lodGenerationScale: number;
  32708. /** @hidden */
  32709. _lodGenerationOffset: number;
  32710. /** @hidden */
  32711. _depthStencilTexture: Nullable<InternalTexture>;
  32712. /** @hidden */
  32713. _colorTextureArray: Nullable<WebGLTexture>;
  32714. /** @hidden */
  32715. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32716. /** @hidden */
  32717. _lodTextureHigh: Nullable<BaseTexture>;
  32718. /** @hidden */
  32719. _lodTextureMid: Nullable<BaseTexture>;
  32720. /** @hidden */
  32721. _lodTextureLow: Nullable<BaseTexture>;
  32722. /** @hidden */
  32723. _isRGBD: boolean;
  32724. /** @hidden */
  32725. _linearSpecularLOD: boolean;
  32726. /** @hidden */
  32727. _irradianceTexture: Nullable<BaseTexture>;
  32728. /** @hidden */
  32729. _webGLTexture: Nullable<WebGLTexture>;
  32730. /** @hidden */
  32731. _references: number;
  32732. private _engine;
  32733. /**
  32734. * Gets the Engine the texture belongs to.
  32735. * @returns The babylon engine
  32736. */
  32737. getEngine(): ThinEngine;
  32738. /**
  32739. * Gets the data source type of the texture
  32740. */
  32741. get source(): InternalTextureSource;
  32742. /**
  32743. * Creates a new InternalTexture
  32744. * @param engine defines the engine to use
  32745. * @param source defines the type of data that will be used
  32746. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32747. */
  32748. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32749. /**
  32750. * Increments the number of references (ie. the number of Texture that point to it)
  32751. */
  32752. incrementReferences(): void;
  32753. /**
  32754. * Change the size of the texture (not the size of the content)
  32755. * @param width defines the new width
  32756. * @param height defines the new height
  32757. * @param depth defines the new depth (1 by default)
  32758. */
  32759. updateSize(width: int, height: int, depth?: int): void;
  32760. /** @hidden */
  32761. _rebuild(): void;
  32762. /** @hidden */
  32763. _swapAndDie(target: InternalTexture): void;
  32764. /**
  32765. * Dispose the current allocated resources
  32766. */
  32767. dispose(): void;
  32768. }
  32769. }
  32770. declare module BABYLON {
  32771. /**
  32772. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32773. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32774. */
  32775. export class Analyser {
  32776. /**
  32777. * Gets or sets the smoothing
  32778. * @ignorenaming
  32779. */
  32780. SMOOTHING: number;
  32781. /**
  32782. * Gets or sets the FFT table size
  32783. * @ignorenaming
  32784. */
  32785. FFT_SIZE: number;
  32786. /**
  32787. * Gets or sets the bar graph amplitude
  32788. * @ignorenaming
  32789. */
  32790. BARGRAPHAMPLITUDE: number;
  32791. /**
  32792. * Gets or sets the position of the debug canvas
  32793. * @ignorenaming
  32794. */
  32795. DEBUGCANVASPOS: {
  32796. x: number;
  32797. y: number;
  32798. };
  32799. /**
  32800. * Gets or sets the debug canvas size
  32801. * @ignorenaming
  32802. */
  32803. DEBUGCANVASSIZE: {
  32804. width: number;
  32805. height: number;
  32806. };
  32807. private _byteFreqs;
  32808. private _byteTime;
  32809. private _floatFreqs;
  32810. private _webAudioAnalyser;
  32811. private _debugCanvas;
  32812. private _debugCanvasContext;
  32813. private _scene;
  32814. private _registerFunc;
  32815. private _audioEngine;
  32816. /**
  32817. * Creates a new analyser
  32818. * @param scene defines hosting scene
  32819. */
  32820. constructor(scene: Scene);
  32821. /**
  32822. * Get the number of data values you will have to play with for the visualization
  32823. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32824. * @returns a number
  32825. */
  32826. getFrequencyBinCount(): number;
  32827. /**
  32828. * Gets the current frequency data as a byte array
  32829. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32830. * @returns a Uint8Array
  32831. */
  32832. getByteFrequencyData(): Uint8Array;
  32833. /**
  32834. * Gets the current waveform as a byte array
  32835. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32836. * @returns a Uint8Array
  32837. */
  32838. getByteTimeDomainData(): Uint8Array;
  32839. /**
  32840. * Gets the current frequency data as a float array
  32841. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32842. * @returns a Float32Array
  32843. */
  32844. getFloatFrequencyData(): Float32Array;
  32845. /**
  32846. * Renders the debug canvas
  32847. */
  32848. drawDebugCanvas(): void;
  32849. /**
  32850. * Stops rendering the debug canvas and removes it
  32851. */
  32852. stopDebugCanvas(): void;
  32853. /**
  32854. * Connects two audio nodes
  32855. * @param inputAudioNode defines first node to connect
  32856. * @param outputAudioNode defines second node to connect
  32857. */
  32858. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32859. /**
  32860. * Releases all associated resources
  32861. */
  32862. dispose(): void;
  32863. }
  32864. }
  32865. declare module BABYLON {
  32866. /**
  32867. * This represents an audio engine and it is responsible
  32868. * to play, synchronize and analyse sounds throughout the application.
  32869. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32870. */
  32871. export interface IAudioEngine extends IDisposable {
  32872. /**
  32873. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32874. */
  32875. readonly canUseWebAudio: boolean;
  32876. /**
  32877. * Gets the current AudioContext if available.
  32878. */
  32879. readonly audioContext: Nullable<AudioContext>;
  32880. /**
  32881. * The master gain node defines the global audio volume of your audio engine.
  32882. */
  32883. readonly masterGain: GainNode;
  32884. /**
  32885. * Gets whether or not mp3 are supported by your browser.
  32886. */
  32887. readonly isMP3supported: boolean;
  32888. /**
  32889. * Gets whether or not ogg are supported by your browser.
  32890. */
  32891. readonly isOGGsupported: boolean;
  32892. /**
  32893. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32894. * @ignoreNaming
  32895. */
  32896. WarnedWebAudioUnsupported: boolean;
  32897. /**
  32898. * Defines if the audio engine relies on a custom unlocked button.
  32899. * In this case, the embedded button will not be displayed.
  32900. */
  32901. useCustomUnlockedButton: boolean;
  32902. /**
  32903. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32904. */
  32905. readonly unlocked: boolean;
  32906. /**
  32907. * Event raised when audio has been unlocked on the browser.
  32908. */
  32909. onAudioUnlockedObservable: Observable<AudioEngine>;
  32910. /**
  32911. * Event raised when audio has been locked on the browser.
  32912. */
  32913. onAudioLockedObservable: Observable<AudioEngine>;
  32914. /**
  32915. * Flags the audio engine in Locked state.
  32916. * This happens due to new browser policies preventing audio to autoplay.
  32917. */
  32918. lock(): void;
  32919. /**
  32920. * Unlocks the audio engine once a user action has been done on the dom.
  32921. * This is helpful to resume play once browser policies have been satisfied.
  32922. */
  32923. unlock(): void;
  32924. /**
  32925. * Gets the global volume sets on the master gain.
  32926. * @returns the global volume if set or -1 otherwise
  32927. */
  32928. getGlobalVolume(): number;
  32929. /**
  32930. * Sets the global volume of your experience (sets on the master gain).
  32931. * @param newVolume Defines the new global volume of the application
  32932. */
  32933. setGlobalVolume(newVolume: number): void;
  32934. /**
  32935. * Connect the audio engine to an audio analyser allowing some amazing
  32936. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32937. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32938. * @param analyser The analyser to connect to the engine
  32939. */
  32940. connectToAnalyser(analyser: Analyser): void;
  32941. }
  32942. /**
  32943. * This represents the default audio engine used in babylon.
  32944. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32945. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32946. */
  32947. export class AudioEngine implements IAudioEngine {
  32948. private _audioContext;
  32949. private _audioContextInitialized;
  32950. private _muteButton;
  32951. private _hostElement;
  32952. /**
  32953. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32954. */
  32955. canUseWebAudio: boolean;
  32956. /**
  32957. * The master gain node defines the global audio volume of your audio engine.
  32958. */
  32959. masterGain: GainNode;
  32960. /**
  32961. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32962. * @ignoreNaming
  32963. */
  32964. WarnedWebAudioUnsupported: boolean;
  32965. /**
  32966. * Gets whether or not mp3 are supported by your browser.
  32967. */
  32968. isMP3supported: boolean;
  32969. /**
  32970. * Gets whether or not ogg are supported by your browser.
  32971. */
  32972. isOGGsupported: boolean;
  32973. /**
  32974. * Gets whether audio has been unlocked on the device.
  32975. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  32976. * a user interaction has happened.
  32977. */
  32978. unlocked: boolean;
  32979. /**
  32980. * Defines if the audio engine relies on a custom unlocked button.
  32981. * In this case, the embedded button will not be displayed.
  32982. */
  32983. useCustomUnlockedButton: boolean;
  32984. /**
  32985. * Event raised when audio has been unlocked on the browser.
  32986. */
  32987. onAudioUnlockedObservable: Observable<AudioEngine>;
  32988. /**
  32989. * Event raised when audio has been locked on the browser.
  32990. */
  32991. onAudioLockedObservable: Observable<AudioEngine>;
  32992. /**
  32993. * Gets the current AudioContext if available.
  32994. */
  32995. get audioContext(): Nullable<AudioContext>;
  32996. private _connectedAnalyser;
  32997. /**
  32998. * Instantiates a new audio engine.
  32999. *
  33000. * There should be only one per page as some browsers restrict the number
  33001. * of audio contexts you can create.
  33002. * @param hostElement defines the host element where to display the mute icon if necessary
  33003. */
  33004. constructor(hostElement?: Nullable<HTMLElement>);
  33005. /**
  33006. * Flags the audio engine in Locked state.
  33007. * This happens due to new browser policies preventing audio to autoplay.
  33008. */
  33009. lock(): void;
  33010. /**
  33011. * Unlocks the audio engine once a user action has been done on the dom.
  33012. * This is helpful to resume play once browser policies have been satisfied.
  33013. */
  33014. unlock(): void;
  33015. private _resumeAudioContext;
  33016. private _initializeAudioContext;
  33017. private _tryToRun;
  33018. private _triggerRunningState;
  33019. private _triggerSuspendedState;
  33020. private _displayMuteButton;
  33021. private _moveButtonToTopLeft;
  33022. private _onResize;
  33023. private _hideMuteButton;
  33024. /**
  33025. * Destroy and release the resources associated with the audio ccontext.
  33026. */
  33027. dispose(): void;
  33028. /**
  33029. * Gets the global volume sets on the master gain.
  33030. * @returns the global volume if set or -1 otherwise
  33031. */
  33032. getGlobalVolume(): number;
  33033. /**
  33034. * Sets the global volume of your experience (sets on the master gain).
  33035. * @param newVolume Defines the new global volume of the application
  33036. */
  33037. setGlobalVolume(newVolume: number): void;
  33038. /**
  33039. * Connect the audio engine to an audio analyser allowing some amazing
  33040. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33041. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33042. * @param analyser The analyser to connect to the engine
  33043. */
  33044. connectToAnalyser(analyser: Analyser): void;
  33045. }
  33046. }
  33047. declare module BABYLON {
  33048. /**
  33049. * Interface used to present a loading screen while loading a scene
  33050. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33051. */
  33052. export interface ILoadingScreen {
  33053. /**
  33054. * Function called to display the loading screen
  33055. */
  33056. displayLoadingUI: () => void;
  33057. /**
  33058. * Function called to hide the loading screen
  33059. */
  33060. hideLoadingUI: () => void;
  33061. /**
  33062. * Gets or sets the color to use for the background
  33063. */
  33064. loadingUIBackgroundColor: string;
  33065. /**
  33066. * Gets or sets the text to display while loading
  33067. */
  33068. loadingUIText: string;
  33069. }
  33070. /**
  33071. * Class used for the default loading screen
  33072. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33073. */
  33074. export class DefaultLoadingScreen implements ILoadingScreen {
  33075. private _renderingCanvas;
  33076. private _loadingText;
  33077. private _loadingDivBackgroundColor;
  33078. private _loadingDiv;
  33079. private _loadingTextDiv;
  33080. /** Gets or sets the logo url to use for the default loading screen */
  33081. static DefaultLogoUrl: string;
  33082. /** Gets or sets the spinner url to use for the default loading screen */
  33083. static DefaultSpinnerUrl: string;
  33084. /**
  33085. * Creates a new default loading screen
  33086. * @param _renderingCanvas defines the canvas used to render the scene
  33087. * @param _loadingText defines the default text to display
  33088. * @param _loadingDivBackgroundColor defines the default background color
  33089. */
  33090. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33091. /**
  33092. * Function called to display the loading screen
  33093. */
  33094. displayLoadingUI(): void;
  33095. /**
  33096. * Function called to hide the loading screen
  33097. */
  33098. hideLoadingUI(): void;
  33099. /**
  33100. * Gets or sets the text to display while loading
  33101. */
  33102. set loadingUIText(text: string);
  33103. get loadingUIText(): string;
  33104. /**
  33105. * Gets or sets the color to use for the background
  33106. */
  33107. get loadingUIBackgroundColor(): string;
  33108. set loadingUIBackgroundColor(color: string);
  33109. private _resizeLoadingUI;
  33110. }
  33111. }
  33112. declare module BABYLON {
  33113. /**
  33114. * Interface for any object that can request an animation frame
  33115. */
  33116. export interface ICustomAnimationFrameRequester {
  33117. /**
  33118. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33119. */
  33120. renderFunction?: Function;
  33121. /**
  33122. * Called to request the next frame to render to
  33123. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33124. */
  33125. requestAnimationFrame: Function;
  33126. /**
  33127. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33128. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33129. */
  33130. requestID?: number;
  33131. }
  33132. }
  33133. declare module BABYLON {
  33134. /**
  33135. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33136. */
  33137. export class PerformanceMonitor {
  33138. private _enabled;
  33139. private _rollingFrameTime;
  33140. private _lastFrameTimeMs;
  33141. /**
  33142. * constructor
  33143. * @param frameSampleSize The number of samples required to saturate the sliding window
  33144. */
  33145. constructor(frameSampleSize?: number);
  33146. /**
  33147. * Samples current frame
  33148. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33149. */
  33150. sampleFrame(timeMs?: number): void;
  33151. /**
  33152. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33153. */
  33154. get averageFrameTime(): number;
  33155. /**
  33156. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33157. */
  33158. get averageFrameTimeVariance(): number;
  33159. /**
  33160. * Returns the frame time of the most recent frame
  33161. */
  33162. get instantaneousFrameTime(): number;
  33163. /**
  33164. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33165. */
  33166. get averageFPS(): number;
  33167. /**
  33168. * Returns the average framerate in frames per second using the most recent frame time
  33169. */
  33170. get instantaneousFPS(): number;
  33171. /**
  33172. * Returns true if enough samples have been taken to completely fill the sliding window
  33173. */
  33174. get isSaturated(): boolean;
  33175. /**
  33176. * Enables contributions to the sliding window sample set
  33177. */
  33178. enable(): void;
  33179. /**
  33180. * Disables contributions to the sliding window sample set
  33181. * Samples will not be interpolated over the disabled period
  33182. */
  33183. disable(): void;
  33184. /**
  33185. * Returns true if sampling is enabled
  33186. */
  33187. get isEnabled(): boolean;
  33188. /**
  33189. * Resets performance monitor
  33190. */
  33191. reset(): void;
  33192. }
  33193. /**
  33194. * RollingAverage
  33195. *
  33196. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33197. */
  33198. export class RollingAverage {
  33199. /**
  33200. * Current average
  33201. */
  33202. average: number;
  33203. /**
  33204. * Current variance
  33205. */
  33206. variance: number;
  33207. protected _samples: Array<number>;
  33208. protected _sampleCount: number;
  33209. protected _pos: number;
  33210. protected _m2: number;
  33211. /**
  33212. * constructor
  33213. * @param length The number of samples required to saturate the sliding window
  33214. */
  33215. constructor(length: number);
  33216. /**
  33217. * Adds a sample to the sample set
  33218. * @param v The sample value
  33219. */
  33220. add(v: number): void;
  33221. /**
  33222. * Returns previously added values or null if outside of history or outside the sliding window domain
  33223. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33224. * @return Value previously recorded with add() or null if outside of range
  33225. */
  33226. history(i: number): number;
  33227. /**
  33228. * Returns true if enough samples have been taken to completely fill the sliding window
  33229. * @return true if sample-set saturated
  33230. */
  33231. isSaturated(): boolean;
  33232. /**
  33233. * Resets the rolling average (equivalent to 0 samples taken so far)
  33234. */
  33235. reset(): void;
  33236. /**
  33237. * Wraps a value around the sample range boundaries
  33238. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33239. * @return Wrapped position in sample range
  33240. */
  33241. protected _wrapPosition(i: number): number;
  33242. }
  33243. }
  33244. declare module BABYLON {
  33245. /**
  33246. * This class is used to track a performance counter which is number based.
  33247. * The user has access to many properties which give statistics of different nature.
  33248. *
  33249. * The implementer can track two kinds of Performance Counter: time and count.
  33250. * 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.
  33251. * 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.
  33252. */
  33253. export class PerfCounter {
  33254. /**
  33255. * Gets or sets a global boolean to turn on and off all the counters
  33256. */
  33257. static Enabled: boolean;
  33258. /**
  33259. * Returns the smallest value ever
  33260. */
  33261. get min(): number;
  33262. /**
  33263. * Returns the biggest value ever
  33264. */
  33265. get max(): number;
  33266. /**
  33267. * Returns the average value since the performance counter is running
  33268. */
  33269. get average(): number;
  33270. /**
  33271. * Returns the average value of the last second the counter was monitored
  33272. */
  33273. get lastSecAverage(): number;
  33274. /**
  33275. * Returns the current value
  33276. */
  33277. get current(): number;
  33278. /**
  33279. * Gets the accumulated total
  33280. */
  33281. get total(): number;
  33282. /**
  33283. * Gets the total value count
  33284. */
  33285. get count(): number;
  33286. /**
  33287. * Creates a new counter
  33288. */
  33289. constructor();
  33290. /**
  33291. * Call this method to start monitoring a new frame.
  33292. * 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.
  33293. */
  33294. fetchNewFrame(): void;
  33295. /**
  33296. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33297. * @param newCount the count value to add to the monitored count
  33298. * @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.
  33299. */
  33300. addCount(newCount: number, fetchResult: boolean): void;
  33301. /**
  33302. * Start monitoring this performance counter
  33303. */
  33304. beginMonitoring(): void;
  33305. /**
  33306. * Compute the time lapsed since the previous beginMonitoring() call.
  33307. * @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
  33308. */
  33309. endMonitoring(newFrame?: boolean): void;
  33310. private _fetchResult;
  33311. private _startMonitoringTime;
  33312. private _min;
  33313. private _max;
  33314. private _average;
  33315. private _current;
  33316. private _totalValueCount;
  33317. private _totalAccumulated;
  33318. private _lastSecAverage;
  33319. private _lastSecAccumulated;
  33320. private _lastSecTime;
  33321. private _lastSecValueCount;
  33322. }
  33323. }
  33324. declare module BABYLON {
  33325. interface ThinEngine {
  33326. /**
  33327. * Sets alpha constants used by some alpha blending modes
  33328. * @param r defines the red component
  33329. * @param g defines the green component
  33330. * @param b defines the blue component
  33331. * @param a defines the alpha component
  33332. */
  33333. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33334. /**
  33335. * Sets the current alpha mode
  33336. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33337. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33338. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33339. */
  33340. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33341. /**
  33342. * Gets the current alpha mode
  33343. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33344. * @returns the current alpha mode
  33345. */
  33346. getAlphaMode(): number;
  33347. /**
  33348. * Sets the current alpha equation
  33349. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33350. */
  33351. setAlphaEquation(equation: number): void;
  33352. /**
  33353. * Gets the current alpha equation.
  33354. * @returns the current alpha equation
  33355. */
  33356. getAlphaEquation(): number;
  33357. }
  33358. }
  33359. declare module BABYLON {
  33360. /**
  33361. * Defines the interface used by display changed events
  33362. */
  33363. export interface IDisplayChangedEventArgs {
  33364. /** Gets the vrDisplay object (if any) */
  33365. vrDisplay: Nullable<any>;
  33366. /** Gets a boolean indicating if webVR is supported */
  33367. vrSupported: boolean;
  33368. }
  33369. /**
  33370. * Defines the interface used by objects containing a viewport (like a camera)
  33371. */
  33372. interface IViewportOwnerLike {
  33373. /**
  33374. * Gets or sets the viewport
  33375. */
  33376. viewport: IViewportLike;
  33377. }
  33378. /**
  33379. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33380. */
  33381. export class Engine extends ThinEngine {
  33382. /** Defines that alpha blending is disabled */
  33383. static readonly ALPHA_DISABLE: number;
  33384. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33385. static readonly ALPHA_ADD: number;
  33386. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33387. static readonly ALPHA_COMBINE: number;
  33388. /** Defines that alpha blending to DEST - SRC * DEST */
  33389. static readonly ALPHA_SUBTRACT: number;
  33390. /** Defines that alpha blending to SRC * DEST */
  33391. static readonly ALPHA_MULTIPLY: number;
  33392. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33393. static readonly ALPHA_MAXIMIZED: number;
  33394. /** Defines that alpha blending to SRC + DEST */
  33395. static readonly ALPHA_ONEONE: number;
  33396. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33397. static readonly ALPHA_PREMULTIPLIED: number;
  33398. /**
  33399. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33400. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33401. */
  33402. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33403. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33404. static readonly ALPHA_INTERPOLATE: number;
  33405. /**
  33406. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33407. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33408. */
  33409. static readonly ALPHA_SCREENMODE: number;
  33410. /** Defines that the ressource is not delayed*/
  33411. static readonly DELAYLOADSTATE_NONE: number;
  33412. /** Defines that the ressource was successfully delay loaded */
  33413. static readonly DELAYLOADSTATE_LOADED: number;
  33414. /** Defines that the ressource is currently delay loading */
  33415. static readonly DELAYLOADSTATE_LOADING: number;
  33416. /** Defines that the ressource is delayed and has not started loading */
  33417. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33418. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33419. static readonly NEVER: number;
  33420. /** 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 */
  33421. static readonly ALWAYS: number;
  33422. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33423. static readonly LESS: number;
  33424. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33425. static readonly EQUAL: number;
  33426. /** 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 */
  33427. static readonly LEQUAL: number;
  33428. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33429. static readonly GREATER: number;
  33430. /** 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 */
  33431. static readonly GEQUAL: number;
  33432. /** 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 */
  33433. static readonly NOTEQUAL: number;
  33434. /** Passed to stencilOperation to specify that stencil value must be kept */
  33435. static readonly KEEP: number;
  33436. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33437. static readonly REPLACE: number;
  33438. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33439. static readonly INCR: number;
  33440. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33441. static readonly DECR: number;
  33442. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33443. static readonly INVERT: number;
  33444. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33445. static readonly INCR_WRAP: number;
  33446. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33447. static readonly DECR_WRAP: number;
  33448. /** Texture is not repeating outside of 0..1 UVs */
  33449. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33450. /** Texture is repeating outside of 0..1 UVs */
  33451. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33452. /** Texture is repeating and mirrored */
  33453. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33454. /** ALPHA */
  33455. static readonly TEXTUREFORMAT_ALPHA: number;
  33456. /** LUMINANCE */
  33457. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33458. /** LUMINANCE_ALPHA */
  33459. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33460. /** RGB */
  33461. static readonly TEXTUREFORMAT_RGB: number;
  33462. /** RGBA */
  33463. static readonly TEXTUREFORMAT_RGBA: number;
  33464. /** RED */
  33465. static readonly TEXTUREFORMAT_RED: number;
  33466. /** RED (2nd reference) */
  33467. static readonly TEXTUREFORMAT_R: number;
  33468. /** RG */
  33469. static readonly TEXTUREFORMAT_RG: number;
  33470. /** RED_INTEGER */
  33471. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33472. /** RED_INTEGER (2nd reference) */
  33473. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33474. /** RG_INTEGER */
  33475. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33476. /** RGB_INTEGER */
  33477. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33478. /** RGBA_INTEGER */
  33479. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33480. /** UNSIGNED_BYTE */
  33481. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33482. /** UNSIGNED_BYTE (2nd reference) */
  33483. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33484. /** FLOAT */
  33485. static readonly TEXTURETYPE_FLOAT: number;
  33486. /** HALF_FLOAT */
  33487. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33488. /** BYTE */
  33489. static readonly TEXTURETYPE_BYTE: number;
  33490. /** SHORT */
  33491. static readonly TEXTURETYPE_SHORT: number;
  33492. /** UNSIGNED_SHORT */
  33493. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33494. /** INT */
  33495. static readonly TEXTURETYPE_INT: number;
  33496. /** UNSIGNED_INT */
  33497. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33498. /** UNSIGNED_SHORT_4_4_4_4 */
  33499. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33500. /** UNSIGNED_SHORT_5_5_5_1 */
  33501. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33502. /** UNSIGNED_SHORT_5_6_5 */
  33503. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33504. /** UNSIGNED_INT_2_10_10_10_REV */
  33505. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33506. /** UNSIGNED_INT_24_8 */
  33507. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33508. /** UNSIGNED_INT_10F_11F_11F_REV */
  33509. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33510. /** UNSIGNED_INT_5_9_9_9_REV */
  33511. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33512. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33513. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33514. /** nearest is mag = nearest and min = nearest and mip = linear */
  33515. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33516. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33517. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33518. /** Trilinear is mag = linear and min = linear and mip = linear */
  33519. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33520. /** nearest is mag = nearest and min = nearest and mip = linear */
  33521. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33522. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33523. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33524. /** Trilinear is mag = linear and min = linear and mip = linear */
  33525. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33526. /** mag = nearest and min = nearest and mip = nearest */
  33527. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33528. /** mag = nearest and min = linear and mip = nearest */
  33529. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33530. /** mag = nearest and min = linear and mip = linear */
  33531. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33532. /** mag = nearest and min = linear and mip = none */
  33533. static readonly TEXTURE_NEAREST_LINEAR: number;
  33534. /** mag = nearest and min = nearest and mip = none */
  33535. static readonly TEXTURE_NEAREST_NEAREST: number;
  33536. /** mag = linear and min = nearest and mip = nearest */
  33537. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33538. /** mag = linear and min = nearest and mip = linear */
  33539. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33540. /** mag = linear and min = linear and mip = none */
  33541. static readonly TEXTURE_LINEAR_LINEAR: number;
  33542. /** mag = linear and min = nearest and mip = none */
  33543. static readonly TEXTURE_LINEAR_NEAREST: number;
  33544. /** Explicit coordinates mode */
  33545. static readonly TEXTURE_EXPLICIT_MODE: number;
  33546. /** Spherical coordinates mode */
  33547. static readonly TEXTURE_SPHERICAL_MODE: number;
  33548. /** Planar coordinates mode */
  33549. static readonly TEXTURE_PLANAR_MODE: number;
  33550. /** Cubic coordinates mode */
  33551. static readonly TEXTURE_CUBIC_MODE: number;
  33552. /** Projection coordinates mode */
  33553. static readonly TEXTURE_PROJECTION_MODE: number;
  33554. /** Skybox coordinates mode */
  33555. static readonly TEXTURE_SKYBOX_MODE: number;
  33556. /** Inverse Cubic coordinates mode */
  33557. static readonly TEXTURE_INVCUBIC_MODE: number;
  33558. /** Equirectangular coordinates mode */
  33559. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33560. /** Equirectangular Fixed coordinates mode */
  33561. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33562. /** Equirectangular Fixed Mirrored coordinates mode */
  33563. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33564. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33565. static readonly SCALEMODE_FLOOR: number;
  33566. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33567. static readonly SCALEMODE_NEAREST: number;
  33568. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33569. static readonly SCALEMODE_CEILING: number;
  33570. /**
  33571. * Returns the current npm package of the sdk
  33572. */
  33573. static get NpmPackage(): string;
  33574. /**
  33575. * Returns the current version of the framework
  33576. */
  33577. static get Version(): string;
  33578. /** Gets the list of created engines */
  33579. static get Instances(): Engine[];
  33580. /**
  33581. * Gets the latest created engine
  33582. */
  33583. static get LastCreatedEngine(): Nullable<Engine>;
  33584. /**
  33585. * Gets the latest created scene
  33586. */
  33587. static get LastCreatedScene(): Nullable<Scene>;
  33588. /**
  33589. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33590. * @param flag defines which part of the materials must be marked as dirty
  33591. * @param predicate defines a predicate used to filter which materials should be affected
  33592. */
  33593. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33594. /**
  33595. * Method called to create the default loading screen.
  33596. * This can be overriden in your own app.
  33597. * @param canvas The rendering canvas element
  33598. * @returns The loading screen
  33599. */
  33600. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33601. /**
  33602. * Method called to create the default rescale post process on each engine.
  33603. */
  33604. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33605. /**
  33606. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33607. **/
  33608. enableOfflineSupport: boolean;
  33609. /**
  33610. * 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)
  33611. **/
  33612. disableManifestCheck: boolean;
  33613. /**
  33614. * Gets the list of created scenes
  33615. */
  33616. scenes: Scene[];
  33617. /**
  33618. * Event raised when a new scene is created
  33619. */
  33620. onNewSceneAddedObservable: Observable<Scene>;
  33621. /**
  33622. * Gets the list of created postprocesses
  33623. */
  33624. postProcesses: PostProcess[];
  33625. /**
  33626. * Gets a boolean indicating if the pointer is currently locked
  33627. */
  33628. isPointerLock: boolean;
  33629. /**
  33630. * Observable event triggered each time the rendering canvas is resized
  33631. */
  33632. onResizeObservable: Observable<Engine>;
  33633. /**
  33634. * Observable event triggered each time the canvas loses focus
  33635. */
  33636. onCanvasBlurObservable: Observable<Engine>;
  33637. /**
  33638. * Observable event triggered each time the canvas gains focus
  33639. */
  33640. onCanvasFocusObservable: Observable<Engine>;
  33641. /**
  33642. * Observable event triggered each time the canvas receives pointerout event
  33643. */
  33644. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33645. /**
  33646. * Observable raised when the engine begins a new frame
  33647. */
  33648. onBeginFrameObservable: Observable<Engine>;
  33649. /**
  33650. * If set, will be used to request the next animation frame for the render loop
  33651. */
  33652. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33653. /**
  33654. * Observable raised when the engine ends the current frame
  33655. */
  33656. onEndFrameObservable: Observable<Engine>;
  33657. /**
  33658. * Observable raised when the engine is about to compile a shader
  33659. */
  33660. onBeforeShaderCompilationObservable: Observable<Engine>;
  33661. /**
  33662. * Observable raised when the engine has jsut compiled a shader
  33663. */
  33664. onAfterShaderCompilationObservable: Observable<Engine>;
  33665. /**
  33666. * Gets the audio engine
  33667. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33668. * @ignorenaming
  33669. */
  33670. static audioEngine: IAudioEngine;
  33671. /**
  33672. * Default AudioEngine factory responsible of creating the Audio Engine.
  33673. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33674. */
  33675. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33676. /**
  33677. * Default offline support factory responsible of creating a tool used to store data locally.
  33678. * By default, this will create a Database object if the workload has been embedded.
  33679. */
  33680. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33681. private _loadingScreen;
  33682. private _pointerLockRequested;
  33683. private _dummyFramebuffer;
  33684. private _rescalePostProcess;
  33685. private _deterministicLockstep;
  33686. private _lockstepMaxSteps;
  33687. private _timeStep;
  33688. protected get _supportsHardwareTextureRescaling(): boolean;
  33689. private _fps;
  33690. private _deltaTime;
  33691. /** @hidden */
  33692. _drawCalls: PerfCounter;
  33693. /** 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 */
  33694. canvasTabIndex: number;
  33695. /**
  33696. * Turn this value on if you want to pause FPS computation when in background
  33697. */
  33698. disablePerformanceMonitorInBackground: boolean;
  33699. private _performanceMonitor;
  33700. /**
  33701. * Gets the performance monitor attached to this engine
  33702. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33703. */
  33704. get performanceMonitor(): PerformanceMonitor;
  33705. private _onFocus;
  33706. private _onBlur;
  33707. private _onCanvasPointerOut;
  33708. private _onCanvasBlur;
  33709. private _onCanvasFocus;
  33710. private _onFullscreenChange;
  33711. private _onPointerLockChange;
  33712. /**
  33713. * Gets the HTML element used to attach event listeners
  33714. * @returns a HTML element
  33715. */
  33716. getInputElement(): Nullable<HTMLElement>;
  33717. /**
  33718. * Creates a new engine
  33719. * @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
  33720. * @param antialias defines enable antialiasing (default: false)
  33721. * @param options defines further options to be sent to the getContext() function
  33722. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33723. */
  33724. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33725. /**
  33726. * Gets current aspect ratio
  33727. * @param viewportOwner defines the camera to use to get the aspect ratio
  33728. * @param useScreen defines if screen size must be used (or the current render target if any)
  33729. * @returns a number defining the aspect ratio
  33730. */
  33731. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33732. /**
  33733. * Gets current screen aspect ratio
  33734. * @returns a number defining the aspect ratio
  33735. */
  33736. getScreenAspectRatio(): number;
  33737. /**
  33738. * Gets the client rect of the HTML canvas attached with the current webGL context
  33739. * @returns a client rectanglee
  33740. */
  33741. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33742. /**
  33743. * Gets the client rect of the HTML element used for events
  33744. * @returns a client rectanglee
  33745. */
  33746. getInputElementClientRect(): Nullable<ClientRect>;
  33747. /**
  33748. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33749. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33750. * @returns true if engine is in deterministic lock step mode
  33751. */
  33752. isDeterministicLockStep(): boolean;
  33753. /**
  33754. * Gets the max steps when engine is running in deterministic lock step
  33755. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33756. * @returns the max steps
  33757. */
  33758. getLockstepMaxSteps(): number;
  33759. /**
  33760. * Returns the time in ms between steps when using deterministic lock step.
  33761. * @returns time step in (ms)
  33762. */
  33763. getTimeStep(): number;
  33764. /**
  33765. * Force the mipmap generation for the given render target texture
  33766. * @param texture defines the render target texture to use
  33767. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33768. */
  33769. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33770. /** States */
  33771. /**
  33772. * Set various states to the webGL context
  33773. * @param culling defines backface culling state
  33774. * @param zOffset defines the value to apply to zOffset (0 by default)
  33775. * @param force defines if states must be applied even if cache is up to date
  33776. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33777. */
  33778. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33779. /**
  33780. * Set the z offset to apply to current rendering
  33781. * @param value defines the offset to apply
  33782. */
  33783. setZOffset(value: number): void;
  33784. /**
  33785. * Gets the current value of the zOffset
  33786. * @returns the current zOffset state
  33787. */
  33788. getZOffset(): number;
  33789. /**
  33790. * Enable or disable depth buffering
  33791. * @param enable defines the state to set
  33792. */
  33793. setDepthBuffer(enable: boolean): void;
  33794. /**
  33795. * Gets a boolean indicating if depth writing is enabled
  33796. * @returns the current depth writing state
  33797. */
  33798. getDepthWrite(): boolean;
  33799. /**
  33800. * Enable or disable depth writing
  33801. * @param enable defines the state to set
  33802. */
  33803. setDepthWrite(enable: boolean): void;
  33804. /**
  33805. * Gets a boolean indicating if stencil buffer is enabled
  33806. * @returns the current stencil buffer state
  33807. */
  33808. getStencilBuffer(): boolean;
  33809. /**
  33810. * Enable or disable the stencil buffer
  33811. * @param enable defines if the stencil buffer must be enabled or disabled
  33812. */
  33813. setStencilBuffer(enable: boolean): void;
  33814. /**
  33815. * Gets the current stencil mask
  33816. * @returns a number defining the new stencil mask to use
  33817. */
  33818. getStencilMask(): number;
  33819. /**
  33820. * Sets the current stencil mask
  33821. * @param mask defines the new stencil mask to use
  33822. */
  33823. setStencilMask(mask: number): void;
  33824. /**
  33825. * Gets the current stencil function
  33826. * @returns a number defining the stencil function to use
  33827. */
  33828. getStencilFunction(): number;
  33829. /**
  33830. * Gets the current stencil reference value
  33831. * @returns a number defining the stencil reference value to use
  33832. */
  33833. getStencilFunctionReference(): number;
  33834. /**
  33835. * Gets the current stencil mask
  33836. * @returns a number defining the stencil mask to use
  33837. */
  33838. getStencilFunctionMask(): number;
  33839. /**
  33840. * Sets the current stencil function
  33841. * @param stencilFunc defines the new stencil function to use
  33842. */
  33843. setStencilFunction(stencilFunc: number): void;
  33844. /**
  33845. * Sets the current stencil reference
  33846. * @param reference defines the new stencil reference to use
  33847. */
  33848. setStencilFunctionReference(reference: number): void;
  33849. /**
  33850. * Sets the current stencil mask
  33851. * @param mask defines the new stencil mask to use
  33852. */
  33853. setStencilFunctionMask(mask: number): void;
  33854. /**
  33855. * Gets the current stencil operation when stencil fails
  33856. * @returns a number defining stencil operation to use when stencil fails
  33857. */
  33858. getStencilOperationFail(): number;
  33859. /**
  33860. * Gets the current stencil operation when depth fails
  33861. * @returns a number defining stencil operation to use when depth fails
  33862. */
  33863. getStencilOperationDepthFail(): number;
  33864. /**
  33865. * Gets the current stencil operation when stencil passes
  33866. * @returns a number defining stencil operation to use when stencil passes
  33867. */
  33868. getStencilOperationPass(): number;
  33869. /**
  33870. * Sets the stencil operation to use when stencil fails
  33871. * @param operation defines the stencil operation to use when stencil fails
  33872. */
  33873. setStencilOperationFail(operation: number): void;
  33874. /**
  33875. * Sets the stencil operation to use when depth fails
  33876. * @param operation defines the stencil operation to use when depth fails
  33877. */
  33878. setStencilOperationDepthFail(operation: number): void;
  33879. /**
  33880. * Sets the stencil operation to use when stencil passes
  33881. * @param operation defines the stencil operation to use when stencil passes
  33882. */
  33883. setStencilOperationPass(operation: number): void;
  33884. /**
  33885. * Sets a boolean indicating if the dithering state is enabled or disabled
  33886. * @param value defines the dithering state
  33887. */
  33888. setDitheringState(value: boolean): void;
  33889. /**
  33890. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33891. * @param value defines the rasterizer state
  33892. */
  33893. setRasterizerState(value: boolean): void;
  33894. /**
  33895. * Gets the current depth function
  33896. * @returns a number defining the depth function
  33897. */
  33898. getDepthFunction(): Nullable<number>;
  33899. /**
  33900. * Sets the current depth function
  33901. * @param depthFunc defines the function to use
  33902. */
  33903. setDepthFunction(depthFunc: number): void;
  33904. /**
  33905. * Sets the current depth function to GREATER
  33906. */
  33907. setDepthFunctionToGreater(): void;
  33908. /**
  33909. * Sets the current depth function to GEQUAL
  33910. */
  33911. setDepthFunctionToGreaterOrEqual(): void;
  33912. /**
  33913. * Sets the current depth function to LESS
  33914. */
  33915. setDepthFunctionToLess(): void;
  33916. /**
  33917. * Sets the current depth function to LEQUAL
  33918. */
  33919. setDepthFunctionToLessOrEqual(): void;
  33920. private _cachedStencilBuffer;
  33921. private _cachedStencilFunction;
  33922. private _cachedStencilMask;
  33923. private _cachedStencilOperationPass;
  33924. private _cachedStencilOperationFail;
  33925. private _cachedStencilOperationDepthFail;
  33926. private _cachedStencilReference;
  33927. /**
  33928. * Caches the the state of the stencil buffer
  33929. */
  33930. cacheStencilState(): void;
  33931. /**
  33932. * Restores the state of the stencil buffer
  33933. */
  33934. restoreStencilState(): void;
  33935. /**
  33936. * Directly set the WebGL Viewport
  33937. * @param x defines the x coordinate of the viewport (in screen space)
  33938. * @param y defines the y coordinate of the viewport (in screen space)
  33939. * @param width defines the width of the viewport (in screen space)
  33940. * @param height defines the height of the viewport (in screen space)
  33941. * @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
  33942. */
  33943. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33944. /**
  33945. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33946. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33947. * @param y defines the y-coordinate of the corner of the clear rectangle
  33948. * @param width defines the width of the clear rectangle
  33949. * @param height defines the height of the clear rectangle
  33950. * @param clearColor defines the clear color
  33951. */
  33952. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33953. /**
  33954. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33955. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33956. * @param y defines the y-coordinate of the corner of the clear rectangle
  33957. * @param width defines the width of the clear rectangle
  33958. * @param height defines the height of the clear rectangle
  33959. */
  33960. enableScissor(x: number, y: number, width: number, height: number): void;
  33961. /**
  33962. * Disable previously set scissor test rectangle
  33963. */
  33964. disableScissor(): void;
  33965. protected _reportDrawCall(): void;
  33966. /**
  33967. * Initializes a webVR display and starts listening to display change events
  33968. * The onVRDisplayChangedObservable will be notified upon these changes
  33969. * @returns The onVRDisplayChangedObservable
  33970. */
  33971. initWebVR(): Observable<IDisplayChangedEventArgs>;
  33972. /** @hidden */
  33973. _prepareVRComponent(): void;
  33974. /** @hidden */
  33975. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  33976. /** @hidden */
  33977. _submitVRFrame(): void;
  33978. /**
  33979. * Call this function to leave webVR mode
  33980. * Will do nothing if webVR is not supported or if there is no webVR device
  33981. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33982. */
  33983. disableVR(): void;
  33984. /**
  33985. * Gets a boolean indicating that the system is in VR mode and is presenting
  33986. * @returns true if VR mode is engaged
  33987. */
  33988. isVRPresenting(): boolean;
  33989. /** @hidden */
  33990. _requestVRFrame(): void;
  33991. /** @hidden */
  33992. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33993. /**
  33994. * Gets the source code of the vertex shader associated with a specific webGL program
  33995. * @param program defines the program to use
  33996. * @returns a string containing the source code of the vertex shader associated with the program
  33997. */
  33998. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  33999. /**
  34000. * Gets the source code of the fragment shader associated with a specific webGL program
  34001. * @param program defines the program to use
  34002. * @returns a string containing the source code of the fragment shader associated with the program
  34003. */
  34004. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34005. /**
  34006. * Sets a depth stencil texture from a render target to the according uniform.
  34007. * @param channel The texture channel
  34008. * @param uniform The uniform to set
  34009. * @param texture The render target texture containing the depth stencil texture to apply
  34010. */
  34011. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34012. /**
  34013. * Sets a texture to the webGL context from a postprocess
  34014. * @param channel defines the channel to use
  34015. * @param postProcess defines the source postprocess
  34016. */
  34017. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34018. /**
  34019. * Binds the output of the passed in post process to the texture channel specified
  34020. * @param channel The channel the texture should be bound to
  34021. * @param postProcess The post process which's output should be bound
  34022. */
  34023. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34024. /** @hidden */
  34025. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34026. protected _rebuildBuffers(): void;
  34027. /** @hidden */
  34028. _renderFrame(): void;
  34029. _renderLoop(): void;
  34030. /** @hidden */
  34031. _renderViews(): boolean;
  34032. /**
  34033. * Toggle full screen mode
  34034. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34035. */
  34036. switchFullscreen(requestPointerLock: boolean): void;
  34037. /**
  34038. * Enters full screen mode
  34039. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34040. */
  34041. enterFullscreen(requestPointerLock: boolean): void;
  34042. /**
  34043. * Exits full screen mode
  34044. */
  34045. exitFullscreen(): void;
  34046. /**
  34047. * Enters Pointerlock mode
  34048. */
  34049. enterPointerlock(): void;
  34050. /**
  34051. * Exits Pointerlock mode
  34052. */
  34053. exitPointerlock(): void;
  34054. /**
  34055. * Begin a new frame
  34056. */
  34057. beginFrame(): void;
  34058. /**
  34059. * Enf the current frame
  34060. */
  34061. endFrame(): void;
  34062. resize(): void;
  34063. /**
  34064. * Force a specific size of the canvas
  34065. * @param width defines the new canvas' width
  34066. * @param height defines the new canvas' height
  34067. */
  34068. setSize(width: number, height: number): void;
  34069. /**
  34070. * Updates a dynamic vertex buffer.
  34071. * @param vertexBuffer the vertex buffer to update
  34072. * @param data the data used to update the vertex buffer
  34073. * @param byteOffset the byte offset of the data
  34074. * @param byteLength the byte length of the data
  34075. */
  34076. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34077. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34078. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34079. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34080. _releaseTexture(texture: InternalTexture): void;
  34081. /**
  34082. * @hidden
  34083. * Rescales a texture
  34084. * @param source input texutre
  34085. * @param destination destination texture
  34086. * @param scene scene to use to render the resize
  34087. * @param internalFormat format to use when resizing
  34088. * @param onComplete callback to be called when resize has completed
  34089. */
  34090. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34091. /**
  34092. * Gets the current framerate
  34093. * @returns a number representing the framerate
  34094. */
  34095. getFps(): number;
  34096. /**
  34097. * Gets the time spent between current and previous frame
  34098. * @returns a number representing the delta time in ms
  34099. */
  34100. getDeltaTime(): number;
  34101. private _measureFps;
  34102. /** @hidden */
  34103. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34104. /**
  34105. * Update a dynamic index buffer
  34106. * @param indexBuffer defines the target index buffer
  34107. * @param indices defines the data to update
  34108. * @param offset defines the offset in the target index buffer where update should start
  34109. */
  34110. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34111. /**
  34112. * Updates the sample count of a render target texture
  34113. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34114. * @param texture defines the texture to update
  34115. * @param samples defines the sample count to set
  34116. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34117. */
  34118. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34119. /**
  34120. * Updates a depth texture Comparison Mode and Function.
  34121. * If the comparison Function is equal to 0, the mode will be set to none.
  34122. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34123. * @param texture The texture to set the comparison function for
  34124. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34125. */
  34126. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34127. /**
  34128. * Creates a webGL buffer to use with instanciation
  34129. * @param capacity defines the size of the buffer
  34130. * @returns the webGL buffer
  34131. */
  34132. createInstancesBuffer(capacity: number): DataBuffer;
  34133. /**
  34134. * Delete a webGL buffer used with instanciation
  34135. * @param buffer defines the webGL buffer to delete
  34136. */
  34137. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34138. private _clientWaitAsync;
  34139. /** @hidden */
  34140. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  34141. /** @hidden */
  34142. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34143. dispose(): void;
  34144. private _disableTouchAction;
  34145. /**
  34146. * Display the loading screen
  34147. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34148. */
  34149. displayLoadingUI(): void;
  34150. /**
  34151. * Hide the loading screen
  34152. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34153. */
  34154. hideLoadingUI(): void;
  34155. /**
  34156. * Gets the current loading screen object
  34157. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34158. */
  34159. get loadingScreen(): ILoadingScreen;
  34160. /**
  34161. * Sets the current loading screen object
  34162. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34163. */
  34164. set loadingScreen(loadingScreen: ILoadingScreen);
  34165. /**
  34166. * Sets the current loading screen text
  34167. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34168. */
  34169. set loadingUIText(text: string);
  34170. /**
  34171. * Sets the current loading screen background color
  34172. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34173. */
  34174. set loadingUIBackgroundColor(color: string);
  34175. /** Pointerlock and fullscreen */
  34176. /**
  34177. * Ask the browser to promote the current element to pointerlock mode
  34178. * @param element defines the DOM element to promote
  34179. */
  34180. static _RequestPointerlock(element: HTMLElement): void;
  34181. /**
  34182. * Asks the browser to exit pointerlock mode
  34183. */
  34184. static _ExitPointerlock(): void;
  34185. /**
  34186. * Ask the browser to promote the current element to fullscreen rendering mode
  34187. * @param element defines the DOM element to promote
  34188. */
  34189. static _RequestFullscreen(element: HTMLElement): void;
  34190. /**
  34191. * Asks the browser to exit fullscreen mode
  34192. */
  34193. static _ExitFullscreen(): void;
  34194. }
  34195. }
  34196. declare module BABYLON {
  34197. /**
  34198. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34199. * during the life time of the application.
  34200. */
  34201. export class EngineStore {
  34202. /** Gets the list of created engines */
  34203. static Instances: Engine[];
  34204. /** @hidden */
  34205. static _LastCreatedScene: Nullable<Scene>;
  34206. /**
  34207. * Gets the latest created engine
  34208. */
  34209. static get LastCreatedEngine(): Nullable<Engine>;
  34210. /**
  34211. * Gets the latest created scene
  34212. */
  34213. static get LastCreatedScene(): Nullable<Scene>;
  34214. /**
  34215. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34216. * @ignorenaming
  34217. */
  34218. static UseFallbackTexture: boolean;
  34219. /**
  34220. * Texture content used if a texture cannot loaded
  34221. * @ignorenaming
  34222. */
  34223. static FallbackTexture: string;
  34224. }
  34225. }
  34226. declare module BABYLON {
  34227. /**
  34228. * Helper class that provides a small promise polyfill
  34229. */
  34230. export class PromisePolyfill {
  34231. /**
  34232. * Static function used to check if the polyfill is required
  34233. * If this is the case then the function will inject the polyfill to window.Promise
  34234. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34235. */
  34236. static Apply(force?: boolean): void;
  34237. }
  34238. }
  34239. declare module BABYLON {
  34240. /**
  34241. * Interface for screenshot methods with describe argument called `size` as object with options
  34242. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34243. */
  34244. export interface IScreenshotSize {
  34245. /**
  34246. * number in pixels for canvas height
  34247. */
  34248. height?: number;
  34249. /**
  34250. * multiplier allowing render at a higher or lower resolution
  34251. * If value is defined then height and width will be ignored and taken from camera
  34252. */
  34253. precision?: number;
  34254. /**
  34255. * number in pixels for canvas width
  34256. */
  34257. width?: number;
  34258. }
  34259. }
  34260. declare module BABYLON {
  34261. interface IColor4Like {
  34262. r: float;
  34263. g: float;
  34264. b: float;
  34265. a: float;
  34266. }
  34267. /**
  34268. * Class containing a set of static utilities functions
  34269. */
  34270. export class Tools {
  34271. /**
  34272. * Gets or sets the base URL to use to load assets
  34273. */
  34274. static get BaseUrl(): string;
  34275. static set BaseUrl(value: string);
  34276. /**
  34277. * Enable/Disable Custom HTTP Request Headers globally.
  34278. * default = false
  34279. * @see CustomRequestHeaders
  34280. */
  34281. static UseCustomRequestHeaders: boolean;
  34282. /**
  34283. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34284. * i.e. when loading files, where the server/service expects an Authorization header
  34285. */
  34286. static CustomRequestHeaders: {
  34287. [key: string]: string;
  34288. };
  34289. /**
  34290. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34291. */
  34292. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34293. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34294. /**
  34295. * Default behaviour for cors in the application.
  34296. * It can be a string if the expected behavior is identical in the entire app.
  34297. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34298. */
  34299. static get CorsBehavior(): string | ((url: string | string[]) => string);
  34300. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  34301. /**
  34302. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34303. * @ignorenaming
  34304. */
  34305. static get UseFallbackTexture(): boolean;
  34306. static set UseFallbackTexture(value: boolean);
  34307. /**
  34308. * Use this object to register external classes like custom textures or material
  34309. * to allow the laoders to instantiate them
  34310. */
  34311. static get RegisteredExternalClasses(): {
  34312. [key: string]: Object;
  34313. };
  34314. static set RegisteredExternalClasses(classes: {
  34315. [key: string]: Object;
  34316. });
  34317. /**
  34318. * Texture content used if a texture cannot loaded
  34319. * @ignorenaming
  34320. */
  34321. static get fallbackTexture(): string;
  34322. static set fallbackTexture(value: string);
  34323. /**
  34324. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34325. * @param u defines the coordinate on X axis
  34326. * @param v defines the coordinate on Y axis
  34327. * @param width defines the width of the source data
  34328. * @param height defines the height of the source data
  34329. * @param pixels defines the source byte array
  34330. * @param color defines the output color
  34331. */
  34332. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34333. /**
  34334. * Interpolates between a and b via alpha
  34335. * @param a The lower value (returned when alpha = 0)
  34336. * @param b The upper value (returned when alpha = 1)
  34337. * @param alpha The interpolation-factor
  34338. * @return The mixed value
  34339. */
  34340. static Mix(a: number, b: number, alpha: number): number;
  34341. /**
  34342. * Tries to instantiate a new object from a given class name
  34343. * @param className defines the class name to instantiate
  34344. * @returns the new object or null if the system was not able to do the instantiation
  34345. */
  34346. static Instantiate(className: string): any;
  34347. /**
  34348. * Provides a slice function that will work even on IE
  34349. * @param data defines the array to slice
  34350. * @param start defines the start of the data (optional)
  34351. * @param end defines the end of the data (optional)
  34352. * @returns the new sliced array
  34353. */
  34354. static Slice<T>(data: T, start?: number, end?: number): T;
  34355. /**
  34356. * Polyfill for setImmediate
  34357. * @param action defines the action to execute after the current execution block
  34358. */
  34359. static SetImmediate(action: () => void): void;
  34360. /**
  34361. * Function indicating if a number is an exponent of 2
  34362. * @param value defines the value to test
  34363. * @returns true if the value is an exponent of 2
  34364. */
  34365. static IsExponentOfTwo(value: number): boolean;
  34366. private static _tmpFloatArray;
  34367. /**
  34368. * Returns the nearest 32-bit single precision float representation of a Number
  34369. * @param value A Number. If the parameter is of a different type, it will get converted
  34370. * to a number or to NaN if it cannot be converted
  34371. * @returns number
  34372. */
  34373. static FloatRound(value: number): number;
  34374. /**
  34375. * Extracts the filename from a path
  34376. * @param path defines the path to use
  34377. * @returns the filename
  34378. */
  34379. static GetFilename(path: string): string;
  34380. /**
  34381. * Extracts the "folder" part of a path (everything before the filename).
  34382. * @param uri The URI to extract the info from
  34383. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34384. * @returns The "folder" part of the path
  34385. */
  34386. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34387. /**
  34388. * Extracts text content from a DOM element hierarchy
  34389. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34390. */
  34391. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34392. /**
  34393. * Convert an angle in radians to degrees
  34394. * @param angle defines the angle to convert
  34395. * @returns the angle in degrees
  34396. */
  34397. static ToDegrees(angle: number): number;
  34398. /**
  34399. * Convert an angle in degrees to radians
  34400. * @param angle defines the angle to convert
  34401. * @returns the angle in radians
  34402. */
  34403. static ToRadians(angle: number): number;
  34404. /**
  34405. * Returns an array if obj is not an array
  34406. * @param obj defines the object to evaluate as an array
  34407. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34408. * @returns either obj directly if obj is an array or a new array containing obj
  34409. */
  34410. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34411. /**
  34412. * Gets the pointer prefix to use
  34413. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34414. */
  34415. static GetPointerPrefix(): string;
  34416. /**
  34417. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34418. * @param url define the url we are trying
  34419. * @param element define the dom element where to configure the cors policy
  34420. */
  34421. static SetCorsBehavior(url: string | string[], element: {
  34422. crossOrigin: string | null;
  34423. }): void;
  34424. /**
  34425. * Removes unwanted characters from an url
  34426. * @param url defines the url to clean
  34427. * @returns the cleaned url
  34428. */
  34429. static CleanUrl(url: string): string;
  34430. /**
  34431. * Gets or sets a function used to pre-process url before using them to load assets
  34432. */
  34433. static get PreprocessUrl(): (url: string) => string;
  34434. static set PreprocessUrl(processor: (url: string) => string);
  34435. /**
  34436. * Loads an image as an HTMLImageElement.
  34437. * @param input url string, ArrayBuffer, or Blob to load
  34438. * @param onLoad callback called when the image successfully loads
  34439. * @param onError callback called when the image fails to load
  34440. * @param offlineProvider offline provider for caching
  34441. * @param mimeType optional mime type
  34442. * @returns the HTMLImageElement of the loaded image
  34443. */
  34444. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34445. /**
  34446. * Loads a file from a url
  34447. * @param url url string, ArrayBuffer, or Blob to load
  34448. * @param onSuccess callback called when the file successfully loads
  34449. * @param onProgress callback called while file is loading (if the server supports this mode)
  34450. * @param offlineProvider defines the offline provider for caching
  34451. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34452. * @param onError callback called when the file fails to load
  34453. * @returns a file request object
  34454. */
  34455. 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;
  34456. /**
  34457. * Loads a file from a url
  34458. * @param url the file url to load
  34459. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34460. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  34461. */
  34462. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  34463. /**
  34464. * Load a script (identified by an url). When the url returns, the
  34465. * content of this file is added into a new script element, attached to the DOM (body element)
  34466. * @param scriptUrl defines the url of the script to laod
  34467. * @param onSuccess defines the callback called when the script is loaded
  34468. * @param onError defines the callback to call if an error occurs
  34469. * @param scriptId defines the id of the script element
  34470. */
  34471. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34472. /**
  34473. * Load an asynchronous script (identified by an url). When the url returns, the
  34474. * content of this file is added into a new script element, attached to the DOM (body element)
  34475. * @param scriptUrl defines the url of the script to laod
  34476. * @param scriptId defines the id of the script element
  34477. * @returns a promise request object
  34478. */
  34479. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34480. /**
  34481. * Loads a file from a blob
  34482. * @param fileToLoad defines the blob to use
  34483. * @param callback defines the callback to call when data is loaded
  34484. * @param progressCallback defines the callback to call during loading process
  34485. * @returns a file request object
  34486. */
  34487. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34488. /**
  34489. * Reads a file from a File object
  34490. * @param file defines the file to load
  34491. * @param onSuccess defines the callback to call when data is loaded
  34492. * @param onProgress defines the callback to call during loading process
  34493. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34494. * @param onError defines the callback to call when an error occurs
  34495. * @returns a file request object
  34496. */
  34497. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34498. /**
  34499. * Creates a data url from a given string content
  34500. * @param content defines the content to convert
  34501. * @returns the new data url link
  34502. */
  34503. static FileAsURL(content: string): string;
  34504. /**
  34505. * Format the given number to a specific decimal format
  34506. * @param value defines the number to format
  34507. * @param decimals defines the number of decimals to use
  34508. * @returns the formatted string
  34509. */
  34510. static Format(value: number, decimals?: number): string;
  34511. /**
  34512. * Tries to copy an object by duplicating every property
  34513. * @param source defines the source object
  34514. * @param destination defines the target object
  34515. * @param doNotCopyList defines a list of properties to avoid
  34516. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34517. */
  34518. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34519. /**
  34520. * Gets a boolean indicating if the given object has no own property
  34521. * @param obj defines the object to test
  34522. * @returns true if object has no own property
  34523. */
  34524. static IsEmpty(obj: any): boolean;
  34525. /**
  34526. * Function used to register events at window level
  34527. * @param windowElement defines the Window object to use
  34528. * @param events defines the events to register
  34529. */
  34530. static RegisterTopRootEvents(windowElement: Window, events: {
  34531. name: string;
  34532. handler: Nullable<(e: FocusEvent) => any>;
  34533. }[]): void;
  34534. /**
  34535. * Function used to unregister events from window level
  34536. * @param windowElement defines the Window object to use
  34537. * @param events defines the events to unregister
  34538. */
  34539. static UnregisterTopRootEvents(windowElement: Window, events: {
  34540. name: string;
  34541. handler: Nullable<(e: FocusEvent) => any>;
  34542. }[]): void;
  34543. /**
  34544. * @ignore
  34545. */
  34546. static _ScreenshotCanvas: HTMLCanvasElement;
  34547. /**
  34548. * Dumps the current bound framebuffer
  34549. * @param width defines the rendering width
  34550. * @param height defines the rendering height
  34551. * @param engine defines the hosting engine
  34552. * @param successCallback defines the callback triggered once the data are available
  34553. * @param mimeType defines the mime type of the result
  34554. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34555. */
  34556. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34557. /**
  34558. * Converts the canvas data to blob.
  34559. * This acts as a polyfill for browsers not supporting the to blob function.
  34560. * @param canvas Defines the canvas to extract the data from
  34561. * @param successCallback Defines the callback triggered once the data are available
  34562. * @param mimeType Defines the mime type of the result
  34563. */
  34564. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34565. /**
  34566. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34567. * @param successCallback defines the callback triggered once the data are available
  34568. * @param mimeType defines the mime type of the result
  34569. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34570. */
  34571. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34572. /**
  34573. * Downloads a blob in the browser
  34574. * @param blob defines the blob to download
  34575. * @param fileName defines the name of the downloaded file
  34576. */
  34577. static Download(blob: Blob, fileName: string): void;
  34578. /**
  34579. * Captures a screenshot of the current rendering
  34580. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34581. * @param engine defines the rendering engine
  34582. * @param camera defines the source camera
  34583. * @param size This parameter can be set to a single number or to an object with the
  34584. * following (optional) properties: precision, width, height. If a single number is passed,
  34585. * it will be used for both width and height. If an object is passed, the screenshot size
  34586. * will be derived from the parameters. The precision property is a multiplier allowing
  34587. * rendering at a higher or lower resolution
  34588. * @param successCallback defines the callback receives a single parameter which contains the
  34589. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34590. * src parameter of an <img> to display it
  34591. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34592. * Check your browser for supported MIME types
  34593. */
  34594. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34595. /**
  34596. * Captures a screenshot of the current rendering
  34597. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34598. * @param engine defines the rendering engine
  34599. * @param camera defines the source camera
  34600. * @param size This parameter can be set to a single number or to an object with the
  34601. * following (optional) properties: precision, width, height. If a single number is passed,
  34602. * it will be used for both width and height. If an object is passed, the screenshot size
  34603. * will be derived from the parameters. The precision property is a multiplier allowing
  34604. * rendering at a higher or lower resolution
  34605. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34606. * Check your browser for supported MIME types
  34607. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34608. * to the src parameter of an <img> to display it
  34609. */
  34610. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34611. /**
  34612. * Generates an image screenshot from the specified camera.
  34613. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34614. * @param engine The engine to use for rendering
  34615. * @param camera The camera to use for rendering
  34616. * @param size This parameter can be set to a single number or to an object with the
  34617. * following (optional) properties: precision, width, height. If a single number is passed,
  34618. * it will be used for both width and height. If an object is passed, the screenshot size
  34619. * will be derived from the parameters. The precision property is a multiplier allowing
  34620. * rendering at a higher or lower resolution
  34621. * @param successCallback The callback receives a single parameter which contains the
  34622. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34623. * src parameter of an <img> to display it
  34624. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34625. * Check your browser for supported MIME types
  34626. * @param samples Texture samples (default: 1)
  34627. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34628. * @param fileName A name for for the downloaded file.
  34629. */
  34630. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34631. /**
  34632. * Generates an image screenshot from the specified camera.
  34633. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34634. * @param engine The engine to use for rendering
  34635. * @param camera The camera to use for rendering
  34636. * @param size This parameter can be set to a single number or to an object with the
  34637. * following (optional) properties: precision, width, height. If a single number is passed,
  34638. * it will be used for both width and height. If an object is passed, the screenshot size
  34639. * will be derived from the parameters. The precision property is a multiplier allowing
  34640. * rendering at a higher or lower resolution
  34641. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34642. * Check your browser for supported MIME types
  34643. * @param samples Texture samples (default: 1)
  34644. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34645. * @param fileName A name for for the downloaded file.
  34646. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34647. * to the src parameter of an <img> to display it
  34648. */
  34649. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34650. /**
  34651. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34652. * Be aware Math.random() could cause collisions, but:
  34653. * "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"
  34654. * @returns a pseudo random id
  34655. */
  34656. static RandomId(): string;
  34657. /**
  34658. * Test if the given uri is a base64 string
  34659. * @param uri The uri to test
  34660. * @return True if the uri is a base64 string or false otherwise
  34661. */
  34662. static IsBase64(uri: string): boolean;
  34663. /**
  34664. * Decode the given base64 uri.
  34665. * @param uri The uri to decode
  34666. * @return The decoded base64 data.
  34667. */
  34668. static DecodeBase64(uri: string): ArrayBuffer;
  34669. /**
  34670. * Gets the absolute url.
  34671. * @param url the input url
  34672. * @return the absolute url
  34673. */
  34674. static GetAbsoluteUrl(url: string): string;
  34675. /**
  34676. * No log
  34677. */
  34678. static readonly NoneLogLevel: number;
  34679. /**
  34680. * Only message logs
  34681. */
  34682. static readonly MessageLogLevel: number;
  34683. /**
  34684. * Only warning logs
  34685. */
  34686. static readonly WarningLogLevel: number;
  34687. /**
  34688. * Only error logs
  34689. */
  34690. static readonly ErrorLogLevel: number;
  34691. /**
  34692. * All logs
  34693. */
  34694. static readonly AllLogLevel: number;
  34695. /**
  34696. * Gets a value indicating the number of loading errors
  34697. * @ignorenaming
  34698. */
  34699. static get errorsCount(): number;
  34700. /**
  34701. * Callback called when a new log is added
  34702. */
  34703. static OnNewCacheEntry: (entry: string) => void;
  34704. /**
  34705. * Log a message to the console
  34706. * @param message defines the message to log
  34707. */
  34708. static Log(message: string): void;
  34709. /**
  34710. * Write a warning message to the console
  34711. * @param message defines the message to log
  34712. */
  34713. static Warn(message: string): void;
  34714. /**
  34715. * Write an error message to the console
  34716. * @param message defines the message to log
  34717. */
  34718. static Error(message: string): void;
  34719. /**
  34720. * Gets current log cache (list of logs)
  34721. */
  34722. static get LogCache(): string;
  34723. /**
  34724. * Clears the log cache
  34725. */
  34726. static ClearLogCache(): void;
  34727. /**
  34728. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34729. */
  34730. static set LogLevels(level: number);
  34731. /**
  34732. * Checks if the window object exists
  34733. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34734. */
  34735. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34736. /**
  34737. * No performance log
  34738. */
  34739. static readonly PerformanceNoneLogLevel: number;
  34740. /**
  34741. * Use user marks to log performance
  34742. */
  34743. static readonly PerformanceUserMarkLogLevel: number;
  34744. /**
  34745. * Log performance to the console
  34746. */
  34747. static readonly PerformanceConsoleLogLevel: number;
  34748. private static _performance;
  34749. /**
  34750. * Sets the current performance log level
  34751. */
  34752. static set PerformanceLogLevel(level: number);
  34753. private static _StartPerformanceCounterDisabled;
  34754. private static _EndPerformanceCounterDisabled;
  34755. private static _StartUserMark;
  34756. private static _EndUserMark;
  34757. private static _StartPerformanceConsole;
  34758. private static _EndPerformanceConsole;
  34759. /**
  34760. * Starts a performance counter
  34761. */
  34762. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34763. /**
  34764. * Ends a specific performance coutner
  34765. */
  34766. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34767. /**
  34768. * Gets either window.performance.now() if supported or Date.now() else
  34769. */
  34770. static get Now(): number;
  34771. /**
  34772. * This method will return the name of the class used to create the instance of the given object.
  34773. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34774. * @param object the object to get the class name from
  34775. * @param isType defines if the object is actually a type
  34776. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34777. */
  34778. static GetClassName(object: any, isType?: boolean): string;
  34779. /**
  34780. * Gets the first element of an array satisfying a given predicate
  34781. * @param array defines the array to browse
  34782. * @param predicate defines the predicate to use
  34783. * @returns null if not found or the element
  34784. */
  34785. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34786. /**
  34787. * This method will return the name of the full name of the class, including its owning module (if any).
  34788. * 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).
  34789. * @param object the object to get the class name from
  34790. * @param isType defines if the object is actually a type
  34791. * @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.
  34792. * @ignorenaming
  34793. */
  34794. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34795. /**
  34796. * Returns a promise that resolves after the given amount of time.
  34797. * @param delay Number of milliseconds to delay
  34798. * @returns Promise that resolves after the given amount of time
  34799. */
  34800. static DelayAsync(delay: number): Promise<void>;
  34801. /**
  34802. * Utility function to detect if the current user agent is Safari
  34803. * @returns whether or not the current user agent is safari
  34804. */
  34805. static IsSafari(): boolean;
  34806. }
  34807. /**
  34808. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34809. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34810. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34811. * @param name The name of the class, case should be preserved
  34812. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34813. */
  34814. export function className(name: string, module?: string): (target: Object) => void;
  34815. /**
  34816. * An implementation of a loop for asynchronous functions.
  34817. */
  34818. export class AsyncLoop {
  34819. /**
  34820. * Defines the number of iterations for the loop
  34821. */
  34822. iterations: number;
  34823. /**
  34824. * Defines the current index of the loop.
  34825. */
  34826. index: number;
  34827. private _done;
  34828. private _fn;
  34829. private _successCallback;
  34830. /**
  34831. * Constructor.
  34832. * @param iterations the number of iterations.
  34833. * @param func the function to run each iteration
  34834. * @param successCallback the callback that will be called upon succesful execution
  34835. * @param offset starting offset.
  34836. */
  34837. constructor(
  34838. /**
  34839. * Defines the number of iterations for the loop
  34840. */
  34841. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34842. /**
  34843. * Execute the next iteration. Must be called after the last iteration was finished.
  34844. */
  34845. executeNext(): void;
  34846. /**
  34847. * Break the loop and run the success callback.
  34848. */
  34849. breakLoop(): void;
  34850. /**
  34851. * Create and run an async loop.
  34852. * @param iterations the number of iterations.
  34853. * @param fn the function to run each iteration
  34854. * @param successCallback the callback that will be called upon succesful execution
  34855. * @param offset starting offset.
  34856. * @returns the created async loop object
  34857. */
  34858. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34859. /**
  34860. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34861. * @param iterations total number of iterations
  34862. * @param syncedIterations number of synchronous iterations in each async iteration.
  34863. * @param fn the function to call each iteration.
  34864. * @param callback a success call back that will be called when iterating stops.
  34865. * @param breakFunction a break condition (optional)
  34866. * @param timeout timeout settings for the setTimeout function. default - 0.
  34867. * @returns the created async loop object
  34868. */
  34869. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34870. }
  34871. }
  34872. declare module BABYLON {
  34873. /**
  34874. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34875. * The underlying implementation relies on an associative array to ensure the best performances.
  34876. * The value can be anything including 'null' but except 'undefined'
  34877. */
  34878. export class StringDictionary<T> {
  34879. /**
  34880. * This will clear this dictionary and copy the content from the 'source' one.
  34881. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34882. * @param source the dictionary to take the content from and copy to this dictionary
  34883. */
  34884. copyFrom(source: StringDictionary<T>): void;
  34885. /**
  34886. * Get a value based from its key
  34887. * @param key the given key to get the matching value from
  34888. * @return the value if found, otherwise undefined is returned
  34889. */
  34890. get(key: string): T | undefined;
  34891. /**
  34892. * Get a value from its key or add it if it doesn't exist.
  34893. * This method will ensure you that a given key/data will be present in the dictionary.
  34894. * @param key the given key to get the matching value from
  34895. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34896. * The factory will only be invoked if there's no data for the given key.
  34897. * @return the value corresponding to the key.
  34898. */
  34899. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34900. /**
  34901. * Get a value from its key if present in the dictionary otherwise add it
  34902. * @param key the key to get the value from
  34903. * @param val if there's no such key/value pair in the dictionary add it with this value
  34904. * @return the value corresponding to the key
  34905. */
  34906. getOrAdd(key: string, val: T): T;
  34907. /**
  34908. * Check if there's a given key in the dictionary
  34909. * @param key the key to check for
  34910. * @return true if the key is present, false otherwise
  34911. */
  34912. contains(key: string): boolean;
  34913. /**
  34914. * Add a new key and its corresponding value
  34915. * @param key the key to add
  34916. * @param value the value corresponding to the key
  34917. * @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
  34918. */
  34919. add(key: string, value: T): boolean;
  34920. /**
  34921. * Update a specific value associated to a key
  34922. * @param key defines the key to use
  34923. * @param value defines the value to store
  34924. * @returns true if the value was updated (or false if the key was not found)
  34925. */
  34926. set(key: string, value: T): boolean;
  34927. /**
  34928. * Get the element of the given key and remove it from the dictionary
  34929. * @param key defines the key to search
  34930. * @returns the value associated with the key or null if not found
  34931. */
  34932. getAndRemove(key: string): Nullable<T>;
  34933. /**
  34934. * Remove a key/value from the dictionary.
  34935. * @param key the key to remove
  34936. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34937. */
  34938. remove(key: string): boolean;
  34939. /**
  34940. * Clear the whole content of the dictionary
  34941. */
  34942. clear(): void;
  34943. /**
  34944. * Gets the current count
  34945. */
  34946. get count(): number;
  34947. /**
  34948. * Execute a callback on each key/val of the dictionary.
  34949. * Note that you can remove any element in this dictionary in the callback implementation
  34950. * @param callback the callback to execute on a given key/value pair
  34951. */
  34952. forEach(callback: (key: string, val: T) => void): void;
  34953. /**
  34954. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34955. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34956. * Note that you can remove any element in this dictionary in the callback implementation
  34957. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34958. * @returns the first item
  34959. */
  34960. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34961. private _count;
  34962. private _data;
  34963. }
  34964. }
  34965. declare module BABYLON {
  34966. /** @hidden */
  34967. export interface ICollisionCoordinator {
  34968. createCollider(): Collider;
  34969. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34970. init(scene: Scene): void;
  34971. }
  34972. /** @hidden */
  34973. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  34974. private _scene;
  34975. private _scaledPosition;
  34976. private _scaledVelocity;
  34977. private _finalPosition;
  34978. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34979. createCollider(): Collider;
  34980. init(scene: Scene): void;
  34981. private _collideWithWorld;
  34982. }
  34983. }
  34984. declare module BABYLON {
  34985. /**
  34986. * Class used to manage all inputs for the scene.
  34987. */
  34988. export class InputManager {
  34989. /** The distance in pixel that you have to move to prevent some events */
  34990. static DragMovementThreshold: number;
  34991. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  34992. static LongPressDelay: number;
  34993. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  34994. static DoubleClickDelay: number;
  34995. /** If you need to check double click without raising a single click at first click, enable this flag */
  34996. static ExclusiveDoubleClickMode: boolean;
  34997. private _wheelEventName;
  34998. private _onPointerMove;
  34999. private _onPointerDown;
  35000. private _onPointerUp;
  35001. private _initClickEvent;
  35002. private _initActionManager;
  35003. private _delayedSimpleClick;
  35004. private _delayedSimpleClickTimeout;
  35005. private _previousDelayedSimpleClickTimeout;
  35006. private _meshPickProceed;
  35007. private _previousButtonPressed;
  35008. private _currentPickResult;
  35009. private _previousPickResult;
  35010. private _totalPointersPressed;
  35011. private _doubleClickOccured;
  35012. private _pointerOverMesh;
  35013. private _pickedDownMesh;
  35014. private _pickedUpMesh;
  35015. private _pointerX;
  35016. private _pointerY;
  35017. private _unTranslatedPointerX;
  35018. private _unTranslatedPointerY;
  35019. private _startingPointerPosition;
  35020. private _previousStartingPointerPosition;
  35021. private _startingPointerTime;
  35022. private _previousStartingPointerTime;
  35023. private _pointerCaptures;
  35024. private _onKeyDown;
  35025. private _onKeyUp;
  35026. private _onCanvasFocusObserver;
  35027. private _onCanvasBlurObserver;
  35028. private _scene;
  35029. /**
  35030. * Creates a new InputManager
  35031. * @param scene defines the hosting scene
  35032. */
  35033. constructor(scene: Scene);
  35034. /**
  35035. * Gets the mesh that is currently under the pointer
  35036. */
  35037. get meshUnderPointer(): Nullable<AbstractMesh>;
  35038. /**
  35039. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35040. */
  35041. get unTranslatedPointer(): Vector2;
  35042. /**
  35043. * Gets or sets the current on-screen X position of the pointer
  35044. */
  35045. get pointerX(): number;
  35046. set pointerX(value: number);
  35047. /**
  35048. * Gets or sets the current on-screen Y position of the pointer
  35049. */
  35050. get pointerY(): number;
  35051. set pointerY(value: number);
  35052. private _updatePointerPosition;
  35053. private _processPointerMove;
  35054. private _setRayOnPointerInfo;
  35055. private _checkPrePointerObservable;
  35056. /**
  35057. * Use this method to simulate a pointer move on a mesh
  35058. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35059. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35060. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35061. */
  35062. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35063. /**
  35064. * Use this method to simulate a pointer down on a mesh
  35065. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35066. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35067. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35068. */
  35069. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35070. private _processPointerDown;
  35071. /** @hidden */
  35072. _isPointerSwiping(): boolean;
  35073. /**
  35074. * Use this method to simulate a pointer up on a mesh
  35075. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35076. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35077. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35078. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35079. */
  35080. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35081. private _processPointerUp;
  35082. /**
  35083. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35084. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35085. * @returns true if the pointer was captured
  35086. */
  35087. isPointerCaptured(pointerId?: number): boolean;
  35088. /**
  35089. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35090. * @param attachUp defines if you want to attach events to pointerup
  35091. * @param attachDown defines if you want to attach events to pointerdown
  35092. * @param attachMove defines if you want to attach events to pointermove
  35093. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35094. */
  35095. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35096. /**
  35097. * Detaches all event handlers
  35098. */
  35099. detachControl(): void;
  35100. /**
  35101. * Force the value of meshUnderPointer
  35102. * @param mesh defines the mesh to use
  35103. */
  35104. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35105. /**
  35106. * Gets the mesh under the pointer
  35107. * @returns a Mesh or null if no mesh is under the pointer
  35108. */
  35109. getPointerOverMesh(): Nullable<AbstractMesh>;
  35110. }
  35111. }
  35112. declare module BABYLON {
  35113. /**
  35114. * Helper class used to generate session unique ID
  35115. */
  35116. export class UniqueIdGenerator {
  35117. private static _UniqueIdCounter;
  35118. /**
  35119. * Gets an unique (relatively to the current scene) Id
  35120. */
  35121. static get UniqueId(): number;
  35122. }
  35123. }
  35124. declare module BABYLON {
  35125. /**
  35126. * This class defines the direct association between an animation and a target
  35127. */
  35128. export class TargetedAnimation {
  35129. /**
  35130. * Animation to perform
  35131. */
  35132. animation: Animation;
  35133. /**
  35134. * Target to animate
  35135. */
  35136. target: any;
  35137. /**
  35138. * Serialize the object
  35139. * @returns the JSON object representing the current entity
  35140. */
  35141. serialize(): any;
  35142. }
  35143. /**
  35144. * Use this class to create coordinated animations on multiple targets
  35145. */
  35146. export class AnimationGroup implements IDisposable {
  35147. /** The name of the animation group */
  35148. name: string;
  35149. private _scene;
  35150. private _targetedAnimations;
  35151. private _animatables;
  35152. private _from;
  35153. private _to;
  35154. private _isStarted;
  35155. private _isPaused;
  35156. private _speedRatio;
  35157. private _loopAnimation;
  35158. private _isAdditive;
  35159. /**
  35160. * Gets or sets the unique id of the node
  35161. */
  35162. uniqueId: number;
  35163. /**
  35164. * This observable will notify when one animation have ended
  35165. */
  35166. onAnimationEndObservable: Observable<TargetedAnimation>;
  35167. /**
  35168. * Observer raised when one animation loops
  35169. */
  35170. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35171. /**
  35172. * Observer raised when all animations have looped
  35173. */
  35174. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35175. /**
  35176. * This observable will notify when all animations have ended.
  35177. */
  35178. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35179. /**
  35180. * This observable will notify when all animations have paused.
  35181. */
  35182. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35183. /**
  35184. * This observable will notify when all animations are playing.
  35185. */
  35186. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35187. /**
  35188. * Gets the first frame
  35189. */
  35190. get from(): number;
  35191. /**
  35192. * Gets the last frame
  35193. */
  35194. get to(): number;
  35195. /**
  35196. * Define if the animations are started
  35197. */
  35198. get isStarted(): boolean;
  35199. /**
  35200. * Gets a value indicating that the current group is playing
  35201. */
  35202. get isPlaying(): boolean;
  35203. /**
  35204. * Gets or sets the speed ratio to use for all animations
  35205. */
  35206. get speedRatio(): number;
  35207. /**
  35208. * Gets or sets the speed ratio to use for all animations
  35209. */
  35210. set speedRatio(value: number);
  35211. /**
  35212. * Gets or sets if all animations should loop or not
  35213. */
  35214. get loopAnimation(): boolean;
  35215. set loopAnimation(value: boolean);
  35216. /**
  35217. * Gets or sets if all animations should be evaluated additively
  35218. */
  35219. get isAdditive(): boolean;
  35220. set isAdditive(value: boolean);
  35221. /**
  35222. * Gets the targeted animations for this animation group
  35223. */
  35224. get targetedAnimations(): Array<TargetedAnimation>;
  35225. /**
  35226. * returning the list of animatables controlled by this animation group.
  35227. */
  35228. get animatables(): Array<Animatable>;
  35229. /**
  35230. * Instantiates a new Animation Group.
  35231. * This helps managing several animations at once.
  35232. * @see http://doc.babylonjs.com/how_to/group
  35233. * @param name Defines the name of the group
  35234. * @param scene Defines the scene the group belongs to
  35235. */
  35236. constructor(
  35237. /** The name of the animation group */
  35238. name: string, scene?: Nullable<Scene>);
  35239. /**
  35240. * Add an animation (with its target) in the group
  35241. * @param animation defines the animation we want to add
  35242. * @param target defines the target of the animation
  35243. * @returns the TargetedAnimation object
  35244. */
  35245. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35246. /**
  35247. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35248. * It can add constant keys at begin or end
  35249. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35250. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35251. * @returns the animation group
  35252. */
  35253. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35254. private _animationLoopCount;
  35255. private _animationLoopFlags;
  35256. private _processLoop;
  35257. /**
  35258. * Start all animations on given targets
  35259. * @param loop defines if animations must loop
  35260. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35261. * @param from defines the from key (optional)
  35262. * @param to defines the to key (optional)
  35263. * @param isAdditive defines the additive state for the resulting animatables (optional)
  35264. * @returns the current animation group
  35265. */
  35266. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  35267. /**
  35268. * Pause all animations
  35269. * @returns the animation group
  35270. */
  35271. pause(): AnimationGroup;
  35272. /**
  35273. * Play all animations to initial state
  35274. * This function will start() the animations if they were not started or will restart() them if they were paused
  35275. * @param loop defines if animations must loop
  35276. * @returns the animation group
  35277. */
  35278. play(loop?: boolean): AnimationGroup;
  35279. /**
  35280. * Reset all animations to initial state
  35281. * @returns the animation group
  35282. */
  35283. reset(): AnimationGroup;
  35284. /**
  35285. * Restart animations from key 0
  35286. * @returns the animation group
  35287. */
  35288. restart(): AnimationGroup;
  35289. /**
  35290. * Stop all animations
  35291. * @returns the animation group
  35292. */
  35293. stop(): AnimationGroup;
  35294. /**
  35295. * Set animation weight for all animatables
  35296. * @param weight defines the weight to use
  35297. * @return the animationGroup
  35298. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35299. */
  35300. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35301. /**
  35302. * Synchronize and normalize all animatables with a source animatable
  35303. * @param root defines the root animatable to synchronize with
  35304. * @return the animationGroup
  35305. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35306. */
  35307. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35308. /**
  35309. * Goes to a specific frame in this animation group
  35310. * @param frame the frame number to go to
  35311. * @return the animationGroup
  35312. */
  35313. goToFrame(frame: number): AnimationGroup;
  35314. /**
  35315. * Dispose all associated resources
  35316. */
  35317. dispose(): void;
  35318. private _checkAnimationGroupEnded;
  35319. /**
  35320. * Clone the current animation group and returns a copy
  35321. * @param newName defines the name of the new group
  35322. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35323. * @returns the new aniamtion group
  35324. */
  35325. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35326. /**
  35327. * Serializes the animationGroup to an object
  35328. * @returns Serialized object
  35329. */
  35330. serialize(): any;
  35331. /**
  35332. * Returns a new AnimationGroup object parsed from the source provided.
  35333. * @param parsedAnimationGroup defines the source
  35334. * @param scene defines the scene that will receive the animationGroup
  35335. * @returns a new AnimationGroup
  35336. */
  35337. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35338. /**
  35339. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  35340. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  35341. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  35342. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  35343. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  35344. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  35345. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  35346. */
  35347. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  35348. /**
  35349. * Returns the string "AnimationGroup"
  35350. * @returns "AnimationGroup"
  35351. */
  35352. getClassName(): string;
  35353. /**
  35354. * Creates a detailled string about the object
  35355. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35356. * @returns a string representing the object
  35357. */
  35358. toString(fullDetails?: boolean): string;
  35359. }
  35360. }
  35361. declare module BABYLON {
  35362. /**
  35363. * Define an interface for all classes that will hold resources
  35364. */
  35365. export interface IDisposable {
  35366. /**
  35367. * Releases all held resources
  35368. */
  35369. dispose(): void;
  35370. }
  35371. /** Interface defining initialization parameters for Scene class */
  35372. export interface SceneOptions {
  35373. /**
  35374. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35375. * It will improve performance when the number of geometries becomes important.
  35376. */
  35377. useGeometryUniqueIdsMap?: boolean;
  35378. /**
  35379. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35380. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35381. */
  35382. useMaterialMeshMap?: boolean;
  35383. /**
  35384. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35385. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35386. */
  35387. useClonedMeshMap?: boolean;
  35388. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35389. virtual?: boolean;
  35390. }
  35391. /**
  35392. * Represents a scene to be rendered by the engine.
  35393. * @see http://doc.babylonjs.com/features/scene
  35394. */
  35395. export class Scene extends AbstractScene implements IAnimatable {
  35396. /** The fog is deactivated */
  35397. static readonly FOGMODE_NONE: number;
  35398. /** The fog density is following an exponential function */
  35399. static readonly FOGMODE_EXP: number;
  35400. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35401. static readonly FOGMODE_EXP2: number;
  35402. /** The fog density is following a linear function. */
  35403. static readonly FOGMODE_LINEAR: number;
  35404. /**
  35405. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35406. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35407. */
  35408. static MinDeltaTime: number;
  35409. /**
  35410. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35411. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35412. */
  35413. static MaxDeltaTime: number;
  35414. /**
  35415. * Factory used to create the default material.
  35416. * @param name The name of the material to create
  35417. * @param scene The scene to create the material for
  35418. * @returns The default material
  35419. */
  35420. static DefaultMaterialFactory(scene: Scene): Material;
  35421. /**
  35422. * Factory used to create the a collision coordinator.
  35423. * @returns The collision coordinator
  35424. */
  35425. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35426. /** @hidden */
  35427. _inputManager: InputManager;
  35428. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35429. cameraToUseForPointers: Nullable<Camera>;
  35430. /** @hidden */
  35431. readonly _isScene: boolean;
  35432. /** @hidden */
  35433. _blockEntityCollection: boolean;
  35434. /**
  35435. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35436. */
  35437. autoClear: boolean;
  35438. /**
  35439. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35440. */
  35441. autoClearDepthAndStencil: boolean;
  35442. /**
  35443. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35444. */
  35445. clearColor: Color4;
  35446. /**
  35447. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35448. */
  35449. ambientColor: Color3;
  35450. /**
  35451. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35452. * It should only be one of the following (if not the default embedded one):
  35453. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35454. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35455. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35456. * The material properties need to be setup according to the type of texture in use.
  35457. */
  35458. environmentBRDFTexture: BaseTexture;
  35459. /** @hidden */
  35460. protected _environmentTexture: Nullable<BaseTexture>;
  35461. /**
  35462. * Texture used in all pbr material as the reflection texture.
  35463. * As in the majority of the scene they are the same (exception for multi room and so on),
  35464. * this is easier to reference from here than from all the materials.
  35465. */
  35466. get environmentTexture(): Nullable<BaseTexture>;
  35467. /**
  35468. * Texture used in all pbr material as the reflection texture.
  35469. * As in the majority of the scene they are the same (exception for multi room and so on),
  35470. * this is easier to set here than in all the materials.
  35471. */
  35472. set environmentTexture(value: Nullable<BaseTexture>);
  35473. /** @hidden */
  35474. protected _environmentIntensity: number;
  35475. /**
  35476. * Intensity of the environment in all pbr material.
  35477. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35478. * As in the majority of the scene they are the same (exception for multi room and so on),
  35479. * this is easier to reference from here than from all the materials.
  35480. */
  35481. get environmentIntensity(): number;
  35482. /**
  35483. * Intensity of the environment in all pbr material.
  35484. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35485. * As in the majority of the scene they are the same (exception for multi room and so on),
  35486. * this is easier to set here than in all the materials.
  35487. */
  35488. set environmentIntensity(value: number);
  35489. /** @hidden */
  35490. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35491. /**
  35492. * Default image processing configuration used either in the rendering
  35493. * Forward main pass or through the imageProcessingPostProcess if present.
  35494. * As in the majority of the scene they are the same (exception for multi camera),
  35495. * this is easier to reference from here than from all the materials and post process.
  35496. *
  35497. * No setter as we it is a shared configuration, you can set the values instead.
  35498. */
  35499. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35500. private _forceWireframe;
  35501. /**
  35502. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35503. */
  35504. set forceWireframe(value: boolean);
  35505. get forceWireframe(): boolean;
  35506. private _skipFrustumClipping;
  35507. /**
  35508. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35509. */
  35510. set skipFrustumClipping(value: boolean);
  35511. get skipFrustumClipping(): boolean;
  35512. private _forcePointsCloud;
  35513. /**
  35514. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35515. */
  35516. set forcePointsCloud(value: boolean);
  35517. get forcePointsCloud(): boolean;
  35518. /**
  35519. * Gets or sets the active clipplane 1
  35520. */
  35521. clipPlane: Nullable<Plane>;
  35522. /**
  35523. * Gets or sets the active clipplane 2
  35524. */
  35525. clipPlane2: Nullable<Plane>;
  35526. /**
  35527. * Gets or sets the active clipplane 3
  35528. */
  35529. clipPlane3: Nullable<Plane>;
  35530. /**
  35531. * Gets or sets the active clipplane 4
  35532. */
  35533. clipPlane4: Nullable<Plane>;
  35534. /**
  35535. * Gets or sets the active clipplane 5
  35536. */
  35537. clipPlane5: Nullable<Plane>;
  35538. /**
  35539. * Gets or sets the active clipplane 6
  35540. */
  35541. clipPlane6: Nullable<Plane>;
  35542. /**
  35543. * Gets or sets a boolean indicating if animations are enabled
  35544. */
  35545. animationsEnabled: boolean;
  35546. private _animationPropertiesOverride;
  35547. /**
  35548. * Gets or sets the animation properties override
  35549. */
  35550. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35551. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35552. /**
  35553. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35554. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35555. */
  35556. useConstantAnimationDeltaTime: boolean;
  35557. /**
  35558. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35559. * Please note that it requires to run a ray cast through the scene on every frame
  35560. */
  35561. constantlyUpdateMeshUnderPointer: boolean;
  35562. /**
  35563. * Defines the HTML cursor to use when hovering over interactive elements
  35564. */
  35565. hoverCursor: string;
  35566. /**
  35567. * Defines the HTML default cursor to use (empty by default)
  35568. */
  35569. defaultCursor: string;
  35570. /**
  35571. * Defines whether cursors are handled by the scene.
  35572. */
  35573. doNotHandleCursors: boolean;
  35574. /**
  35575. * This is used to call preventDefault() on pointer down
  35576. * in order to block unwanted artifacts like system double clicks
  35577. */
  35578. preventDefaultOnPointerDown: boolean;
  35579. /**
  35580. * This is used to call preventDefault() on pointer up
  35581. * in order to block unwanted artifacts like system double clicks
  35582. */
  35583. preventDefaultOnPointerUp: boolean;
  35584. /**
  35585. * Gets or sets user defined metadata
  35586. */
  35587. metadata: any;
  35588. /**
  35589. * For internal use only. Please do not use.
  35590. */
  35591. reservedDataStore: any;
  35592. /**
  35593. * Gets the name of the plugin used to load this scene (null by default)
  35594. */
  35595. loadingPluginName: string;
  35596. /**
  35597. * Use this array to add regular expressions used to disable offline support for specific urls
  35598. */
  35599. disableOfflineSupportExceptionRules: RegExp[];
  35600. /**
  35601. * An event triggered when the scene is disposed.
  35602. */
  35603. onDisposeObservable: Observable<Scene>;
  35604. private _onDisposeObserver;
  35605. /** Sets a function to be executed when this scene is disposed. */
  35606. set onDispose(callback: () => void);
  35607. /**
  35608. * An event triggered before rendering the scene (right after animations and physics)
  35609. */
  35610. onBeforeRenderObservable: Observable<Scene>;
  35611. private _onBeforeRenderObserver;
  35612. /** Sets a function to be executed before rendering this scene */
  35613. set beforeRender(callback: Nullable<() => void>);
  35614. /**
  35615. * An event triggered after rendering the scene
  35616. */
  35617. onAfterRenderObservable: Observable<Scene>;
  35618. /**
  35619. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35620. */
  35621. onAfterRenderCameraObservable: Observable<Camera>;
  35622. private _onAfterRenderObserver;
  35623. /** Sets a function to be executed after rendering this scene */
  35624. set afterRender(callback: Nullable<() => void>);
  35625. /**
  35626. * An event triggered before animating the scene
  35627. */
  35628. onBeforeAnimationsObservable: Observable<Scene>;
  35629. /**
  35630. * An event triggered after animations processing
  35631. */
  35632. onAfterAnimationsObservable: Observable<Scene>;
  35633. /**
  35634. * An event triggered before draw calls are ready to be sent
  35635. */
  35636. onBeforeDrawPhaseObservable: Observable<Scene>;
  35637. /**
  35638. * An event triggered after draw calls have been sent
  35639. */
  35640. onAfterDrawPhaseObservable: Observable<Scene>;
  35641. /**
  35642. * An event triggered when the scene is ready
  35643. */
  35644. onReadyObservable: Observable<Scene>;
  35645. /**
  35646. * An event triggered before rendering a camera
  35647. */
  35648. onBeforeCameraRenderObservable: Observable<Camera>;
  35649. private _onBeforeCameraRenderObserver;
  35650. /** Sets a function to be executed before rendering a camera*/
  35651. set beforeCameraRender(callback: () => void);
  35652. /**
  35653. * An event triggered after rendering a camera
  35654. */
  35655. onAfterCameraRenderObservable: Observable<Camera>;
  35656. private _onAfterCameraRenderObserver;
  35657. /** Sets a function to be executed after rendering a camera*/
  35658. set afterCameraRender(callback: () => void);
  35659. /**
  35660. * An event triggered when active meshes evaluation is about to start
  35661. */
  35662. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35663. /**
  35664. * An event triggered when active meshes evaluation is done
  35665. */
  35666. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35667. /**
  35668. * An event triggered when particles rendering is about to start
  35669. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35670. */
  35671. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35672. /**
  35673. * An event triggered when particles rendering is done
  35674. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35675. */
  35676. onAfterParticlesRenderingObservable: Observable<Scene>;
  35677. /**
  35678. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35679. */
  35680. onDataLoadedObservable: Observable<Scene>;
  35681. /**
  35682. * An event triggered when a camera is created
  35683. */
  35684. onNewCameraAddedObservable: Observable<Camera>;
  35685. /**
  35686. * An event triggered when a camera is removed
  35687. */
  35688. onCameraRemovedObservable: Observable<Camera>;
  35689. /**
  35690. * An event triggered when a light is created
  35691. */
  35692. onNewLightAddedObservable: Observable<Light>;
  35693. /**
  35694. * An event triggered when a light is removed
  35695. */
  35696. onLightRemovedObservable: Observable<Light>;
  35697. /**
  35698. * An event triggered when a geometry is created
  35699. */
  35700. onNewGeometryAddedObservable: Observable<Geometry>;
  35701. /**
  35702. * An event triggered when a geometry is removed
  35703. */
  35704. onGeometryRemovedObservable: Observable<Geometry>;
  35705. /**
  35706. * An event triggered when a transform node is created
  35707. */
  35708. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35709. /**
  35710. * An event triggered when a transform node is removed
  35711. */
  35712. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35713. /**
  35714. * An event triggered when a mesh is created
  35715. */
  35716. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35717. /**
  35718. * An event triggered when a mesh is removed
  35719. */
  35720. onMeshRemovedObservable: Observable<AbstractMesh>;
  35721. /**
  35722. * An event triggered when a skeleton is created
  35723. */
  35724. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35725. /**
  35726. * An event triggered when a skeleton is removed
  35727. */
  35728. onSkeletonRemovedObservable: Observable<Skeleton>;
  35729. /**
  35730. * An event triggered when a material is created
  35731. */
  35732. onNewMaterialAddedObservable: Observable<Material>;
  35733. /**
  35734. * An event triggered when a material is removed
  35735. */
  35736. onMaterialRemovedObservable: Observable<Material>;
  35737. /**
  35738. * An event triggered when a texture is created
  35739. */
  35740. onNewTextureAddedObservable: Observable<BaseTexture>;
  35741. /**
  35742. * An event triggered when a texture is removed
  35743. */
  35744. onTextureRemovedObservable: Observable<BaseTexture>;
  35745. /**
  35746. * An event triggered when render targets are about to be rendered
  35747. * Can happen multiple times per frame.
  35748. */
  35749. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35750. /**
  35751. * An event triggered when render targets were rendered.
  35752. * Can happen multiple times per frame.
  35753. */
  35754. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35755. /**
  35756. * An event triggered before calculating deterministic simulation step
  35757. */
  35758. onBeforeStepObservable: Observable<Scene>;
  35759. /**
  35760. * An event triggered after calculating deterministic simulation step
  35761. */
  35762. onAfterStepObservable: Observable<Scene>;
  35763. /**
  35764. * An event triggered when the activeCamera property is updated
  35765. */
  35766. onActiveCameraChanged: Observable<Scene>;
  35767. /**
  35768. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35769. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35770. * 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)
  35771. */
  35772. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35773. /**
  35774. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35775. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35776. * 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)
  35777. */
  35778. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35779. /**
  35780. * This Observable will when a mesh has been imported into the scene.
  35781. */
  35782. onMeshImportedObservable: Observable<AbstractMesh>;
  35783. /**
  35784. * This Observable will when an animation file has been imported into the scene.
  35785. */
  35786. onAnimationFileImportedObservable: Observable<Scene>;
  35787. /**
  35788. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35789. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35790. */
  35791. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35792. /** @hidden */
  35793. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35794. /**
  35795. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35796. */
  35797. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35798. /**
  35799. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35800. */
  35801. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35802. /**
  35803. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35804. */
  35805. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35806. /** Callback called when a pointer move is detected */
  35807. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35808. /** Callback called when a pointer down is detected */
  35809. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35810. /** Callback called when a pointer up is detected */
  35811. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35812. /** Callback called when a pointer pick is detected */
  35813. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35814. /**
  35815. * 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).
  35816. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35817. */
  35818. onPrePointerObservable: Observable<PointerInfoPre>;
  35819. /**
  35820. * Observable event triggered each time an input event is received from the rendering canvas
  35821. */
  35822. onPointerObservable: Observable<PointerInfo>;
  35823. /**
  35824. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35825. */
  35826. get unTranslatedPointer(): Vector2;
  35827. /**
  35828. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35829. */
  35830. static get DragMovementThreshold(): number;
  35831. static set DragMovementThreshold(value: number);
  35832. /**
  35833. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35834. */
  35835. static get LongPressDelay(): number;
  35836. static set LongPressDelay(value: number);
  35837. /**
  35838. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35839. */
  35840. static get DoubleClickDelay(): number;
  35841. static set DoubleClickDelay(value: number);
  35842. /** If you need to check double click without raising a single click at first click, enable this flag */
  35843. static get ExclusiveDoubleClickMode(): boolean;
  35844. static set ExclusiveDoubleClickMode(value: boolean);
  35845. /** @hidden */
  35846. _mirroredCameraPosition: Nullable<Vector3>;
  35847. /**
  35848. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35849. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35850. */
  35851. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35852. /**
  35853. * Observable event triggered each time an keyboard event is received from the hosting window
  35854. */
  35855. onKeyboardObservable: Observable<KeyboardInfo>;
  35856. private _useRightHandedSystem;
  35857. /**
  35858. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35859. */
  35860. set useRightHandedSystem(value: boolean);
  35861. get useRightHandedSystem(): boolean;
  35862. private _timeAccumulator;
  35863. private _currentStepId;
  35864. private _currentInternalStep;
  35865. /**
  35866. * Sets the step Id used by deterministic lock step
  35867. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35868. * @param newStepId defines the step Id
  35869. */
  35870. setStepId(newStepId: number): void;
  35871. /**
  35872. * Gets the step Id used by deterministic lock step
  35873. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35874. * @returns the step Id
  35875. */
  35876. getStepId(): number;
  35877. /**
  35878. * Gets the internal step used by deterministic lock step
  35879. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35880. * @returns the internal step
  35881. */
  35882. getInternalStep(): number;
  35883. private _fogEnabled;
  35884. /**
  35885. * Gets or sets a boolean indicating if fog is enabled on this scene
  35886. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35887. * (Default is true)
  35888. */
  35889. set fogEnabled(value: boolean);
  35890. get fogEnabled(): boolean;
  35891. private _fogMode;
  35892. /**
  35893. * Gets or sets the fog mode to use
  35894. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35895. * | mode | value |
  35896. * | --- | --- |
  35897. * | FOGMODE_NONE | 0 |
  35898. * | FOGMODE_EXP | 1 |
  35899. * | FOGMODE_EXP2 | 2 |
  35900. * | FOGMODE_LINEAR | 3 |
  35901. */
  35902. set fogMode(value: number);
  35903. get fogMode(): number;
  35904. /**
  35905. * Gets or sets the fog color to use
  35906. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35907. * (Default is Color3(0.2, 0.2, 0.3))
  35908. */
  35909. fogColor: Color3;
  35910. /**
  35911. * Gets or sets the fog density to use
  35912. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35913. * (Default is 0.1)
  35914. */
  35915. fogDensity: number;
  35916. /**
  35917. * Gets or sets the fog start distance to use
  35918. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35919. * (Default is 0)
  35920. */
  35921. fogStart: number;
  35922. /**
  35923. * Gets or sets the fog end distance to use
  35924. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35925. * (Default is 1000)
  35926. */
  35927. fogEnd: number;
  35928. private _shadowsEnabled;
  35929. /**
  35930. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35931. */
  35932. set shadowsEnabled(value: boolean);
  35933. get shadowsEnabled(): boolean;
  35934. private _lightsEnabled;
  35935. /**
  35936. * Gets or sets a boolean indicating if lights are enabled on this scene
  35937. */
  35938. set lightsEnabled(value: boolean);
  35939. get lightsEnabled(): boolean;
  35940. /** All of the active cameras added to this scene. */
  35941. activeCameras: Camera[];
  35942. /** @hidden */
  35943. _activeCamera: Nullable<Camera>;
  35944. /** Gets or sets the current active camera */
  35945. get activeCamera(): Nullable<Camera>;
  35946. set activeCamera(value: Nullable<Camera>);
  35947. private _defaultMaterial;
  35948. /** The default material used on meshes when no material is affected */
  35949. get defaultMaterial(): Material;
  35950. /** The default material used on meshes when no material is affected */
  35951. set defaultMaterial(value: Material);
  35952. private _texturesEnabled;
  35953. /**
  35954. * Gets or sets a boolean indicating if textures are enabled on this scene
  35955. */
  35956. set texturesEnabled(value: boolean);
  35957. get texturesEnabled(): boolean;
  35958. /**
  35959. * Gets or sets a boolean indicating if particles are enabled on this scene
  35960. */
  35961. particlesEnabled: boolean;
  35962. /**
  35963. * Gets or sets a boolean indicating if sprites are enabled on this scene
  35964. */
  35965. spritesEnabled: boolean;
  35966. private _skeletonsEnabled;
  35967. /**
  35968. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  35969. */
  35970. set skeletonsEnabled(value: boolean);
  35971. get skeletonsEnabled(): boolean;
  35972. /**
  35973. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  35974. */
  35975. lensFlaresEnabled: boolean;
  35976. /**
  35977. * Gets or sets a boolean indicating if collisions are enabled on this scene
  35978. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35979. */
  35980. collisionsEnabled: boolean;
  35981. private _collisionCoordinator;
  35982. /** @hidden */
  35983. get collisionCoordinator(): ICollisionCoordinator;
  35984. /**
  35985. * Defines the gravity applied to this scene (used only for collisions)
  35986. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35987. */
  35988. gravity: Vector3;
  35989. /**
  35990. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  35991. */
  35992. postProcessesEnabled: boolean;
  35993. /**
  35994. * The list of postprocesses added to the scene
  35995. */
  35996. postProcesses: PostProcess[];
  35997. /**
  35998. * Gets the current postprocess manager
  35999. */
  36000. postProcessManager: PostProcessManager;
  36001. /**
  36002. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36003. */
  36004. renderTargetsEnabled: boolean;
  36005. /**
  36006. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36007. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36008. */
  36009. dumpNextRenderTargets: boolean;
  36010. /**
  36011. * The list of user defined render targets added to the scene
  36012. */
  36013. customRenderTargets: RenderTargetTexture[];
  36014. /**
  36015. * Defines if texture loading must be delayed
  36016. * If true, textures will only be loaded when they need to be rendered
  36017. */
  36018. useDelayedTextureLoading: boolean;
  36019. /**
  36020. * Gets the list of meshes imported to the scene through SceneLoader
  36021. */
  36022. importedMeshesFiles: String[];
  36023. /**
  36024. * Gets or sets a boolean indicating if probes are enabled on this scene
  36025. */
  36026. probesEnabled: boolean;
  36027. /**
  36028. * Gets or sets the current offline provider to use to store scene data
  36029. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36030. */
  36031. offlineProvider: IOfflineProvider;
  36032. /**
  36033. * Gets or sets the action manager associated with the scene
  36034. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36035. */
  36036. actionManager: AbstractActionManager;
  36037. private _meshesForIntersections;
  36038. /**
  36039. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36040. */
  36041. proceduralTexturesEnabled: boolean;
  36042. private _engine;
  36043. private _totalVertices;
  36044. /** @hidden */
  36045. _activeIndices: PerfCounter;
  36046. /** @hidden */
  36047. _activeParticles: PerfCounter;
  36048. /** @hidden */
  36049. _activeBones: PerfCounter;
  36050. private _animationRatio;
  36051. /** @hidden */
  36052. _animationTimeLast: number;
  36053. /** @hidden */
  36054. _animationTime: number;
  36055. /**
  36056. * Gets or sets a general scale for animation speed
  36057. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36058. */
  36059. animationTimeScale: number;
  36060. /** @hidden */
  36061. _cachedMaterial: Nullable<Material>;
  36062. /** @hidden */
  36063. _cachedEffect: Nullable<Effect>;
  36064. /** @hidden */
  36065. _cachedVisibility: Nullable<number>;
  36066. private _renderId;
  36067. private _frameId;
  36068. private _executeWhenReadyTimeoutId;
  36069. private _intermediateRendering;
  36070. private _viewUpdateFlag;
  36071. private _projectionUpdateFlag;
  36072. /** @hidden */
  36073. _toBeDisposed: Nullable<IDisposable>[];
  36074. private _activeRequests;
  36075. /** @hidden */
  36076. _pendingData: any[];
  36077. private _isDisposed;
  36078. /**
  36079. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36080. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36081. */
  36082. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36083. private _activeMeshes;
  36084. private _processedMaterials;
  36085. private _renderTargets;
  36086. /** @hidden */
  36087. _activeParticleSystems: SmartArray<IParticleSystem>;
  36088. private _activeSkeletons;
  36089. private _softwareSkinnedMeshes;
  36090. private _renderingManager;
  36091. /** @hidden */
  36092. _activeAnimatables: Animatable[];
  36093. private _transformMatrix;
  36094. private _sceneUbo;
  36095. /** @hidden */
  36096. _viewMatrix: Matrix;
  36097. private _projectionMatrix;
  36098. /** @hidden */
  36099. _forcedViewPosition: Nullable<Vector3>;
  36100. /** @hidden */
  36101. _frustumPlanes: Plane[];
  36102. /**
  36103. * Gets the list of frustum planes (built from the active camera)
  36104. */
  36105. get frustumPlanes(): Plane[];
  36106. /**
  36107. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36108. * This is useful if there are more lights that the maximum simulteanous authorized
  36109. */
  36110. requireLightSorting: boolean;
  36111. /** @hidden */
  36112. readonly useMaterialMeshMap: boolean;
  36113. /** @hidden */
  36114. readonly useClonedMeshMap: boolean;
  36115. private _externalData;
  36116. private _uid;
  36117. /**
  36118. * @hidden
  36119. * Backing store of defined scene components.
  36120. */
  36121. _components: ISceneComponent[];
  36122. /**
  36123. * @hidden
  36124. * Backing store of defined scene components.
  36125. */
  36126. _serializableComponents: ISceneSerializableComponent[];
  36127. /**
  36128. * List of components to register on the next registration step.
  36129. */
  36130. private _transientComponents;
  36131. /**
  36132. * Registers the transient components if needed.
  36133. */
  36134. private _registerTransientComponents;
  36135. /**
  36136. * @hidden
  36137. * Add a component to the scene.
  36138. * Note that the ccomponent could be registered on th next frame if this is called after
  36139. * the register component stage.
  36140. * @param component Defines the component to add to the scene
  36141. */
  36142. _addComponent(component: ISceneComponent): void;
  36143. /**
  36144. * @hidden
  36145. * Gets a component from the scene.
  36146. * @param name defines the name of the component to retrieve
  36147. * @returns the component or null if not present
  36148. */
  36149. _getComponent(name: string): Nullable<ISceneComponent>;
  36150. /**
  36151. * @hidden
  36152. * Defines the actions happening before camera updates.
  36153. */
  36154. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36155. /**
  36156. * @hidden
  36157. * Defines the actions happening before clear the canvas.
  36158. */
  36159. _beforeClearStage: Stage<SimpleStageAction>;
  36160. /**
  36161. * @hidden
  36162. * Defines the actions when collecting render targets for the frame.
  36163. */
  36164. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36165. /**
  36166. * @hidden
  36167. * Defines the actions happening for one camera in the frame.
  36168. */
  36169. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36170. /**
  36171. * @hidden
  36172. * Defines the actions happening during the per mesh ready checks.
  36173. */
  36174. _isReadyForMeshStage: Stage<MeshStageAction>;
  36175. /**
  36176. * @hidden
  36177. * Defines the actions happening before evaluate active mesh checks.
  36178. */
  36179. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36180. /**
  36181. * @hidden
  36182. * Defines the actions happening during the evaluate sub mesh checks.
  36183. */
  36184. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36185. /**
  36186. * @hidden
  36187. * Defines the actions happening during the active mesh stage.
  36188. */
  36189. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36190. /**
  36191. * @hidden
  36192. * Defines the actions happening during the per camera render target step.
  36193. */
  36194. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36195. /**
  36196. * @hidden
  36197. * Defines the actions happening just before the active camera is drawing.
  36198. */
  36199. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36200. /**
  36201. * @hidden
  36202. * Defines the actions happening just before a render target is drawing.
  36203. */
  36204. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36205. /**
  36206. * @hidden
  36207. * Defines the actions happening just before a rendering group is drawing.
  36208. */
  36209. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36210. /**
  36211. * @hidden
  36212. * Defines the actions happening just before a mesh is drawing.
  36213. */
  36214. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36215. /**
  36216. * @hidden
  36217. * Defines the actions happening just after a mesh has been drawn.
  36218. */
  36219. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36220. /**
  36221. * @hidden
  36222. * Defines the actions happening just after a rendering group has been drawn.
  36223. */
  36224. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36225. /**
  36226. * @hidden
  36227. * Defines the actions happening just after the active camera has been drawn.
  36228. */
  36229. _afterCameraDrawStage: Stage<CameraStageAction>;
  36230. /**
  36231. * @hidden
  36232. * Defines the actions happening just after a render target has been drawn.
  36233. */
  36234. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36235. /**
  36236. * @hidden
  36237. * Defines the actions happening just after rendering all cameras and computing intersections.
  36238. */
  36239. _afterRenderStage: Stage<SimpleStageAction>;
  36240. /**
  36241. * @hidden
  36242. * Defines the actions happening when a pointer move event happens.
  36243. */
  36244. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36245. /**
  36246. * @hidden
  36247. * Defines the actions happening when a pointer down event happens.
  36248. */
  36249. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36250. /**
  36251. * @hidden
  36252. * Defines the actions happening when a pointer up event happens.
  36253. */
  36254. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36255. /**
  36256. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36257. */
  36258. private geometriesByUniqueId;
  36259. /**
  36260. * Creates a new Scene
  36261. * @param engine defines the engine to use to render this scene
  36262. * @param options defines the scene options
  36263. */
  36264. constructor(engine: Engine, options?: SceneOptions);
  36265. /**
  36266. * Gets a string idenfifying the name of the class
  36267. * @returns "Scene" string
  36268. */
  36269. getClassName(): string;
  36270. private _defaultMeshCandidates;
  36271. /**
  36272. * @hidden
  36273. */
  36274. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36275. private _defaultSubMeshCandidates;
  36276. /**
  36277. * @hidden
  36278. */
  36279. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36280. /**
  36281. * Sets the default candidate providers for the scene.
  36282. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36283. * and getCollidingSubMeshCandidates to their default function
  36284. */
  36285. setDefaultCandidateProviders(): void;
  36286. /**
  36287. * Gets the mesh that is currently under the pointer
  36288. */
  36289. get meshUnderPointer(): Nullable<AbstractMesh>;
  36290. /**
  36291. * Gets or sets the current on-screen X position of the pointer
  36292. */
  36293. get pointerX(): number;
  36294. set pointerX(value: number);
  36295. /**
  36296. * Gets or sets the current on-screen Y position of the pointer
  36297. */
  36298. get pointerY(): number;
  36299. set pointerY(value: number);
  36300. /**
  36301. * Gets the cached material (ie. the latest rendered one)
  36302. * @returns the cached material
  36303. */
  36304. getCachedMaterial(): Nullable<Material>;
  36305. /**
  36306. * Gets the cached effect (ie. the latest rendered one)
  36307. * @returns the cached effect
  36308. */
  36309. getCachedEffect(): Nullable<Effect>;
  36310. /**
  36311. * Gets the cached visibility state (ie. the latest rendered one)
  36312. * @returns the cached visibility state
  36313. */
  36314. getCachedVisibility(): Nullable<number>;
  36315. /**
  36316. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36317. * @param material defines the current material
  36318. * @param effect defines the current effect
  36319. * @param visibility defines the current visibility state
  36320. * @returns true if one parameter is not cached
  36321. */
  36322. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36323. /**
  36324. * Gets the engine associated with the scene
  36325. * @returns an Engine
  36326. */
  36327. getEngine(): Engine;
  36328. /**
  36329. * Gets the total number of vertices rendered per frame
  36330. * @returns the total number of vertices rendered per frame
  36331. */
  36332. getTotalVertices(): number;
  36333. /**
  36334. * Gets the performance counter for total vertices
  36335. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36336. */
  36337. get totalVerticesPerfCounter(): PerfCounter;
  36338. /**
  36339. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36340. * @returns the total number of active indices rendered per frame
  36341. */
  36342. getActiveIndices(): number;
  36343. /**
  36344. * Gets the performance counter for active indices
  36345. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36346. */
  36347. get totalActiveIndicesPerfCounter(): PerfCounter;
  36348. /**
  36349. * Gets the total number of active particles rendered per frame
  36350. * @returns the total number of active particles rendered per frame
  36351. */
  36352. getActiveParticles(): number;
  36353. /**
  36354. * Gets the performance counter for active particles
  36355. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36356. */
  36357. get activeParticlesPerfCounter(): PerfCounter;
  36358. /**
  36359. * Gets the total number of active bones rendered per frame
  36360. * @returns the total number of active bones rendered per frame
  36361. */
  36362. getActiveBones(): number;
  36363. /**
  36364. * Gets the performance counter for active bones
  36365. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36366. */
  36367. get activeBonesPerfCounter(): PerfCounter;
  36368. /**
  36369. * Gets the array of active meshes
  36370. * @returns an array of AbstractMesh
  36371. */
  36372. getActiveMeshes(): SmartArray<AbstractMesh>;
  36373. /**
  36374. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36375. * @returns a number
  36376. */
  36377. getAnimationRatio(): number;
  36378. /**
  36379. * Gets an unique Id for the current render phase
  36380. * @returns a number
  36381. */
  36382. getRenderId(): number;
  36383. /**
  36384. * Gets an unique Id for the current frame
  36385. * @returns a number
  36386. */
  36387. getFrameId(): number;
  36388. /** Call this function if you want to manually increment the render Id*/
  36389. incrementRenderId(): void;
  36390. private _createUbo;
  36391. /**
  36392. * Use this method to simulate a pointer move on a mesh
  36393. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36394. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36395. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36396. * @returns the current scene
  36397. */
  36398. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36399. /**
  36400. * Use this method to simulate a pointer down on a mesh
  36401. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36402. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36403. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36404. * @returns the current scene
  36405. */
  36406. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36407. /**
  36408. * Use this method to simulate a pointer up on a mesh
  36409. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36410. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36411. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36412. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36413. * @returns the current scene
  36414. */
  36415. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36416. /**
  36417. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36418. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36419. * @returns true if the pointer was captured
  36420. */
  36421. isPointerCaptured(pointerId?: number): boolean;
  36422. /**
  36423. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36424. * @param attachUp defines if you want to attach events to pointerup
  36425. * @param attachDown defines if you want to attach events to pointerdown
  36426. * @param attachMove defines if you want to attach events to pointermove
  36427. */
  36428. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36429. /** Detaches all event handlers*/
  36430. detachControl(): void;
  36431. /**
  36432. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36433. * Delay loaded resources are not taking in account
  36434. * @return true if all required resources are ready
  36435. */
  36436. isReady(): boolean;
  36437. /** Resets all cached information relative to material (including effect and visibility) */
  36438. resetCachedMaterial(): void;
  36439. /**
  36440. * Registers a function to be called before every frame render
  36441. * @param func defines the function to register
  36442. */
  36443. registerBeforeRender(func: () => void): void;
  36444. /**
  36445. * Unregisters a function called before every frame render
  36446. * @param func defines the function to unregister
  36447. */
  36448. unregisterBeforeRender(func: () => void): void;
  36449. /**
  36450. * Registers a function to be called after every frame render
  36451. * @param func defines the function to register
  36452. */
  36453. registerAfterRender(func: () => void): void;
  36454. /**
  36455. * Unregisters a function called after every frame render
  36456. * @param func defines the function to unregister
  36457. */
  36458. unregisterAfterRender(func: () => void): void;
  36459. private _executeOnceBeforeRender;
  36460. /**
  36461. * The provided function will run before render once and will be disposed afterwards.
  36462. * A timeout delay can be provided so that the function will be executed in N ms.
  36463. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36464. * @param func The function to be executed.
  36465. * @param timeout optional delay in ms
  36466. */
  36467. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36468. /** @hidden */
  36469. _addPendingData(data: any): void;
  36470. /** @hidden */
  36471. _removePendingData(data: any): void;
  36472. /**
  36473. * Returns the number of items waiting to be loaded
  36474. * @returns the number of items waiting to be loaded
  36475. */
  36476. getWaitingItemsCount(): number;
  36477. /**
  36478. * Returns a boolean indicating if the scene is still loading data
  36479. */
  36480. get isLoading(): boolean;
  36481. /**
  36482. * Registers a function to be executed when the scene is ready
  36483. * @param {Function} func - the function to be executed
  36484. */
  36485. executeWhenReady(func: () => void): void;
  36486. /**
  36487. * Returns a promise that resolves when the scene is ready
  36488. * @returns A promise that resolves when the scene is ready
  36489. */
  36490. whenReadyAsync(): Promise<void>;
  36491. /** @hidden */
  36492. _checkIsReady(): void;
  36493. /**
  36494. * Gets all animatable attached to the scene
  36495. */
  36496. get animatables(): Animatable[];
  36497. /**
  36498. * Resets the last animation time frame.
  36499. * Useful to override when animations start running when loading a scene for the first time.
  36500. */
  36501. resetLastAnimationTimeFrame(): void;
  36502. /**
  36503. * Gets the current view matrix
  36504. * @returns a Matrix
  36505. */
  36506. getViewMatrix(): Matrix;
  36507. /**
  36508. * Gets the current projection matrix
  36509. * @returns a Matrix
  36510. */
  36511. getProjectionMatrix(): Matrix;
  36512. /**
  36513. * Gets the current transform matrix
  36514. * @returns a Matrix made of View * Projection
  36515. */
  36516. getTransformMatrix(): Matrix;
  36517. /**
  36518. * Sets the current transform matrix
  36519. * @param viewL defines the View matrix to use
  36520. * @param projectionL defines the Projection matrix to use
  36521. * @param viewR defines the right View matrix to use (if provided)
  36522. * @param projectionR defines the right Projection matrix to use (if provided)
  36523. */
  36524. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36525. /**
  36526. * Gets the uniform buffer used to store scene data
  36527. * @returns a UniformBuffer
  36528. */
  36529. getSceneUniformBuffer(): UniformBuffer;
  36530. /**
  36531. * Gets an unique (relatively to the current scene) Id
  36532. * @returns an unique number for the scene
  36533. */
  36534. getUniqueId(): number;
  36535. /**
  36536. * Add a mesh to the list of scene's meshes
  36537. * @param newMesh defines the mesh to add
  36538. * @param recursive if all child meshes should also be added to the scene
  36539. */
  36540. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36541. /**
  36542. * Remove a mesh for the list of scene's meshes
  36543. * @param toRemove defines the mesh to remove
  36544. * @param recursive if all child meshes should also be removed from the scene
  36545. * @returns the index where the mesh was in the mesh list
  36546. */
  36547. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36548. /**
  36549. * Add a transform node to the list of scene's transform nodes
  36550. * @param newTransformNode defines the transform node to add
  36551. */
  36552. addTransformNode(newTransformNode: TransformNode): void;
  36553. /**
  36554. * Remove a transform node for the list of scene's transform nodes
  36555. * @param toRemove defines the transform node to remove
  36556. * @returns the index where the transform node was in the transform node list
  36557. */
  36558. removeTransformNode(toRemove: TransformNode): number;
  36559. /**
  36560. * Remove a skeleton for the list of scene's skeletons
  36561. * @param toRemove defines the skeleton to remove
  36562. * @returns the index where the skeleton was in the skeleton list
  36563. */
  36564. removeSkeleton(toRemove: Skeleton): number;
  36565. /**
  36566. * Remove a morph target for the list of scene's morph targets
  36567. * @param toRemove defines the morph target to remove
  36568. * @returns the index where the morph target was in the morph target list
  36569. */
  36570. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36571. /**
  36572. * Remove a light for the list of scene's lights
  36573. * @param toRemove defines the light to remove
  36574. * @returns the index where the light was in the light list
  36575. */
  36576. removeLight(toRemove: Light): number;
  36577. /**
  36578. * Remove a camera for the list of scene's cameras
  36579. * @param toRemove defines the camera to remove
  36580. * @returns the index where the camera was in the camera list
  36581. */
  36582. removeCamera(toRemove: Camera): number;
  36583. /**
  36584. * Remove a particle system for the list of scene's particle systems
  36585. * @param toRemove defines the particle system to remove
  36586. * @returns the index where the particle system was in the particle system list
  36587. */
  36588. removeParticleSystem(toRemove: IParticleSystem): number;
  36589. /**
  36590. * Remove a animation for the list of scene's animations
  36591. * @param toRemove defines the animation to remove
  36592. * @returns the index where the animation was in the animation list
  36593. */
  36594. removeAnimation(toRemove: Animation): number;
  36595. /**
  36596. * Will stop the animation of the given target
  36597. * @param target - the target
  36598. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36599. * @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)
  36600. */
  36601. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36602. /**
  36603. * Removes the given animation group from this scene.
  36604. * @param toRemove The animation group to remove
  36605. * @returns The index of the removed animation group
  36606. */
  36607. removeAnimationGroup(toRemove: AnimationGroup): number;
  36608. /**
  36609. * Removes the given multi-material from this scene.
  36610. * @param toRemove The multi-material to remove
  36611. * @returns The index of the removed multi-material
  36612. */
  36613. removeMultiMaterial(toRemove: MultiMaterial): number;
  36614. /**
  36615. * Removes the given material from this scene.
  36616. * @param toRemove The material to remove
  36617. * @returns The index of the removed material
  36618. */
  36619. removeMaterial(toRemove: Material): number;
  36620. /**
  36621. * Removes the given action manager from this scene.
  36622. * @param toRemove The action manager to remove
  36623. * @returns The index of the removed action manager
  36624. */
  36625. removeActionManager(toRemove: AbstractActionManager): number;
  36626. /**
  36627. * Removes the given texture from this scene.
  36628. * @param toRemove The texture to remove
  36629. * @returns The index of the removed texture
  36630. */
  36631. removeTexture(toRemove: BaseTexture): number;
  36632. /**
  36633. * Adds the given light to this scene
  36634. * @param newLight The light to add
  36635. */
  36636. addLight(newLight: Light): void;
  36637. /**
  36638. * Sorts the list list based on light priorities
  36639. */
  36640. sortLightsByPriority(): void;
  36641. /**
  36642. * Adds the given camera to this scene
  36643. * @param newCamera The camera to add
  36644. */
  36645. addCamera(newCamera: Camera): void;
  36646. /**
  36647. * Adds the given skeleton to this scene
  36648. * @param newSkeleton The skeleton to add
  36649. */
  36650. addSkeleton(newSkeleton: Skeleton): void;
  36651. /**
  36652. * Adds the given particle system to this scene
  36653. * @param newParticleSystem The particle system to add
  36654. */
  36655. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36656. /**
  36657. * Adds the given animation to this scene
  36658. * @param newAnimation The animation to add
  36659. */
  36660. addAnimation(newAnimation: Animation): void;
  36661. /**
  36662. * Adds the given animation group to this scene.
  36663. * @param newAnimationGroup The animation group to add
  36664. */
  36665. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36666. /**
  36667. * Adds the given multi-material to this scene
  36668. * @param newMultiMaterial The multi-material to add
  36669. */
  36670. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36671. /**
  36672. * Adds the given material to this scene
  36673. * @param newMaterial The material to add
  36674. */
  36675. addMaterial(newMaterial: Material): void;
  36676. /**
  36677. * Adds the given morph target to this scene
  36678. * @param newMorphTargetManager The morph target to add
  36679. */
  36680. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36681. /**
  36682. * Adds the given geometry to this scene
  36683. * @param newGeometry The geometry to add
  36684. */
  36685. addGeometry(newGeometry: Geometry): void;
  36686. /**
  36687. * Adds the given action manager to this scene
  36688. * @param newActionManager The action manager to add
  36689. */
  36690. addActionManager(newActionManager: AbstractActionManager): void;
  36691. /**
  36692. * Adds the given texture to this scene.
  36693. * @param newTexture The texture to add
  36694. */
  36695. addTexture(newTexture: BaseTexture): void;
  36696. /**
  36697. * Switch active camera
  36698. * @param newCamera defines the new active camera
  36699. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36700. */
  36701. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36702. /**
  36703. * sets the active camera of the scene using its ID
  36704. * @param id defines the camera's ID
  36705. * @return the new active camera or null if none found.
  36706. */
  36707. setActiveCameraByID(id: string): Nullable<Camera>;
  36708. /**
  36709. * sets the active camera of the scene using its name
  36710. * @param name defines the camera's name
  36711. * @returns the new active camera or null if none found.
  36712. */
  36713. setActiveCameraByName(name: string): Nullable<Camera>;
  36714. /**
  36715. * get an animation group using its name
  36716. * @param name defines the material's name
  36717. * @return the animation group or null if none found.
  36718. */
  36719. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36720. /**
  36721. * Get a material using its unique id
  36722. * @param uniqueId defines the material's unique id
  36723. * @return the material or null if none found.
  36724. */
  36725. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36726. /**
  36727. * get a material using its id
  36728. * @param id defines the material's ID
  36729. * @return the material or null if none found.
  36730. */
  36731. getMaterialByID(id: string): Nullable<Material>;
  36732. /**
  36733. * Gets a the last added material using a given id
  36734. * @param id defines the material's ID
  36735. * @return the last material with the given id or null if none found.
  36736. */
  36737. getLastMaterialByID(id: string): Nullable<Material>;
  36738. /**
  36739. * Gets a material using its name
  36740. * @param name defines the material's name
  36741. * @return the material or null if none found.
  36742. */
  36743. getMaterialByName(name: string): Nullable<Material>;
  36744. /**
  36745. * Get a texture using its unique id
  36746. * @param uniqueId defines the texture's unique id
  36747. * @return the texture or null if none found.
  36748. */
  36749. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36750. /**
  36751. * Gets a camera using its id
  36752. * @param id defines the id to look for
  36753. * @returns the camera or null if not found
  36754. */
  36755. getCameraByID(id: string): Nullable<Camera>;
  36756. /**
  36757. * Gets a camera using its unique id
  36758. * @param uniqueId defines the unique id to look for
  36759. * @returns the camera or null if not found
  36760. */
  36761. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36762. /**
  36763. * Gets a camera using its name
  36764. * @param name defines the camera's name
  36765. * @return the camera or null if none found.
  36766. */
  36767. getCameraByName(name: string): Nullable<Camera>;
  36768. /**
  36769. * Gets a bone using its id
  36770. * @param id defines the bone's id
  36771. * @return the bone or null if not found
  36772. */
  36773. getBoneByID(id: string): Nullable<Bone>;
  36774. /**
  36775. * Gets a bone using its id
  36776. * @param name defines the bone's name
  36777. * @return the bone or null if not found
  36778. */
  36779. getBoneByName(name: string): Nullable<Bone>;
  36780. /**
  36781. * Gets a light node using its name
  36782. * @param name defines the the light's name
  36783. * @return the light or null if none found.
  36784. */
  36785. getLightByName(name: string): Nullable<Light>;
  36786. /**
  36787. * Gets a light node using its id
  36788. * @param id defines the light's id
  36789. * @return the light or null if none found.
  36790. */
  36791. getLightByID(id: string): Nullable<Light>;
  36792. /**
  36793. * Gets a light node using its scene-generated unique ID
  36794. * @param uniqueId defines the light's unique id
  36795. * @return the light or null if none found.
  36796. */
  36797. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36798. /**
  36799. * Gets a particle system by id
  36800. * @param id defines the particle system id
  36801. * @return the corresponding system or null if none found
  36802. */
  36803. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36804. /**
  36805. * Gets a geometry using its ID
  36806. * @param id defines the geometry's id
  36807. * @return the geometry or null if none found.
  36808. */
  36809. getGeometryByID(id: string): Nullable<Geometry>;
  36810. private _getGeometryByUniqueID;
  36811. /**
  36812. * Add a new geometry to this scene
  36813. * @param geometry defines the geometry to be added to the scene.
  36814. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36815. * @return a boolean defining if the geometry was added or not
  36816. */
  36817. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36818. /**
  36819. * Removes an existing geometry
  36820. * @param geometry defines the geometry to be removed from the scene
  36821. * @return a boolean defining if the geometry was removed or not
  36822. */
  36823. removeGeometry(geometry: Geometry): boolean;
  36824. /**
  36825. * Gets the list of geometries attached to the scene
  36826. * @returns an array of Geometry
  36827. */
  36828. getGeometries(): Geometry[];
  36829. /**
  36830. * Gets the first added mesh found of a given ID
  36831. * @param id defines the id to search for
  36832. * @return the mesh found or null if not found at all
  36833. */
  36834. getMeshByID(id: string): Nullable<AbstractMesh>;
  36835. /**
  36836. * Gets a list of meshes using their id
  36837. * @param id defines the id to search for
  36838. * @returns a list of meshes
  36839. */
  36840. getMeshesByID(id: string): Array<AbstractMesh>;
  36841. /**
  36842. * Gets the first added transform node found of a given ID
  36843. * @param id defines the id to search for
  36844. * @return the found transform node or null if not found at all.
  36845. */
  36846. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36847. /**
  36848. * Gets a transform node with its auto-generated unique id
  36849. * @param uniqueId efines the unique id to search for
  36850. * @return the found transform node or null if not found at all.
  36851. */
  36852. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36853. /**
  36854. * Gets a list of transform nodes using their id
  36855. * @param id defines the id to search for
  36856. * @returns a list of transform nodes
  36857. */
  36858. getTransformNodesByID(id: string): Array<TransformNode>;
  36859. /**
  36860. * Gets a mesh with its auto-generated unique id
  36861. * @param uniqueId defines the unique id to search for
  36862. * @return the found mesh or null if not found at all.
  36863. */
  36864. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36865. /**
  36866. * Gets a the last added mesh using a given id
  36867. * @param id defines the id to search for
  36868. * @return the found mesh or null if not found at all.
  36869. */
  36870. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36871. /**
  36872. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36873. * @param id defines the id to search for
  36874. * @return the found node or null if not found at all
  36875. */
  36876. getLastEntryByID(id: string): Nullable<Node>;
  36877. /**
  36878. * Gets a node (Mesh, Camera, Light) using a given id
  36879. * @param id defines the id to search for
  36880. * @return the found node or null if not found at all
  36881. */
  36882. getNodeByID(id: string): Nullable<Node>;
  36883. /**
  36884. * Gets a node (Mesh, Camera, Light) using a given name
  36885. * @param name defines the name to search for
  36886. * @return the found node or null if not found at all.
  36887. */
  36888. getNodeByName(name: string): Nullable<Node>;
  36889. /**
  36890. * Gets a mesh using a given name
  36891. * @param name defines the name to search for
  36892. * @return the found mesh or null if not found at all.
  36893. */
  36894. getMeshByName(name: string): Nullable<AbstractMesh>;
  36895. /**
  36896. * Gets a transform node using a given name
  36897. * @param name defines the name to search for
  36898. * @return the found transform node or null if not found at all.
  36899. */
  36900. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36901. /**
  36902. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36903. * @param id defines the id to search for
  36904. * @return the found skeleton or null if not found at all.
  36905. */
  36906. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36907. /**
  36908. * Gets a skeleton using a given auto generated unique id
  36909. * @param uniqueId defines the unique id to search for
  36910. * @return the found skeleton or null if not found at all.
  36911. */
  36912. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36913. /**
  36914. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36915. * @param id defines the id to search for
  36916. * @return the found skeleton or null if not found at all.
  36917. */
  36918. getSkeletonById(id: string): Nullable<Skeleton>;
  36919. /**
  36920. * Gets a skeleton using a given name
  36921. * @param name defines the name to search for
  36922. * @return the found skeleton or null if not found at all.
  36923. */
  36924. getSkeletonByName(name: string): Nullable<Skeleton>;
  36925. /**
  36926. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36927. * @param id defines the id to search for
  36928. * @return the found morph target manager or null if not found at all.
  36929. */
  36930. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36931. /**
  36932. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36933. * @param id defines the id to search for
  36934. * @return the found morph target or null if not found at all.
  36935. */
  36936. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36937. /**
  36938. * Gets a boolean indicating if the given mesh is active
  36939. * @param mesh defines the mesh to look for
  36940. * @returns true if the mesh is in the active list
  36941. */
  36942. isActiveMesh(mesh: AbstractMesh): boolean;
  36943. /**
  36944. * Return a unique id as a string which can serve as an identifier for the scene
  36945. */
  36946. get uid(): string;
  36947. /**
  36948. * Add an externaly attached data from its key.
  36949. * This method call will fail and return false, if such key already exists.
  36950. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  36951. * @param key the unique key that identifies the data
  36952. * @param data the data object to associate to the key for this Engine instance
  36953. * @return true if no such key were already present and the data was added successfully, false otherwise
  36954. */
  36955. addExternalData<T>(key: string, data: T): boolean;
  36956. /**
  36957. * Get an externaly attached data from its key
  36958. * @param key the unique key that identifies the data
  36959. * @return the associated data, if present (can be null), or undefined if not present
  36960. */
  36961. getExternalData<T>(key: string): Nullable<T>;
  36962. /**
  36963. * Get an externaly attached data from its key, create it using a factory if it's not already present
  36964. * @param key the unique key that identifies the data
  36965. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  36966. * @return the associated data, can be null if the factory returned null.
  36967. */
  36968. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  36969. /**
  36970. * Remove an externaly attached data from the Engine instance
  36971. * @param key the unique key that identifies the data
  36972. * @return true if the data was successfully removed, false if it doesn't exist
  36973. */
  36974. removeExternalData(key: string): boolean;
  36975. private _evaluateSubMesh;
  36976. /**
  36977. * Clear the processed materials smart array preventing retention point in material dispose.
  36978. */
  36979. freeProcessedMaterials(): void;
  36980. private _preventFreeActiveMeshesAndRenderingGroups;
  36981. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  36982. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  36983. * when disposing several meshes in a row or a hierarchy of meshes.
  36984. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  36985. */
  36986. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  36987. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  36988. /**
  36989. * Clear the active meshes smart array preventing retention point in mesh dispose.
  36990. */
  36991. freeActiveMeshes(): void;
  36992. /**
  36993. * Clear the info related to rendering groups preventing retention points during dispose.
  36994. */
  36995. freeRenderingGroups(): void;
  36996. /** @hidden */
  36997. _isInIntermediateRendering(): boolean;
  36998. /**
  36999. * Lambda returning the list of potentially active meshes.
  37000. */
  37001. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37002. /**
  37003. * Lambda returning the list of potentially active sub meshes.
  37004. */
  37005. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37006. /**
  37007. * Lambda returning the list of potentially intersecting sub meshes.
  37008. */
  37009. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37010. /**
  37011. * Lambda returning the list of potentially colliding sub meshes.
  37012. */
  37013. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37014. private _activeMeshesFrozen;
  37015. private _skipEvaluateActiveMeshesCompletely;
  37016. /**
  37017. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37018. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37019. * @returns the current scene
  37020. */
  37021. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37022. /**
  37023. * Use this function to restart evaluating active meshes on every frame
  37024. * @returns the current scene
  37025. */
  37026. unfreezeActiveMeshes(): Scene;
  37027. private _evaluateActiveMeshes;
  37028. private _activeMesh;
  37029. /**
  37030. * Update the transform matrix to update from the current active camera
  37031. * @param force defines a boolean used to force the update even if cache is up to date
  37032. */
  37033. updateTransformMatrix(force?: boolean): void;
  37034. private _bindFrameBuffer;
  37035. /** @hidden */
  37036. _allowPostProcessClearColor: boolean;
  37037. /** @hidden */
  37038. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37039. private _processSubCameras;
  37040. private _checkIntersections;
  37041. /** @hidden */
  37042. _advancePhysicsEngineStep(step: number): void;
  37043. /**
  37044. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37045. */
  37046. getDeterministicFrameTime: () => number;
  37047. /** @hidden */
  37048. _animate(): void;
  37049. /** Execute all animations (for a frame) */
  37050. animate(): void;
  37051. /**
  37052. * Render the scene
  37053. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37054. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37055. */
  37056. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37057. /**
  37058. * Freeze all materials
  37059. * A frozen material will not be updatable but should be faster to render
  37060. */
  37061. freezeMaterials(): void;
  37062. /**
  37063. * Unfreeze all materials
  37064. * A frozen material will not be updatable but should be faster to render
  37065. */
  37066. unfreezeMaterials(): void;
  37067. /**
  37068. * Releases all held ressources
  37069. */
  37070. dispose(): void;
  37071. /**
  37072. * Gets if the scene is already disposed
  37073. */
  37074. get isDisposed(): boolean;
  37075. /**
  37076. * Call this function to reduce memory footprint of the scene.
  37077. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37078. */
  37079. clearCachedVertexData(): void;
  37080. /**
  37081. * This function will remove the local cached buffer data from texture.
  37082. * It will save memory but will prevent the texture from being rebuilt
  37083. */
  37084. cleanCachedTextureBuffer(): void;
  37085. /**
  37086. * Get the world extend vectors with an optional filter
  37087. *
  37088. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37089. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37090. */
  37091. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37092. min: Vector3;
  37093. max: Vector3;
  37094. };
  37095. /**
  37096. * Creates a ray that can be used to pick in the scene
  37097. * @param x defines the x coordinate of the origin (on-screen)
  37098. * @param y defines the y coordinate of the origin (on-screen)
  37099. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37100. * @param camera defines the camera to use for the picking
  37101. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37102. * @returns a Ray
  37103. */
  37104. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37105. /**
  37106. * Creates a ray that can be used to pick in the scene
  37107. * @param x defines the x coordinate of the origin (on-screen)
  37108. * @param y defines the y coordinate of the origin (on-screen)
  37109. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37110. * @param result defines the ray where to store the picking ray
  37111. * @param camera defines the camera to use for the picking
  37112. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37113. * @returns the current scene
  37114. */
  37115. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37116. /**
  37117. * Creates a ray that can be used to pick in the scene
  37118. * @param x defines the x coordinate of the origin (on-screen)
  37119. * @param y defines the y coordinate of the origin (on-screen)
  37120. * @param camera defines the camera to use for the picking
  37121. * @returns a Ray
  37122. */
  37123. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37124. /**
  37125. * Creates a ray that can be used to pick in the scene
  37126. * @param x defines the x coordinate of the origin (on-screen)
  37127. * @param y defines the y coordinate of the origin (on-screen)
  37128. * @param result defines the ray where to store the picking ray
  37129. * @param camera defines the camera to use for the picking
  37130. * @returns the current scene
  37131. */
  37132. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37133. /** Launch a ray to try to pick a mesh in the scene
  37134. * @param x position on screen
  37135. * @param y position on screen
  37136. * @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
  37137. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37138. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37139. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37140. * @returns a PickingInfo
  37141. */
  37142. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37143. /** Use the given ray to pick a mesh in the scene
  37144. * @param ray The ray to use to pick meshes
  37145. * @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
  37146. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37147. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37148. * @returns a PickingInfo
  37149. */
  37150. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37151. /**
  37152. * Launch a ray to try to pick a mesh in the scene
  37153. * @param x X position on screen
  37154. * @param y Y position on screen
  37155. * @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
  37156. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37157. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37158. * @returns an array of PickingInfo
  37159. */
  37160. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37161. /**
  37162. * Launch a ray to try to pick a mesh in the scene
  37163. * @param ray Ray to use
  37164. * @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
  37165. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37166. * @returns an array of PickingInfo
  37167. */
  37168. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37169. /**
  37170. * Force the value of meshUnderPointer
  37171. * @param mesh defines the mesh to use
  37172. */
  37173. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37174. /**
  37175. * Gets the mesh under the pointer
  37176. * @returns a Mesh or null if no mesh is under the pointer
  37177. */
  37178. getPointerOverMesh(): Nullable<AbstractMesh>;
  37179. /** @hidden */
  37180. _rebuildGeometries(): void;
  37181. /** @hidden */
  37182. _rebuildTextures(): void;
  37183. private _getByTags;
  37184. /**
  37185. * Get a list of meshes by tags
  37186. * @param tagsQuery defines the tags query to use
  37187. * @param forEach defines a predicate used to filter results
  37188. * @returns an array of Mesh
  37189. */
  37190. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37191. /**
  37192. * Get a list of cameras by tags
  37193. * @param tagsQuery defines the tags query to use
  37194. * @param forEach defines a predicate used to filter results
  37195. * @returns an array of Camera
  37196. */
  37197. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37198. /**
  37199. * Get a list of lights by tags
  37200. * @param tagsQuery defines the tags query to use
  37201. * @param forEach defines a predicate used to filter results
  37202. * @returns an array of Light
  37203. */
  37204. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37205. /**
  37206. * Get a list of materials by tags
  37207. * @param tagsQuery defines the tags query to use
  37208. * @param forEach defines a predicate used to filter results
  37209. * @returns an array of Material
  37210. */
  37211. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37212. /**
  37213. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37214. * This allowed control for front to back rendering or reversly depending of the special needs.
  37215. *
  37216. * @param renderingGroupId The rendering group id corresponding to its index
  37217. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37218. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37219. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37220. */
  37221. 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;
  37222. /**
  37223. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37224. *
  37225. * @param renderingGroupId The rendering group id corresponding to its index
  37226. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37227. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37228. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37229. */
  37230. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37231. /**
  37232. * Gets the current auto clear configuration for one rendering group of the rendering
  37233. * manager.
  37234. * @param index the rendering group index to get the information for
  37235. * @returns The auto clear setup for the requested rendering group
  37236. */
  37237. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37238. private _blockMaterialDirtyMechanism;
  37239. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37240. get blockMaterialDirtyMechanism(): boolean;
  37241. set blockMaterialDirtyMechanism(value: boolean);
  37242. /**
  37243. * Will flag all materials as dirty to trigger new shader compilation
  37244. * @param flag defines the flag used to specify which material part must be marked as dirty
  37245. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37246. */
  37247. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37248. /** @hidden */
  37249. _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;
  37250. /** @hidden */
  37251. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37252. /** @hidden */
  37253. _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;
  37254. /** @hidden */
  37255. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37256. /** @hidden */
  37257. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37258. /** @hidden */
  37259. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37260. }
  37261. }
  37262. declare module BABYLON {
  37263. /**
  37264. * Set of assets to keep when moving a scene into an asset container.
  37265. */
  37266. export class KeepAssets extends AbstractScene {
  37267. }
  37268. /**
  37269. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37270. */
  37271. export class InstantiatedEntries {
  37272. /**
  37273. * List of new root nodes (eg. nodes with no parent)
  37274. */
  37275. rootNodes: TransformNode[];
  37276. /**
  37277. * List of new skeletons
  37278. */
  37279. skeletons: Skeleton[];
  37280. /**
  37281. * List of new animation groups
  37282. */
  37283. animationGroups: AnimationGroup[];
  37284. }
  37285. /**
  37286. * Container with a set of assets that can be added or removed from a scene.
  37287. */
  37288. export class AssetContainer extends AbstractScene {
  37289. private _wasAddedToScene;
  37290. /**
  37291. * The scene the AssetContainer belongs to.
  37292. */
  37293. scene: Scene;
  37294. /**
  37295. * Instantiates an AssetContainer.
  37296. * @param scene The scene the AssetContainer belongs to.
  37297. */
  37298. constructor(scene: Scene);
  37299. /**
  37300. * Instantiate or clone all meshes and add the new ones to the scene.
  37301. * Skeletons and animation groups will all be cloned
  37302. * @param nameFunction defines an optional function used to get new names for clones
  37303. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37304. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37305. */
  37306. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37307. /**
  37308. * Adds all the assets from the container to the scene.
  37309. */
  37310. addAllToScene(): void;
  37311. /**
  37312. * Removes all the assets in the container from the scene
  37313. */
  37314. removeAllFromScene(): void;
  37315. /**
  37316. * Disposes all the assets in the container
  37317. */
  37318. dispose(): void;
  37319. private _moveAssets;
  37320. /**
  37321. * Removes all the assets contained in the scene and adds them to the container.
  37322. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37323. */
  37324. moveAllFromScene(keepAssets?: KeepAssets): void;
  37325. /**
  37326. * 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.
  37327. * @returns the root mesh
  37328. */
  37329. createRootMesh(): Mesh;
  37330. /**
  37331. * Merge animations from this asset container into a scene
  37332. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37333. * @param animatables set of animatables to retarget to a node from the scene
  37334. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37335. */
  37336. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37337. }
  37338. }
  37339. declare module BABYLON {
  37340. /**
  37341. * Defines how the parser contract is defined.
  37342. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37343. */
  37344. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37345. /**
  37346. * Defines how the individual parser contract is defined.
  37347. * These parser can parse an individual asset
  37348. */
  37349. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37350. /**
  37351. * Base class of the scene acting as a container for the different elements composing a scene.
  37352. * This class is dynamically extended by the different components of the scene increasing
  37353. * flexibility and reducing coupling
  37354. */
  37355. export abstract class AbstractScene {
  37356. /**
  37357. * Stores the list of available parsers in the application.
  37358. */
  37359. private static _BabylonFileParsers;
  37360. /**
  37361. * Stores the list of available individual parsers in the application.
  37362. */
  37363. private static _IndividualBabylonFileParsers;
  37364. /**
  37365. * Adds a parser in the list of available ones
  37366. * @param name Defines the name of the parser
  37367. * @param parser Defines the parser to add
  37368. */
  37369. static AddParser(name: string, parser: BabylonFileParser): void;
  37370. /**
  37371. * Gets a general parser from the list of avaialble ones
  37372. * @param name Defines the name of the parser
  37373. * @returns the requested parser or null
  37374. */
  37375. static GetParser(name: string): Nullable<BabylonFileParser>;
  37376. /**
  37377. * Adds n individual parser in the list of available ones
  37378. * @param name Defines the name of the parser
  37379. * @param parser Defines the parser to add
  37380. */
  37381. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37382. /**
  37383. * Gets an individual parser from the list of avaialble ones
  37384. * @param name Defines the name of the parser
  37385. * @returns the requested parser or null
  37386. */
  37387. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37388. /**
  37389. * Parser json data and populate both a scene and its associated container object
  37390. * @param jsonData Defines the data to parse
  37391. * @param scene Defines the scene to parse the data for
  37392. * @param container Defines the container attached to the parsing sequence
  37393. * @param rootUrl Defines the root url of the data
  37394. */
  37395. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37396. /**
  37397. * Gets the list of root nodes (ie. nodes with no parent)
  37398. */
  37399. rootNodes: Node[];
  37400. /** All of the cameras added to this scene
  37401. * @see http://doc.babylonjs.com/babylon101/cameras
  37402. */
  37403. cameras: Camera[];
  37404. /**
  37405. * All of the lights added to this scene
  37406. * @see http://doc.babylonjs.com/babylon101/lights
  37407. */
  37408. lights: Light[];
  37409. /**
  37410. * All of the (abstract) meshes added to this scene
  37411. */
  37412. meshes: AbstractMesh[];
  37413. /**
  37414. * The list of skeletons added to the scene
  37415. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37416. */
  37417. skeletons: Skeleton[];
  37418. /**
  37419. * All of the particle systems added to this scene
  37420. * @see http://doc.babylonjs.com/babylon101/particles
  37421. */
  37422. particleSystems: IParticleSystem[];
  37423. /**
  37424. * Gets a list of Animations associated with the scene
  37425. */
  37426. animations: Animation[];
  37427. /**
  37428. * All of the animation groups added to this scene
  37429. * @see http://doc.babylonjs.com/how_to/group
  37430. */
  37431. animationGroups: AnimationGroup[];
  37432. /**
  37433. * All of the multi-materials added to this scene
  37434. * @see http://doc.babylonjs.com/how_to/multi_materials
  37435. */
  37436. multiMaterials: MultiMaterial[];
  37437. /**
  37438. * All of the materials added to this scene
  37439. * In the context of a Scene, it is not supposed to be modified manually.
  37440. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37441. * Note also that the order of the Material within the array is not significant and might change.
  37442. * @see http://doc.babylonjs.com/babylon101/materials
  37443. */
  37444. materials: Material[];
  37445. /**
  37446. * The list of morph target managers added to the scene
  37447. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37448. */
  37449. morphTargetManagers: MorphTargetManager[];
  37450. /**
  37451. * The list of geometries used in the scene.
  37452. */
  37453. geometries: Geometry[];
  37454. /**
  37455. * All of the tranform nodes added to this scene
  37456. * In the context of a Scene, it is not supposed to be modified manually.
  37457. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37458. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37459. * @see http://doc.babylonjs.com/how_to/transformnode
  37460. */
  37461. transformNodes: TransformNode[];
  37462. /**
  37463. * ActionManagers available on the scene.
  37464. */
  37465. actionManagers: AbstractActionManager[];
  37466. /**
  37467. * Textures to keep.
  37468. */
  37469. textures: BaseTexture[];
  37470. /**
  37471. * Environment texture for the scene
  37472. */
  37473. environmentTexture: Nullable<BaseTexture>;
  37474. /**
  37475. * @returns all meshes, lights, cameras, transformNodes and bones
  37476. */
  37477. getNodes(): Array<Node>;
  37478. }
  37479. }
  37480. declare module BABYLON {
  37481. /**
  37482. * Interface used to define options for Sound class
  37483. */
  37484. export interface ISoundOptions {
  37485. /**
  37486. * Does the sound autoplay once loaded.
  37487. */
  37488. autoplay?: boolean;
  37489. /**
  37490. * Does the sound loop after it finishes playing once.
  37491. */
  37492. loop?: boolean;
  37493. /**
  37494. * Sound's volume
  37495. */
  37496. volume?: number;
  37497. /**
  37498. * Is it a spatial sound?
  37499. */
  37500. spatialSound?: boolean;
  37501. /**
  37502. * Maximum distance to hear that sound
  37503. */
  37504. maxDistance?: number;
  37505. /**
  37506. * Uses user defined attenuation function
  37507. */
  37508. useCustomAttenuation?: boolean;
  37509. /**
  37510. * Define the roll off factor of spatial sounds.
  37511. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37512. */
  37513. rolloffFactor?: number;
  37514. /**
  37515. * Define the reference distance the sound should be heard perfectly.
  37516. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37517. */
  37518. refDistance?: number;
  37519. /**
  37520. * Define the distance attenuation model the sound will follow.
  37521. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37522. */
  37523. distanceModel?: string;
  37524. /**
  37525. * Defines the playback speed (1 by default)
  37526. */
  37527. playbackRate?: number;
  37528. /**
  37529. * Defines if the sound is from a streaming source
  37530. */
  37531. streaming?: boolean;
  37532. /**
  37533. * Defines an optional length (in seconds) inside the sound file
  37534. */
  37535. length?: number;
  37536. /**
  37537. * Defines an optional offset (in seconds) inside the sound file
  37538. */
  37539. offset?: number;
  37540. /**
  37541. * If true, URLs will not be required to state the audio file codec to use.
  37542. */
  37543. skipCodecCheck?: boolean;
  37544. }
  37545. /**
  37546. * Defines a sound that can be played in the application.
  37547. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37548. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37549. */
  37550. export class Sound {
  37551. /**
  37552. * The name of the sound in the scene.
  37553. */
  37554. name: string;
  37555. /**
  37556. * Does the sound autoplay once loaded.
  37557. */
  37558. autoplay: boolean;
  37559. /**
  37560. * Does the sound loop after it finishes playing once.
  37561. */
  37562. loop: boolean;
  37563. /**
  37564. * Does the sound use a custom attenuation curve to simulate the falloff
  37565. * happening when the source gets further away from the camera.
  37566. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37567. */
  37568. useCustomAttenuation: boolean;
  37569. /**
  37570. * The sound track id this sound belongs to.
  37571. */
  37572. soundTrackId: number;
  37573. /**
  37574. * Is this sound currently played.
  37575. */
  37576. isPlaying: boolean;
  37577. /**
  37578. * Is this sound currently paused.
  37579. */
  37580. isPaused: boolean;
  37581. /**
  37582. * Does this sound enables spatial sound.
  37583. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37584. */
  37585. spatialSound: boolean;
  37586. /**
  37587. * Define the reference distance the sound should be heard perfectly.
  37588. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37589. */
  37590. refDistance: number;
  37591. /**
  37592. * Define the roll off factor of spatial sounds.
  37593. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37594. */
  37595. rolloffFactor: number;
  37596. /**
  37597. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37598. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37599. */
  37600. maxDistance: number;
  37601. /**
  37602. * Define the distance attenuation model the sound will follow.
  37603. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37604. */
  37605. distanceModel: string;
  37606. /**
  37607. * @hidden
  37608. * Back Compat
  37609. **/
  37610. onended: () => any;
  37611. /**
  37612. * Observable event when the current playing sound finishes.
  37613. */
  37614. onEndedObservable: Observable<Sound>;
  37615. private _panningModel;
  37616. private _playbackRate;
  37617. private _streaming;
  37618. private _startTime;
  37619. private _startOffset;
  37620. private _position;
  37621. /** @hidden */
  37622. _positionInEmitterSpace: boolean;
  37623. private _localDirection;
  37624. private _volume;
  37625. private _isReadyToPlay;
  37626. private _isDirectional;
  37627. private _readyToPlayCallback;
  37628. private _audioBuffer;
  37629. private _soundSource;
  37630. private _streamingSource;
  37631. private _soundPanner;
  37632. private _soundGain;
  37633. private _inputAudioNode;
  37634. private _outputAudioNode;
  37635. private _coneInnerAngle;
  37636. private _coneOuterAngle;
  37637. private _coneOuterGain;
  37638. private _scene;
  37639. private _connectedTransformNode;
  37640. private _customAttenuationFunction;
  37641. private _registerFunc;
  37642. private _isOutputConnected;
  37643. private _htmlAudioElement;
  37644. private _urlType;
  37645. private _length?;
  37646. private _offset?;
  37647. /** @hidden */
  37648. static _SceneComponentInitialization: (scene: Scene) => void;
  37649. /**
  37650. * Create a sound and attach it to a scene
  37651. * @param name Name of your sound
  37652. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37653. * @param scene defines the scene the sound belongs to
  37654. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37655. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37656. */
  37657. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37658. /**
  37659. * Release the sound and its associated resources
  37660. */
  37661. dispose(): void;
  37662. /**
  37663. * Gets if the sounds is ready to be played or not.
  37664. * @returns true if ready, otherwise false
  37665. */
  37666. isReady(): boolean;
  37667. private _soundLoaded;
  37668. /**
  37669. * Sets the data of the sound from an audiobuffer
  37670. * @param audioBuffer The audioBuffer containing the data
  37671. */
  37672. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37673. /**
  37674. * Updates the current sounds options such as maxdistance, loop...
  37675. * @param options A JSON object containing values named as the object properties
  37676. */
  37677. updateOptions(options: ISoundOptions): void;
  37678. private _createSpatialParameters;
  37679. private _updateSpatialParameters;
  37680. /**
  37681. * Switch the panning model to HRTF:
  37682. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37683. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37684. */
  37685. switchPanningModelToHRTF(): void;
  37686. /**
  37687. * Switch the panning model to Equal Power:
  37688. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37689. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37690. */
  37691. switchPanningModelToEqualPower(): void;
  37692. private _switchPanningModel;
  37693. /**
  37694. * Connect this sound to a sound track audio node like gain...
  37695. * @param soundTrackAudioNode the sound track audio node to connect to
  37696. */
  37697. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37698. /**
  37699. * Transform this sound into a directional source
  37700. * @param coneInnerAngle Size of the inner cone in degree
  37701. * @param coneOuterAngle Size of the outer cone in degree
  37702. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37703. */
  37704. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37705. /**
  37706. * Gets or sets the inner angle for the directional cone.
  37707. */
  37708. get directionalConeInnerAngle(): number;
  37709. /**
  37710. * Gets or sets the inner angle for the directional cone.
  37711. */
  37712. set directionalConeInnerAngle(value: number);
  37713. /**
  37714. * Gets or sets the outer angle for the directional cone.
  37715. */
  37716. get directionalConeOuterAngle(): number;
  37717. /**
  37718. * Gets or sets the outer angle for the directional cone.
  37719. */
  37720. set directionalConeOuterAngle(value: number);
  37721. /**
  37722. * Sets the position of the emitter if spatial sound is enabled
  37723. * @param newPosition Defines the new posisiton
  37724. */
  37725. setPosition(newPosition: Vector3): void;
  37726. /**
  37727. * Sets the local direction of the emitter if spatial sound is enabled
  37728. * @param newLocalDirection Defines the new local direction
  37729. */
  37730. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37731. private _updateDirection;
  37732. /** @hidden */
  37733. updateDistanceFromListener(): void;
  37734. /**
  37735. * Sets a new custom attenuation function for the sound.
  37736. * @param callback Defines the function used for the attenuation
  37737. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37738. */
  37739. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37740. /**
  37741. * Play the sound
  37742. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37743. * @param offset (optional) Start the sound at a specific time in seconds
  37744. * @param length (optional) Sound duration (in seconds)
  37745. */
  37746. play(time?: number, offset?: number, length?: number): void;
  37747. private _onended;
  37748. /**
  37749. * Stop the sound
  37750. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37751. */
  37752. stop(time?: number): void;
  37753. /**
  37754. * Put the sound in pause
  37755. */
  37756. pause(): void;
  37757. /**
  37758. * Sets a dedicated volume for this sounds
  37759. * @param newVolume Define the new volume of the sound
  37760. * @param time Define time for gradual change to new volume
  37761. */
  37762. setVolume(newVolume: number, time?: number): void;
  37763. /**
  37764. * Set the sound play back rate
  37765. * @param newPlaybackRate Define the playback rate the sound should be played at
  37766. */
  37767. setPlaybackRate(newPlaybackRate: number): void;
  37768. /**
  37769. * Gets the volume of the sound.
  37770. * @returns the volume of the sound
  37771. */
  37772. getVolume(): number;
  37773. /**
  37774. * Attach the sound to a dedicated mesh
  37775. * @param transformNode The transform node to connect the sound with
  37776. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37777. */
  37778. attachToMesh(transformNode: TransformNode): void;
  37779. /**
  37780. * Detach the sound from the previously attached mesh
  37781. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37782. */
  37783. detachFromMesh(): void;
  37784. private _onRegisterAfterWorldMatrixUpdate;
  37785. /**
  37786. * Clone the current sound in the scene.
  37787. * @returns the new sound clone
  37788. */
  37789. clone(): Nullable<Sound>;
  37790. /**
  37791. * Gets the current underlying audio buffer containing the data
  37792. * @returns the audio buffer
  37793. */
  37794. getAudioBuffer(): Nullable<AudioBuffer>;
  37795. /**
  37796. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  37797. * @returns the source node
  37798. */
  37799. getSoundSource(): Nullable<AudioBufferSourceNode>;
  37800. /**
  37801. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  37802. * @returns the gain node
  37803. */
  37804. getSoundGain(): Nullable<GainNode>;
  37805. /**
  37806. * Serializes the Sound in a JSON representation
  37807. * @returns the JSON representation of the sound
  37808. */
  37809. serialize(): any;
  37810. /**
  37811. * Parse a JSON representation of a sound to innstantiate in a given scene
  37812. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37813. * @param scene Define the scene the new parsed sound should be created in
  37814. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37815. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37816. * @returns the newly parsed sound
  37817. */
  37818. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37819. }
  37820. }
  37821. declare module BABYLON {
  37822. /**
  37823. * This defines an action helpful to play a defined sound on a triggered action.
  37824. */
  37825. export class PlaySoundAction extends Action {
  37826. private _sound;
  37827. /**
  37828. * Instantiate the action
  37829. * @param triggerOptions defines the trigger options
  37830. * @param sound defines the sound to play
  37831. * @param condition defines the trigger related conditions
  37832. */
  37833. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37834. /** @hidden */
  37835. _prepare(): void;
  37836. /**
  37837. * Execute the action and play the sound.
  37838. */
  37839. execute(): void;
  37840. /**
  37841. * Serializes the actions and its related information.
  37842. * @param parent defines the object to serialize in
  37843. * @returns the serialized object
  37844. */
  37845. serialize(parent: any): any;
  37846. }
  37847. /**
  37848. * This defines an action helpful to stop a defined sound on a triggered action.
  37849. */
  37850. export class StopSoundAction extends Action {
  37851. private _sound;
  37852. /**
  37853. * Instantiate the action
  37854. * @param triggerOptions defines the trigger options
  37855. * @param sound defines the sound to stop
  37856. * @param condition defines the trigger related conditions
  37857. */
  37858. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37859. /** @hidden */
  37860. _prepare(): void;
  37861. /**
  37862. * Execute the action and stop the sound.
  37863. */
  37864. execute(): void;
  37865. /**
  37866. * Serializes the actions and its related information.
  37867. * @param parent defines the object to serialize in
  37868. * @returns the serialized object
  37869. */
  37870. serialize(parent: any): any;
  37871. }
  37872. }
  37873. declare module BABYLON {
  37874. /**
  37875. * This defines an action responsible to change the value of a property
  37876. * by interpolating between its current value and the newly set one once triggered.
  37877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37878. */
  37879. export class InterpolateValueAction extends Action {
  37880. /**
  37881. * Defines the path of the property where the value should be interpolated
  37882. */
  37883. propertyPath: string;
  37884. /**
  37885. * Defines the target value at the end of the interpolation.
  37886. */
  37887. value: any;
  37888. /**
  37889. * Defines the time it will take for the property to interpolate to the value.
  37890. */
  37891. duration: number;
  37892. /**
  37893. * Defines if the other scene animations should be stopped when the action has been triggered
  37894. */
  37895. stopOtherAnimations?: boolean;
  37896. /**
  37897. * Defines a callback raised once the interpolation animation has been done.
  37898. */
  37899. onInterpolationDone?: () => void;
  37900. /**
  37901. * Observable triggered once the interpolation animation has been done.
  37902. */
  37903. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37904. private _target;
  37905. private _effectiveTarget;
  37906. private _property;
  37907. /**
  37908. * Instantiate the action
  37909. * @param triggerOptions defines the trigger options
  37910. * @param target defines the object containing the value to interpolate
  37911. * @param propertyPath defines the path to the property in the target object
  37912. * @param value defines the target value at the end of the interpolation
  37913. * @param duration deines the time it will take for the property to interpolate to the value.
  37914. * @param condition defines the trigger related conditions
  37915. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  37916. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  37917. */
  37918. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  37919. /** @hidden */
  37920. _prepare(): void;
  37921. /**
  37922. * Execute the action starts the value interpolation.
  37923. */
  37924. execute(): void;
  37925. /**
  37926. * Serializes the actions and its related information.
  37927. * @param parent defines the object to serialize in
  37928. * @returns the serialized object
  37929. */
  37930. serialize(parent: any): any;
  37931. }
  37932. }
  37933. declare module BABYLON {
  37934. /**
  37935. * Options allowed during the creation of a sound track.
  37936. */
  37937. export interface ISoundTrackOptions {
  37938. /**
  37939. * The volume the sound track should take during creation
  37940. */
  37941. volume?: number;
  37942. /**
  37943. * Define if the sound track is the main sound track of the scene
  37944. */
  37945. mainTrack?: boolean;
  37946. }
  37947. /**
  37948. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37949. * It will be also used in a future release to apply effects on a specific track.
  37950. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37951. */
  37952. export class SoundTrack {
  37953. /**
  37954. * The unique identifier of the sound track in the scene.
  37955. */
  37956. id: number;
  37957. /**
  37958. * The list of sounds included in the sound track.
  37959. */
  37960. soundCollection: Array<Sound>;
  37961. private _outputAudioNode;
  37962. private _scene;
  37963. private _connectedAnalyser;
  37964. private _options;
  37965. private _isInitialized;
  37966. /**
  37967. * Creates a new sound track.
  37968. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37969. * @param scene Define the scene the sound track belongs to
  37970. * @param options
  37971. */
  37972. constructor(scene: Scene, options?: ISoundTrackOptions);
  37973. private _initializeSoundTrackAudioGraph;
  37974. /**
  37975. * Release the sound track and its associated resources
  37976. */
  37977. dispose(): void;
  37978. /**
  37979. * Adds a sound to this sound track
  37980. * @param sound define the cound to add
  37981. * @ignoreNaming
  37982. */
  37983. AddSound(sound: Sound): void;
  37984. /**
  37985. * Removes a sound to this sound track
  37986. * @param sound define the cound to remove
  37987. * @ignoreNaming
  37988. */
  37989. RemoveSound(sound: Sound): void;
  37990. /**
  37991. * Set a global volume for the full sound track.
  37992. * @param newVolume Define the new volume of the sound track
  37993. */
  37994. setVolume(newVolume: number): void;
  37995. /**
  37996. * Switch the panning model to HRTF:
  37997. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37998. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37999. */
  38000. switchPanningModelToHRTF(): void;
  38001. /**
  38002. * Switch the panning model to Equal Power:
  38003. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38004. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38005. */
  38006. switchPanningModelToEqualPower(): void;
  38007. /**
  38008. * Connect the sound track to an audio analyser allowing some amazing
  38009. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38010. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38011. * @param analyser The analyser to connect to the engine
  38012. */
  38013. connectToAnalyser(analyser: Analyser): void;
  38014. }
  38015. }
  38016. declare module BABYLON {
  38017. interface AbstractScene {
  38018. /**
  38019. * The list of sounds used in the scene.
  38020. */
  38021. sounds: Nullable<Array<Sound>>;
  38022. }
  38023. interface Scene {
  38024. /**
  38025. * @hidden
  38026. * Backing field
  38027. */
  38028. _mainSoundTrack: SoundTrack;
  38029. /**
  38030. * The main sound track played by the scene.
  38031. * It cotains your primary collection of sounds.
  38032. */
  38033. mainSoundTrack: SoundTrack;
  38034. /**
  38035. * The list of sound tracks added to the scene
  38036. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38037. */
  38038. soundTracks: Nullable<Array<SoundTrack>>;
  38039. /**
  38040. * Gets a sound using a given name
  38041. * @param name defines the name to search for
  38042. * @return the found sound or null if not found at all.
  38043. */
  38044. getSoundByName(name: string): Nullable<Sound>;
  38045. /**
  38046. * Gets or sets if audio support is enabled
  38047. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38048. */
  38049. audioEnabled: boolean;
  38050. /**
  38051. * Gets or sets if audio will be output to headphones
  38052. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38053. */
  38054. headphone: boolean;
  38055. /**
  38056. * Gets or sets custom audio listener position provider
  38057. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38058. */
  38059. audioListenerPositionProvider: Nullable<() => Vector3>;
  38060. /**
  38061. * Gets or sets a refresh rate when using 3D audio positioning
  38062. */
  38063. audioPositioningRefreshRate: number;
  38064. }
  38065. /**
  38066. * Defines the sound scene component responsible to manage any sounds
  38067. * in a given scene.
  38068. */
  38069. export class AudioSceneComponent implements ISceneSerializableComponent {
  38070. /**
  38071. * The component name helpfull to identify the component in the list of scene components.
  38072. */
  38073. readonly name: string;
  38074. /**
  38075. * The scene the component belongs to.
  38076. */
  38077. scene: Scene;
  38078. private _audioEnabled;
  38079. /**
  38080. * Gets whether audio is enabled or not.
  38081. * Please use related enable/disable method to switch state.
  38082. */
  38083. get audioEnabled(): boolean;
  38084. private _headphone;
  38085. /**
  38086. * Gets whether audio is outputing to headphone or not.
  38087. * Please use the according Switch methods to change output.
  38088. */
  38089. get headphone(): boolean;
  38090. /**
  38091. * Gets or sets a refresh rate when using 3D audio positioning
  38092. */
  38093. audioPositioningRefreshRate: number;
  38094. private _audioListenerPositionProvider;
  38095. /**
  38096. * Gets the current audio listener position provider
  38097. */
  38098. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38099. /**
  38100. * Sets a custom listener position for all sounds in the scene
  38101. * By default, this is the position of the first active camera
  38102. */
  38103. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38104. /**
  38105. * Creates a new instance of the component for the given scene
  38106. * @param scene Defines the scene to register the component in
  38107. */
  38108. constructor(scene: Scene);
  38109. /**
  38110. * Registers the component in a given scene
  38111. */
  38112. register(): void;
  38113. /**
  38114. * Rebuilds the elements related to this component in case of
  38115. * context lost for instance.
  38116. */
  38117. rebuild(): void;
  38118. /**
  38119. * Serializes the component data to the specified json object
  38120. * @param serializationObject The object to serialize to
  38121. */
  38122. serialize(serializationObject: any): void;
  38123. /**
  38124. * Adds all the elements from the container to the scene
  38125. * @param container the container holding the elements
  38126. */
  38127. addFromContainer(container: AbstractScene): void;
  38128. /**
  38129. * Removes all the elements in the container from the scene
  38130. * @param container contains the elements to remove
  38131. * @param dispose if the removed element should be disposed (default: false)
  38132. */
  38133. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38134. /**
  38135. * Disposes the component and the associated ressources.
  38136. */
  38137. dispose(): void;
  38138. /**
  38139. * Disables audio in the associated scene.
  38140. */
  38141. disableAudio(): void;
  38142. /**
  38143. * Enables audio in the associated scene.
  38144. */
  38145. enableAudio(): void;
  38146. /**
  38147. * Switch audio to headphone output.
  38148. */
  38149. switchAudioModeForHeadphones(): void;
  38150. /**
  38151. * Switch audio to normal speakers.
  38152. */
  38153. switchAudioModeForNormalSpeakers(): void;
  38154. private _cachedCameraDirection;
  38155. private _cachedCameraPosition;
  38156. private _lastCheck;
  38157. private _afterRender;
  38158. }
  38159. }
  38160. declare module BABYLON {
  38161. /**
  38162. * Wraps one or more Sound objects and selects one with random weight for playback.
  38163. */
  38164. export class WeightedSound {
  38165. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38166. loop: boolean;
  38167. private _coneInnerAngle;
  38168. private _coneOuterAngle;
  38169. private _volume;
  38170. /** A Sound is currently playing. */
  38171. isPlaying: boolean;
  38172. /** A Sound is currently paused. */
  38173. isPaused: boolean;
  38174. private _sounds;
  38175. private _weights;
  38176. private _currentIndex?;
  38177. /**
  38178. * Creates a new WeightedSound from the list of sounds given.
  38179. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38180. * @param sounds Array of Sounds that will be selected from.
  38181. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38182. */
  38183. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38184. /**
  38185. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38186. */
  38187. get directionalConeInnerAngle(): number;
  38188. /**
  38189. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38190. */
  38191. set directionalConeInnerAngle(value: number);
  38192. /**
  38193. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38194. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38195. */
  38196. get directionalConeOuterAngle(): number;
  38197. /**
  38198. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38199. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38200. */
  38201. set directionalConeOuterAngle(value: number);
  38202. /**
  38203. * Playback volume.
  38204. */
  38205. get volume(): number;
  38206. /**
  38207. * Playback volume.
  38208. */
  38209. set volume(value: number);
  38210. private _onended;
  38211. /**
  38212. * Suspend playback
  38213. */
  38214. pause(): void;
  38215. /**
  38216. * Stop playback
  38217. */
  38218. stop(): void;
  38219. /**
  38220. * Start playback.
  38221. * @param startOffset Position the clip head at a specific time in seconds.
  38222. */
  38223. play(startOffset?: number): void;
  38224. }
  38225. }
  38226. declare module BABYLON {
  38227. /**
  38228. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38229. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38230. */
  38231. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38232. /**
  38233. * Gets the name of the behavior.
  38234. */
  38235. get name(): string;
  38236. /**
  38237. * The easing function used by animations
  38238. */
  38239. static EasingFunction: BackEase;
  38240. /**
  38241. * The easing mode used by animations
  38242. */
  38243. static EasingMode: number;
  38244. /**
  38245. * The duration of the animation, in milliseconds
  38246. */
  38247. transitionDuration: number;
  38248. /**
  38249. * Length of the distance animated by the transition when lower radius is reached
  38250. */
  38251. lowerRadiusTransitionRange: number;
  38252. /**
  38253. * Length of the distance animated by the transition when upper radius is reached
  38254. */
  38255. upperRadiusTransitionRange: number;
  38256. private _autoTransitionRange;
  38257. /**
  38258. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38259. */
  38260. get autoTransitionRange(): boolean;
  38261. /**
  38262. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38263. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38264. */
  38265. set autoTransitionRange(value: boolean);
  38266. private _attachedCamera;
  38267. private _onAfterCheckInputsObserver;
  38268. private _onMeshTargetChangedObserver;
  38269. /**
  38270. * Initializes the behavior.
  38271. */
  38272. init(): void;
  38273. /**
  38274. * Attaches the behavior to its arc rotate camera.
  38275. * @param camera Defines the camera to attach the behavior to
  38276. */
  38277. attach(camera: ArcRotateCamera): void;
  38278. /**
  38279. * Detaches the behavior from its current arc rotate camera.
  38280. */
  38281. detach(): void;
  38282. private _radiusIsAnimating;
  38283. private _radiusBounceTransition;
  38284. private _animatables;
  38285. private _cachedWheelPrecision;
  38286. /**
  38287. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38288. * @param radiusLimit The limit to check against.
  38289. * @return Bool to indicate if at limit.
  38290. */
  38291. private _isRadiusAtLimit;
  38292. /**
  38293. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38294. * @param radiusDelta The delta by which to animate to. Can be negative.
  38295. */
  38296. private _applyBoundRadiusAnimation;
  38297. /**
  38298. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38299. */
  38300. protected _clearAnimationLocks(): void;
  38301. /**
  38302. * Stops and removes all animations that have been applied to the camera
  38303. */
  38304. stopAllAnimations(): void;
  38305. }
  38306. }
  38307. declare module BABYLON {
  38308. /**
  38309. * 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.
  38310. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38311. */
  38312. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38313. /**
  38314. * Gets the name of the behavior.
  38315. */
  38316. get name(): string;
  38317. private _mode;
  38318. private _radiusScale;
  38319. private _positionScale;
  38320. private _defaultElevation;
  38321. private _elevationReturnTime;
  38322. private _elevationReturnWaitTime;
  38323. private _zoomStopsAnimation;
  38324. private _framingTime;
  38325. /**
  38326. * The easing function used by animations
  38327. */
  38328. static EasingFunction: ExponentialEase;
  38329. /**
  38330. * The easing mode used by animations
  38331. */
  38332. static EasingMode: number;
  38333. /**
  38334. * Sets the current mode used by the behavior
  38335. */
  38336. set mode(mode: number);
  38337. /**
  38338. * Gets current mode used by the behavior.
  38339. */
  38340. get mode(): number;
  38341. /**
  38342. * Sets the scale applied to the radius (1 by default)
  38343. */
  38344. set radiusScale(radius: number);
  38345. /**
  38346. * Gets the scale applied to the radius
  38347. */
  38348. get radiusScale(): number;
  38349. /**
  38350. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38351. */
  38352. set positionScale(scale: number);
  38353. /**
  38354. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38355. */
  38356. get positionScale(): number;
  38357. /**
  38358. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38359. * behaviour is triggered, in radians.
  38360. */
  38361. set defaultElevation(elevation: number);
  38362. /**
  38363. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38364. * behaviour is triggered, in radians.
  38365. */
  38366. get defaultElevation(): number;
  38367. /**
  38368. * Sets the time (in milliseconds) taken to return to the default beta position.
  38369. * Negative value indicates camera should not return to default.
  38370. */
  38371. set elevationReturnTime(speed: number);
  38372. /**
  38373. * Gets the time (in milliseconds) taken to return to the default beta position.
  38374. * Negative value indicates camera should not return to default.
  38375. */
  38376. get elevationReturnTime(): number;
  38377. /**
  38378. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38379. */
  38380. set elevationReturnWaitTime(time: number);
  38381. /**
  38382. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38383. */
  38384. get elevationReturnWaitTime(): number;
  38385. /**
  38386. * Sets the flag that indicates if user zooming should stop animation.
  38387. */
  38388. set zoomStopsAnimation(flag: boolean);
  38389. /**
  38390. * Gets the flag that indicates if user zooming should stop animation.
  38391. */
  38392. get zoomStopsAnimation(): boolean;
  38393. /**
  38394. * Sets the transition time when framing the mesh, in milliseconds
  38395. */
  38396. set framingTime(time: number);
  38397. /**
  38398. * Gets the transition time when framing the mesh, in milliseconds
  38399. */
  38400. get framingTime(): number;
  38401. /**
  38402. * Define if the behavior should automatically change the configured
  38403. * camera limits and sensibilities.
  38404. */
  38405. autoCorrectCameraLimitsAndSensibility: boolean;
  38406. private _onPrePointerObservableObserver;
  38407. private _onAfterCheckInputsObserver;
  38408. private _onMeshTargetChangedObserver;
  38409. private _attachedCamera;
  38410. private _isPointerDown;
  38411. private _lastInteractionTime;
  38412. /**
  38413. * Initializes the behavior.
  38414. */
  38415. init(): void;
  38416. /**
  38417. * Attaches the behavior to its arc rotate camera.
  38418. * @param camera Defines the camera to attach the behavior to
  38419. */
  38420. attach(camera: ArcRotateCamera): void;
  38421. /**
  38422. * Detaches the behavior from its current arc rotate camera.
  38423. */
  38424. detach(): void;
  38425. private _animatables;
  38426. private _betaIsAnimating;
  38427. private _betaTransition;
  38428. private _radiusTransition;
  38429. private _vectorTransition;
  38430. /**
  38431. * Targets the given mesh and updates zoom level accordingly.
  38432. * @param mesh The mesh to target.
  38433. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38434. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38435. */
  38436. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38437. /**
  38438. * Targets the given mesh with its children and updates zoom level accordingly.
  38439. * @param mesh The mesh to target.
  38440. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38441. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38442. */
  38443. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38444. /**
  38445. * Targets the given meshes with their children and updates zoom level accordingly.
  38446. * @param meshes The mesh to target.
  38447. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38448. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38449. */
  38450. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38451. /**
  38452. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38453. * @param minimumWorld Determines the smaller position of the bounding box extend
  38454. * @param maximumWorld Determines the bigger position of the bounding box extend
  38455. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38456. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38457. */
  38458. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38459. /**
  38460. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38461. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38462. * frustum width.
  38463. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38464. * to fully enclose the mesh in the viewing frustum.
  38465. */
  38466. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38467. /**
  38468. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38469. * is automatically returned to its default position (expected to be above ground plane).
  38470. */
  38471. private _maintainCameraAboveGround;
  38472. /**
  38473. * Returns the frustum slope based on the canvas ratio and camera FOV
  38474. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38475. */
  38476. private _getFrustumSlope;
  38477. /**
  38478. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38479. */
  38480. private _clearAnimationLocks;
  38481. /**
  38482. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38483. */
  38484. private _applyUserInteraction;
  38485. /**
  38486. * Stops and removes all animations that have been applied to the camera
  38487. */
  38488. stopAllAnimations(): void;
  38489. /**
  38490. * Gets a value indicating if the user is moving the camera
  38491. */
  38492. get isUserIsMoving(): boolean;
  38493. /**
  38494. * The camera can move all the way towards the mesh.
  38495. */
  38496. static IgnoreBoundsSizeMode: number;
  38497. /**
  38498. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38499. */
  38500. static FitFrustumSidesMode: number;
  38501. }
  38502. }
  38503. declare module BABYLON {
  38504. /**
  38505. * Base class for Camera Pointer Inputs.
  38506. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38507. * for example usage.
  38508. */
  38509. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38510. /**
  38511. * Defines the camera the input is attached to.
  38512. */
  38513. abstract camera: Camera;
  38514. /**
  38515. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38516. */
  38517. protected _altKey: boolean;
  38518. protected _ctrlKey: boolean;
  38519. protected _metaKey: boolean;
  38520. protected _shiftKey: boolean;
  38521. /**
  38522. * Which mouse buttons were pressed at time of last mouse event.
  38523. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38524. */
  38525. protected _buttonsPressed: number;
  38526. /**
  38527. * Defines the buttons associated with the input to handle camera move.
  38528. */
  38529. buttons: number[];
  38530. /**
  38531. * Attach the input controls to a specific dom element to get the input from.
  38532. * @param element Defines the element the controls should be listened from
  38533. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38534. */
  38535. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38536. /**
  38537. * Detach the current controls from the specified dom element.
  38538. * @param element Defines the element to stop listening the inputs from
  38539. */
  38540. detachControl(element: Nullable<HTMLElement>): void;
  38541. /**
  38542. * Gets the class name of the current input.
  38543. * @returns the class name
  38544. */
  38545. getClassName(): string;
  38546. /**
  38547. * Get the friendly name associated with the input class.
  38548. * @returns the input friendly name
  38549. */
  38550. getSimpleName(): string;
  38551. /**
  38552. * Called on pointer POINTERDOUBLETAP event.
  38553. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38554. */
  38555. protected onDoubleTap(type: string): void;
  38556. /**
  38557. * Called on pointer POINTERMOVE event if only a single touch is active.
  38558. * Override this method to provide functionality.
  38559. */
  38560. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38561. /**
  38562. * Called on pointer POINTERMOVE event if multiple touches are active.
  38563. * Override this method to provide functionality.
  38564. */
  38565. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38566. /**
  38567. * Called on JS contextmenu event.
  38568. * Override this method to provide functionality.
  38569. */
  38570. protected onContextMenu(evt: PointerEvent): void;
  38571. /**
  38572. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38573. * press.
  38574. * Override this method to provide functionality.
  38575. */
  38576. protected onButtonDown(evt: PointerEvent): void;
  38577. /**
  38578. * Called each time a new POINTERUP event occurs. Ie, for each button
  38579. * release.
  38580. * Override this method to provide functionality.
  38581. */
  38582. protected onButtonUp(evt: PointerEvent): void;
  38583. /**
  38584. * Called when window becomes inactive.
  38585. * Override this method to provide functionality.
  38586. */
  38587. protected onLostFocus(): void;
  38588. private _pointerInput;
  38589. private _observer;
  38590. private _onLostFocus;
  38591. private pointA;
  38592. private pointB;
  38593. }
  38594. }
  38595. declare module BABYLON {
  38596. /**
  38597. * Manage the pointers inputs to control an arc rotate camera.
  38598. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38599. */
  38600. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38601. /**
  38602. * Defines the camera the input is attached to.
  38603. */
  38604. camera: ArcRotateCamera;
  38605. /**
  38606. * Gets the class name of the current input.
  38607. * @returns the class name
  38608. */
  38609. getClassName(): string;
  38610. /**
  38611. * Defines the buttons associated with the input to handle camera move.
  38612. */
  38613. buttons: number[];
  38614. /**
  38615. * Defines the pointer angular sensibility along the X axis or how fast is
  38616. * the camera rotating.
  38617. */
  38618. angularSensibilityX: number;
  38619. /**
  38620. * Defines the pointer angular sensibility along the Y axis or how fast is
  38621. * the camera rotating.
  38622. */
  38623. angularSensibilityY: number;
  38624. /**
  38625. * Defines the pointer pinch precision or how fast is the camera zooming.
  38626. */
  38627. pinchPrecision: number;
  38628. /**
  38629. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38630. * from 0.
  38631. * It defines the percentage of current camera.radius to use as delta when
  38632. * pinch zoom is used.
  38633. */
  38634. pinchDeltaPercentage: number;
  38635. /**
  38636. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38637. * that any object in the plane at the camera's target point will scale
  38638. * perfectly with finger motion.
  38639. * Overrides pinchDeltaPercentage and pinchPrecision.
  38640. */
  38641. useNaturalPinchZoom: boolean;
  38642. /**
  38643. * Defines the pointer panning sensibility or how fast is the camera moving.
  38644. */
  38645. panningSensibility: number;
  38646. /**
  38647. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38648. */
  38649. multiTouchPanning: boolean;
  38650. /**
  38651. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38652. * zoom (pinch) through multitouch.
  38653. */
  38654. multiTouchPanAndZoom: boolean;
  38655. /**
  38656. * Revers pinch action direction.
  38657. */
  38658. pinchInwards: boolean;
  38659. private _isPanClick;
  38660. private _twoFingerActivityCount;
  38661. private _isPinching;
  38662. /**
  38663. * Called on pointer POINTERMOVE event if only a single touch is active.
  38664. */
  38665. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38666. /**
  38667. * Called on pointer POINTERDOUBLETAP event.
  38668. */
  38669. protected onDoubleTap(type: string): void;
  38670. /**
  38671. * Called on pointer POINTERMOVE event if multiple touches are active.
  38672. */
  38673. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38674. /**
  38675. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38676. * press.
  38677. */
  38678. protected onButtonDown(evt: PointerEvent): void;
  38679. /**
  38680. * Called each time a new POINTERUP event occurs. Ie, for each button
  38681. * release.
  38682. */
  38683. protected onButtonUp(evt: PointerEvent): void;
  38684. /**
  38685. * Called when window becomes inactive.
  38686. */
  38687. protected onLostFocus(): void;
  38688. }
  38689. }
  38690. declare module BABYLON {
  38691. /**
  38692. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38693. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38694. */
  38695. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38696. /**
  38697. * Defines the camera the input is attached to.
  38698. */
  38699. camera: ArcRotateCamera;
  38700. /**
  38701. * Defines the list of key codes associated with the up action (increase alpha)
  38702. */
  38703. keysUp: number[];
  38704. /**
  38705. * Defines the list of key codes associated with the down action (decrease alpha)
  38706. */
  38707. keysDown: number[];
  38708. /**
  38709. * Defines the list of key codes associated with the left action (increase beta)
  38710. */
  38711. keysLeft: number[];
  38712. /**
  38713. * Defines the list of key codes associated with the right action (decrease beta)
  38714. */
  38715. keysRight: number[];
  38716. /**
  38717. * Defines the list of key codes associated with the reset action.
  38718. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38719. */
  38720. keysReset: number[];
  38721. /**
  38722. * Defines the panning sensibility of the inputs.
  38723. * (How fast is the camera panning)
  38724. */
  38725. panningSensibility: number;
  38726. /**
  38727. * Defines the zooming sensibility of the inputs.
  38728. * (How fast is the camera zooming)
  38729. */
  38730. zoomingSensibility: number;
  38731. /**
  38732. * Defines whether maintaining the alt key down switch the movement mode from
  38733. * orientation to zoom.
  38734. */
  38735. useAltToZoom: boolean;
  38736. /**
  38737. * Rotation speed of the camera
  38738. */
  38739. angularSpeed: number;
  38740. private _keys;
  38741. private _ctrlPressed;
  38742. private _altPressed;
  38743. private _onCanvasBlurObserver;
  38744. private _onKeyboardObserver;
  38745. private _engine;
  38746. private _scene;
  38747. /**
  38748. * Attach the input controls to a specific dom element to get the input from.
  38749. * @param element Defines the element the controls should be listened from
  38750. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38751. */
  38752. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38753. /**
  38754. * Detach the current controls from the specified dom element.
  38755. * @param element Defines the element to stop listening the inputs from
  38756. */
  38757. detachControl(element: Nullable<HTMLElement>): void;
  38758. /**
  38759. * Update the current camera state depending on the inputs that have been used this frame.
  38760. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38761. */
  38762. checkInputs(): void;
  38763. /**
  38764. * Gets the class name of the current intput.
  38765. * @returns the class name
  38766. */
  38767. getClassName(): string;
  38768. /**
  38769. * Get the friendly name associated with the input class.
  38770. * @returns the input friendly name
  38771. */
  38772. getSimpleName(): string;
  38773. }
  38774. }
  38775. declare module BABYLON {
  38776. /**
  38777. * Manage the mouse wheel inputs to control an arc rotate camera.
  38778. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38779. */
  38780. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38781. /**
  38782. * Defines the camera the input is attached to.
  38783. */
  38784. camera: ArcRotateCamera;
  38785. /**
  38786. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38787. */
  38788. wheelPrecision: number;
  38789. /**
  38790. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38791. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38792. */
  38793. wheelDeltaPercentage: number;
  38794. private _wheel;
  38795. private _observer;
  38796. private computeDeltaFromMouseWheelLegacyEvent;
  38797. /**
  38798. * Attach the input controls to a specific dom element to get the input from.
  38799. * @param element Defines the element the controls should be listened from
  38800. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38801. */
  38802. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38803. /**
  38804. * Detach the current controls from the specified dom element.
  38805. * @param element Defines the element to stop listening the inputs from
  38806. */
  38807. detachControl(element: Nullable<HTMLElement>): void;
  38808. /**
  38809. * Gets the class name of the current intput.
  38810. * @returns the class name
  38811. */
  38812. getClassName(): string;
  38813. /**
  38814. * Get the friendly name associated with the input class.
  38815. * @returns the input friendly name
  38816. */
  38817. getSimpleName(): string;
  38818. }
  38819. }
  38820. declare module BABYLON {
  38821. /**
  38822. * Default Inputs manager for the ArcRotateCamera.
  38823. * It groups all the default supported inputs for ease of use.
  38824. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38825. */
  38826. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38827. /**
  38828. * Instantiates a new ArcRotateCameraInputsManager.
  38829. * @param camera Defines the camera the inputs belong to
  38830. */
  38831. constructor(camera: ArcRotateCamera);
  38832. /**
  38833. * Add mouse wheel input support to the input manager.
  38834. * @returns the current input manager
  38835. */
  38836. addMouseWheel(): ArcRotateCameraInputsManager;
  38837. /**
  38838. * Add pointers input support to the input manager.
  38839. * @returns the current input manager
  38840. */
  38841. addPointers(): ArcRotateCameraInputsManager;
  38842. /**
  38843. * Add keyboard input support to the input manager.
  38844. * @returns the current input manager
  38845. */
  38846. addKeyboard(): ArcRotateCameraInputsManager;
  38847. }
  38848. }
  38849. declare module BABYLON {
  38850. /**
  38851. * This represents an orbital type of camera.
  38852. *
  38853. * 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.
  38854. * 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.
  38855. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  38856. */
  38857. export class ArcRotateCamera extends TargetCamera {
  38858. /**
  38859. * Defines the rotation angle of the camera along the longitudinal axis.
  38860. */
  38861. alpha: number;
  38862. /**
  38863. * Defines the rotation angle of the camera along the latitudinal axis.
  38864. */
  38865. beta: number;
  38866. /**
  38867. * Defines the radius of the camera from it s target point.
  38868. */
  38869. radius: number;
  38870. protected _target: Vector3;
  38871. protected _targetHost: Nullable<AbstractMesh>;
  38872. /**
  38873. * Defines the target point of the camera.
  38874. * The camera looks towards it form the radius distance.
  38875. */
  38876. get target(): Vector3;
  38877. set target(value: Vector3);
  38878. /**
  38879. * Define the current local position of the camera in the scene
  38880. */
  38881. get position(): Vector3;
  38882. set position(newPosition: Vector3);
  38883. protected _upVector: Vector3;
  38884. protected _upToYMatrix: Matrix;
  38885. protected _YToUpMatrix: Matrix;
  38886. /**
  38887. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  38888. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  38889. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  38890. */
  38891. set upVector(vec: Vector3);
  38892. get upVector(): Vector3;
  38893. /**
  38894. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  38895. */
  38896. setMatUp(): void;
  38897. /**
  38898. * Current inertia value on the longitudinal axis.
  38899. * The bigger this number the longer it will take for the camera to stop.
  38900. */
  38901. inertialAlphaOffset: number;
  38902. /**
  38903. * Current inertia value on the latitudinal axis.
  38904. * The bigger this number the longer it will take for the camera to stop.
  38905. */
  38906. inertialBetaOffset: number;
  38907. /**
  38908. * Current inertia value on the radius axis.
  38909. * The bigger this number the longer it will take for the camera to stop.
  38910. */
  38911. inertialRadiusOffset: number;
  38912. /**
  38913. * Minimum allowed angle on the longitudinal axis.
  38914. * This can help limiting how the Camera is able to move in the scene.
  38915. */
  38916. lowerAlphaLimit: Nullable<number>;
  38917. /**
  38918. * Maximum allowed angle on the longitudinal axis.
  38919. * This can help limiting how the Camera is able to move in the scene.
  38920. */
  38921. upperAlphaLimit: Nullable<number>;
  38922. /**
  38923. * Minimum allowed angle on the latitudinal axis.
  38924. * This can help limiting how the Camera is able to move in the scene.
  38925. */
  38926. lowerBetaLimit: number;
  38927. /**
  38928. * Maximum allowed angle on the latitudinal axis.
  38929. * This can help limiting how the Camera is able to move in the scene.
  38930. */
  38931. upperBetaLimit: number;
  38932. /**
  38933. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  38934. * This can help limiting how the Camera is able to move in the scene.
  38935. */
  38936. lowerRadiusLimit: Nullable<number>;
  38937. /**
  38938. * Maximum allowed distance of the camera to the target (The camera can not get further).
  38939. * This can help limiting how the Camera is able to move in the scene.
  38940. */
  38941. upperRadiusLimit: Nullable<number>;
  38942. /**
  38943. * Defines the current inertia value used during panning of the camera along the X axis.
  38944. */
  38945. inertialPanningX: number;
  38946. /**
  38947. * Defines the current inertia value used during panning of the camera along the Y axis.
  38948. */
  38949. inertialPanningY: number;
  38950. /**
  38951. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  38952. * Basically if your fingers moves away from more than this distance you will be considered
  38953. * in pinch mode.
  38954. */
  38955. pinchToPanMaxDistance: number;
  38956. /**
  38957. * Defines the maximum distance the camera can pan.
  38958. * This could help keeping the cammera always in your scene.
  38959. */
  38960. panningDistanceLimit: Nullable<number>;
  38961. /**
  38962. * Defines the target of the camera before paning.
  38963. */
  38964. panningOriginTarget: Vector3;
  38965. /**
  38966. * Defines the value of the inertia used during panning.
  38967. * 0 would mean stop inertia and one would mean no decelleration at all.
  38968. */
  38969. panningInertia: number;
  38970. /**
  38971. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  38972. */
  38973. get angularSensibilityX(): number;
  38974. set angularSensibilityX(value: number);
  38975. /**
  38976. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  38977. */
  38978. get angularSensibilityY(): number;
  38979. set angularSensibilityY(value: number);
  38980. /**
  38981. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  38982. */
  38983. get pinchPrecision(): number;
  38984. set pinchPrecision(value: number);
  38985. /**
  38986. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  38987. * It will be used instead of pinchDeltaPrecision if different from 0.
  38988. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38989. */
  38990. get pinchDeltaPercentage(): number;
  38991. set pinchDeltaPercentage(value: number);
  38992. /**
  38993. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  38994. * and pinch delta percentage.
  38995. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38996. * that any object in the plane at the camera's target point will scale
  38997. * perfectly with finger motion.
  38998. */
  38999. get useNaturalPinchZoom(): boolean;
  39000. set useNaturalPinchZoom(value: boolean);
  39001. /**
  39002. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39003. */
  39004. get panningSensibility(): number;
  39005. set panningSensibility(value: number);
  39006. /**
  39007. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39008. */
  39009. get keysUp(): number[];
  39010. set keysUp(value: number[]);
  39011. /**
  39012. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39013. */
  39014. get keysDown(): number[];
  39015. set keysDown(value: number[]);
  39016. /**
  39017. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39018. */
  39019. get keysLeft(): number[];
  39020. set keysLeft(value: number[]);
  39021. /**
  39022. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39023. */
  39024. get keysRight(): number[];
  39025. set keysRight(value: number[]);
  39026. /**
  39027. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39028. */
  39029. get wheelPrecision(): number;
  39030. set wheelPrecision(value: number);
  39031. /**
  39032. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39033. * It will be used instead of pinchDeltaPrecision if different from 0.
  39034. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39035. */
  39036. get wheelDeltaPercentage(): number;
  39037. set wheelDeltaPercentage(value: number);
  39038. /**
  39039. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39040. */
  39041. zoomOnFactor: number;
  39042. /**
  39043. * Defines a screen offset for the camera position.
  39044. */
  39045. targetScreenOffset: Vector2;
  39046. /**
  39047. * Allows the camera to be completely reversed.
  39048. * If false the camera can not arrive upside down.
  39049. */
  39050. allowUpsideDown: boolean;
  39051. /**
  39052. * Define if double tap/click is used to restore the previously saved state of the camera.
  39053. */
  39054. useInputToRestoreState: boolean;
  39055. /** @hidden */
  39056. _viewMatrix: Matrix;
  39057. /** @hidden */
  39058. _useCtrlForPanning: boolean;
  39059. /** @hidden */
  39060. _panningMouseButton: number;
  39061. /**
  39062. * Defines the input associated to the camera.
  39063. */
  39064. inputs: ArcRotateCameraInputsManager;
  39065. /** @hidden */
  39066. _reset: () => void;
  39067. /**
  39068. * Defines the allowed panning axis.
  39069. */
  39070. panningAxis: Vector3;
  39071. protected _localDirection: Vector3;
  39072. protected _transformedDirection: Vector3;
  39073. private _bouncingBehavior;
  39074. /**
  39075. * Gets the bouncing behavior of the camera if it has been enabled.
  39076. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39077. */
  39078. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39079. /**
  39080. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39081. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39082. */
  39083. get useBouncingBehavior(): boolean;
  39084. set useBouncingBehavior(value: boolean);
  39085. private _framingBehavior;
  39086. /**
  39087. * Gets the framing behavior of the camera if it has been enabled.
  39088. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39089. */
  39090. get framingBehavior(): Nullable<FramingBehavior>;
  39091. /**
  39092. * Defines if the framing behavior of the camera is enabled on the camera.
  39093. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39094. */
  39095. get useFramingBehavior(): boolean;
  39096. set useFramingBehavior(value: boolean);
  39097. private _autoRotationBehavior;
  39098. /**
  39099. * Gets the auto rotation behavior of the camera if it has been enabled.
  39100. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39101. */
  39102. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39103. /**
  39104. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39105. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39106. */
  39107. get useAutoRotationBehavior(): boolean;
  39108. set useAutoRotationBehavior(value: boolean);
  39109. /**
  39110. * Observable triggered when the mesh target has been changed on the camera.
  39111. */
  39112. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39113. /**
  39114. * Event raised when the camera is colliding with a mesh.
  39115. */
  39116. onCollide: (collidedMesh: AbstractMesh) => void;
  39117. /**
  39118. * Defines whether the camera should check collision with the objects oh the scene.
  39119. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39120. */
  39121. checkCollisions: boolean;
  39122. /**
  39123. * Defines the collision radius of the camera.
  39124. * This simulates a sphere around the camera.
  39125. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39126. */
  39127. collisionRadius: Vector3;
  39128. protected _collider: Collider;
  39129. protected _previousPosition: Vector3;
  39130. protected _collisionVelocity: Vector3;
  39131. protected _newPosition: Vector3;
  39132. protected _previousAlpha: number;
  39133. protected _previousBeta: number;
  39134. protected _previousRadius: number;
  39135. protected _collisionTriggered: boolean;
  39136. protected _targetBoundingCenter: Nullable<Vector3>;
  39137. private _computationVector;
  39138. /**
  39139. * Instantiates a new ArcRotateCamera in a given scene
  39140. * @param name Defines the name of the camera
  39141. * @param alpha Defines the camera rotation along the logitudinal axis
  39142. * @param beta Defines the camera rotation along the latitudinal axis
  39143. * @param radius Defines the camera distance from its target
  39144. * @param target Defines the camera target
  39145. * @param scene Defines the scene the camera belongs to
  39146. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39147. */
  39148. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39149. /** @hidden */
  39150. _initCache(): void;
  39151. /** @hidden */
  39152. _updateCache(ignoreParentClass?: boolean): void;
  39153. protected _getTargetPosition(): Vector3;
  39154. private _storedAlpha;
  39155. private _storedBeta;
  39156. private _storedRadius;
  39157. private _storedTarget;
  39158. private _storedTargetScreenOffset;
  39159. /**
  39160. * Stores the current state of the camera (alpha, beta, radius and target)
  39161. * @returns the camera itself
  39162. */
  39163. storeState(): Camera;
  39164. /**
  39165. * @hidden
  39166. * Restored camera state. You must call storeState() first
  39167. */
  39168. _restoreStateValues(): boolean;
  39169. /** @hidden */
  39170. _isSynchronizedViewMatrix(): boolean;
  39171. /**
  39172. * Attached controls to the current camera.
  39173. * @param element Defines the element the controls should be listened from
  39174. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39175. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39176. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39177. */
  39178. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39179. /**
  39180. * Detach the current controls from the camera.
  39181. * The camera will stop reacting to inputs.
  39182. * @param element Defines the element to stop listening the inputs from
  39183. */
  39184. detachControl(element: HTMLElement): void;
  39185. /** @hidden */
  39186. _checkInputs(): void;
  39187. protected _checkLimits(): void;
  39188. /**
  39189. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39190. */
  39191. rebuildAnglesAndRadius(): void;
  39192. /**
  39193. * Use a position to define the current camera related information like alpha, beta and radius
  39194. * @param position Defines the position to set the camera at
  39195. */
  39196. setPosition(position: Vector3): void;
  39197. /**
  39198. * Defines the target the camera should look at.
  39199. * This will automatically adapt alpha beta and radius to fit within the new target.
  39200. * @param target Defines the new target as a Vector or a mesh
  39201. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  39202. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39203. */
  39204. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39205. /** @hidden */
  39206. _getViewMatrix(): Matrix;
  39207. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39208. /**
  39209. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39210. * @param meshes Defines the mesh to zoom on
  39211. * @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)
  39212. */
  39213. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39214. /**
  39215. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39216. * The target will be changed but the radius
  39217. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39218. * @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)
  39219. */
  39220. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39221. min: Vector3;
  39222. max: Vector3;
  39223. distance: number;
  39224. }, doNotUpdateMaxZ?: boolean): void;
  39225. /**
  39226. * @override
  39227. * Override Camera.createRigCamera
  39228. */
  39229. createRigCamera(name: string, cameraIndex: number): Camera;
  39230. /**
  39231. * @hidden
  39232. * @override
  39233. * Override Camera._updateRigCameras
  39234. */
  39235. _updateRigCameras(): void;
  39236. /**
  39237. * Destroy the camera and release the current resources hold by it.
  39238. */
  39239. dispose(): void;
  39240. /**
  39241. * Gets the current object class name.
  39242. * @return the class name
  39243. */
  39244. getClassName(): string;
  39245. }
  39246. }
  39247. declare module BABYLON {
  39248. /**
  39249. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39250. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39251. */
  39252. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39253. /**
  39254. * Gets the name of the behavior.
  39255. */
  39256. get name(): string;
  39257. private _zoomStopsAnimation;
  39258. private _idleRotationSpeed;
  39259. private _idleRotationWaitTime;
  39260. private _idleRotationSpinupTime;
  39261. /**
  39262. * Sets the flag that indicates if user zooming should stop animation.
  39263. */
  39264. set zoomStopsAnimation(flag: boolean);
  39265. /**
  39266. * Gets the flag that indicates if user zooming should stop animation.
  39267. */
  39268. get zoomStopsAnimation(): boolean;
  39269. /**
  39270. * Sets the default speed at which the camera rotates around the model.
  39271. */
  39272. set idleRotationSpeed(speed: number);
  39273. /**
  39274. * Gets the default speed at which the camera rotates around the model.
  39275. */
  39276. get idleRotationSpeed(): number;
  39277. /**
  39278. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39279. */
  39280. set idleRotationWaitTime(time: number);
  39281. /**
  39282. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39283. */
  39284. get idleRotationWaitTime(): number;
  39285. /**
  39286. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39287. */
  39288. set idleRotationSpinupTime(time: number);
  39289. /**
  39290. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39291. */
  39292. get idleRotationSpinupTime(): number;
  39293. /**
  39294. * Gets a value indicating if the camera is currently rotating because of this behavior
  39295. */
  39296. get rotationInProgress(): boolean;
  39297. private _onPrePointerObservableObserver;
  39298. private _onAfterCheckInputsObserver;
  39299. private _attachedCamera;
  39300. private _isPointerDown;
  39301. private _lastFrameTime;
  39302. private _lastInteractionTime;
  39303. private _cameraRotationSpeed;
  39304. /**
  39305. * Initializes the behavior.
  39306. */
  39307. init(): void;
  39308. /**
  39309. * Attaches the behavior to its arc rotate camera.
  39310. * @param camera Defines the camera to attach the behavior to
  39311. */
  39312. attach(camera: ArcRotateCamera): void;
  39313. /**
  39314. * Detaches the behavior from its current arc rotate camera.
  39315. */
  39316. detach(): void;
  39317. /**
  39318. * Returns true if user is scrolling.
  39319. * @return true if user is scrolling.
  39320. */
  39321. private _userIsZooming;
  39322. private _lastFrameRadius;
  39323. private _shouldAnimationStopForInteraction;
  39324. /**
  39325. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39326. */
  39327. private _applyUserInteraction;
  39328. private _userIsMoving;
  39329. }
  39330. }
  39331. declare module BABYLON {
  39332. /**
  39333. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39334. */
  39335. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39336. private ui;
  39337. /**
  39338. * The name of the behavior
  39339. */
  39340. name: string;
  39341. /**
  39342. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39343. */
  39344. distanceAwayFromFace: number;
  39345. /**
  39346. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39347. */
  39348. distanceAwayFromBottomOfFace: number;
  39349. private _faceVectors;
  39350. private _target;
  39351. private _scene;
  39352. private _onRenderObserver;
  39353. private _tmpMatrix;
  39354. private _tmpVector;
  39355. /**
  39356. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39357. * @param ui The transform node that should be attched to the mesh
  39358. */
  39359. constructor(ui: TransformNode);
  39360. /**
  39361. * Initializes the behavior
  39362. */
  39363. init(): void;
  39364. private _closestFace;
  39365. private _zeroVector;
  39366. private _lookAtTmpMatrix;
  39367. private _lookAtToRef;
  39368. /**
  39369. * Attaches the AttachToBoxBehavior to the passed in mesh
  39370. * @param target The mesh that the specified node will be attached to
  39371. */
  39372. attach(target: Mesh): void;
  39373. /**
  39374. * Detaches the behavior from the mesh
  39375. */
  39376. detach(): void;
  39377. }
  39378. }
  39379. declare module BABYLON {
  39380. /**
  39381. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39382. */
  39383. export class FadeInOutBehavior implements Behavior<Mesh> {
  39384. /**
  39385. * Time in milliseconds to delay before fading in (Default: 0)
  39386. */
  39387. delay: number;
  39388. /**
  39389. * Time in milliseconds for the mesh to fade in (Default: 300)
  39390. */
  39391. fadeInTime: number;
  39392. private _millisecondsPerFrame;
  39393. private _hovered;
  39394. private _hoverValue;
  39395. private _ownerNode;
  39396. /**
  39397. * Instatiates the FadeInOutBehavior
  39398. */
  39399. constructor();
  39400. /**
  39401. * The name of the behavior
  39402. */
  39403. get name(): string;
  39404. /**
  39405. * Initializes the behavior
  39406. */
  39407. init(): void;
  39408. /**
  39409. * Attaches the fade behavior on the passed in mesh
  39410. * @param ownerNode The mesh that will be faded in/out once attached
  39411. */
  39412. attach(ownerNode: Mesh): void;
  39413. /**
  39414. * Detaches the behavior from the mesh
  39415. */
  39416. detach(): void;
  39417. /**
  39418. * Triggers the mesh to begin fading in or out
  39419. * @param value if the object should fade in or out (true to fade in)
  39420. */
  39421. fadeIn(value: boolean): void;
  39422. private _update;
  39423. private _setAllVisibility;
  39424. }
  39425. }
  39426. declare module BABYLON {
  39427. /**
  39428. * Class containing a set of static utilities functions for managing Pivots
  39429. * @hidden
  39430. */
  39431. export class PivotTools {
  39432. private static _PivotCached;
  39433. private static _OldPivotPoint;
  39434. private static _PivotTranslation;
  39435. private static _PivotTmpVector;
  39436. /** @hidden */
  39437. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39438. /** @hidden */
  39439. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39440. }
  39441. }
  39442. declare module BABYLON {
  39443. /**
  39444. * Class containing static functions to help procedurally build meshes
  39445. */
  39446. export class PlaneBuilder {
  39447. /**
  39448. * Creates a plane mesh
  39449. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39450. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39451. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39452. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39453. * * 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
  39454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39455. * @param name defines the name of the mesh
  39456. * @param options defines the options used to create the mesh
  39457. * @param scene defines the hosting scene
  39458. * @returns the plane mesh
  39459. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39460. */
  39461. static CreatePlane(name: string, options: {
  39462. size?: number;
  39463. width?: number;
  39464. height?: number;
  39465. sideOrientation?: number;
  39466. frontUVs?: Vector4;
  39467. backUVs?: Vector4;
  39468. updatable?: boolean;
  39469. sourcePlane?: Plane;
  39470. }, scene?: Nullable<Scene>): Mesh;
  39471. }
  39472. }
  39473. declare module BABYLON {
  39474. /**
  39475. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39476. */
  39477. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39478. private static _AnyMouseID;
  39479. /**
  39480. * Abstract mesh the behavior is set on
  39481. */
  39482. attachedNode: AbstractMesh;
  39483. private _dragPlane;
  39484. private _scene;
  39485. private _pointerObserver;
  39486. private _beforeRenderObserver;
  39487. private static _planeScene;
  39488. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39489. /**
  39490. * 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)
  39491. */
  39492. maxDragAngle: number;
  39493. /**
  39494. * @hidden
  39495. */
  39496. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39497. /**
  39498. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39499. */
  39500. currentDraggingPointerID: number;
  39501. /**
  39502. * The last position where the pointer hit the drag plane in world space
  39503. */
  39504. lastDragPosition: Vector3;
  39505. /**
  39506. * If the behavior is currently in a dragging state
  39507. */
  39508. dragging: boolean;
  39509. /**
  39510. * 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)
  39511. */
  39512. dragDeltaRatio: number;
  39513. /**
  39514. * If the drag plane orientation should be updated during the dragging (Default: true)
  39515. */
  39516. updateDragPlane: boolean;
  39517. private _debugMode;
  39518. private _moving;
  39519. /**
  39520. * Fires each time the attached mesh is dragged with the pointer
  39521. * * delta between last drag position and current drag position in world space
  39522. * * dragDistance along the drag axis
  39523. * * dragPlaneNormal normal of the current drag plane used during the drag
  39524. * * dragPlanePoint in world space where the drag intersects the drag plane
  39525. */
  39526. onDragObservable: Observable<{
  39527. delta: Vector3;
  39528. dragPlanePoint: Vector3;
  39529. dragPlaneNormal: Vector3;
  39530. dragDistance: number;
  39531. pointerId: number;
  39532. }>;
  39533. /**
  39534. * Fires each time a drag begins (eg. mouse down on mesh)
  39535. */
  39536. onDragStartObservable: Observable<{
  39537. dragPlanePoint: Vector3;
  39538. pointerId: number;
  39539. }>;
  39540. /**
  39541. * Fires each time a drag ends (eg. mouse release after drag)
  39542. */
  39543. onDragEndObservable: Observable<{
  39544. dragPlanePoint: Vector3;
  39545. pointerId: number;
  39546. }>;
  39547. /**
  39548. * If the attached mesh should be moved when dragged
  39549. */
  39550. moveAttached: boolean;
  39551. /**
  39552. * If the drag behavior will react to drag events (Default: true)
  39553. */
  39554. enabled: boolean;
  39555. /**
  39556. * If pointer events should start and release the drag (Default: true)
  39557. */
  39558. startAndReleaseDragOnPointerEvents: boolean;
  39559. /**
  39560. * If camera controls should be detached during the drag
  39561. */
  39562. detachCameraControls: boolean;
  39563. /**
  39564. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39565. */
  39566. useObjectOrientationForDragging: boolean;
  39567. private _options;
  39568. /**
  39569. * Gets the options used by the behavior
  39570. */
  39571. get options(): {
  39572. dragAxis?: Vector3;
  39573. dragPlaneNormal?: Vector3;
  39574. };
  39575. /**
  39576. * Sets the options used by the behavior
  39577. */
  39578. set options(options: {
  39579. dragAxis?: Vector3;
  39580. dragPlaneNormal?: Vector3;
  39581. });
  39582. /**
  39583. * Creates a pointer drag behavior that can be attached to a mesh
  39584. * @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)
  39585. */
  39586. constructor(options?: {
  39587. dragAxis?: Vector3;
  39588. dragPlaneNormal?: Vector3;
  39589. });
  39590. /**
  39591. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39592. */
  39593. validateDrag: (targetPosition: Vector3) => boolean;
  39594. /**
  39595. * The name of the behavior
  39596. */
  39597. get name(): string;
  39598. /**
  39599. * Initializes the behavior
  39600. */
  39601. init(): void;
  39602. private _tmpVector;
  39603. private _alternatePickedPoint;
  39604. private _worldDragAxis;
  39605. private _targetPosition;
  39606. private _attachedElement;
  39607. /**
  39608. * Attaches the drag behavior the passed in mesh
  39609. * @param ownerNode The mesh that will be dragged around once attached
  39610. * @param predicate Predicate to use for pick filtering
  39611. */
  39612. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39613. /**
  39614. * Force relase the drag action by code.
  39615. */
  39616. releaseDrag(): void;
  39617. private _startDragRay;
  39618. private _lastPointerRay;
  39619. /**
  39620. * Simulates the start of a pointer drag event on the behavior
  39621. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39622. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39623. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39624. */
  39625. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39626. private _startDrag;
  39627. private _dragDelta;
  39628. private _moveDrag;
  39629. private _pickWithRayOnDragPlane;
  39630. private _pointA;
  39631. private _pointB;
  39632. private _pointC;
  39633. private _lineA;
  39634. private _lineB;
  39635. private _localAxis;
  39636. private _lookAt;
  39637. private _updateDragPlanePosition;
  39638. /**
  39639. * Detaches the behavior from the mesh
  39640. */
  39641. detach(): void;
  39642. }
  39643. }
  39644. declare module BABYLON {
  39645. /**
  39646. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39647. */
  39648. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39649. private _dragBehaviorA;
  39650. private _dragBehaviorB;
  39651. private _startDistance;
  39652. private _initialScale;
  39653. private _targetScale;
  39654. private _ownerNode;
  39655. private _sceneRenderObserver;
  39656. /**
  39657. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39658. */
  39659. constructor();
  39660. /**
  39661. * The name of the behavior
  39662. */
  39663. get name(): string;
  39664. /**
  39665. * Initializes the behavior
  39666. */
  39667. init(): void;
  39668. private _getCurrentDistance;
  39669. /**
  39670. * Attaches the scale behavior the passed in mesh
  39671. * @param ownerNode The mesh that will be scaled around once attached
  39672. */
  39673. attach(ownerNode: Mesh): void;
  39674. /**
  39675. * Detaches the behavior from the mesh
  39676. */
  39677. detach(): void;
  39678. }
  39679. }
  39680. declare module BABYLON {
  39681. /**
  39682. * 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
  39683. */
  39684. export class SixDofDragBehavior implements Behavior<Mesh> {
  39685. private static _virtualScene;
  39686. private _ownerNode;
  39687. private _sceneRenderObserver;
  39688. private _scene;
  39689. private _targetPosition;
  39690. private _virtualOriginMesh;
  39691. private _virtualDragMesh;
  39692. private _pointerObserver;
  39693. private _moving;
  39694. private _startingOrientation;
  39695. private _attachedElement;
  39696. /**
  39697. * 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)
  39698. */
  39699. private zDragFactor;
  39700. /**
  39701. * If the object should rotate to face the drag origin
  39702. */
  39703. rotateDraggedObject: boolean;
  39704. /**
  39705. * If the behavior is currently in a dragging state
  39706. */
  39707. dragging: boolean;
  39708. /**
  39709. * 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)
  39710. */
  39711. dragDeltaRatio: number;
  39712. /**
  39713. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39714. */
  39715. currentDraggingPointerID: number;
  39716. /**
  39717. * If camera controls should be detached during the drag
  39718. */
  39719. detachCameraControls: boolean;
  39720. /**
  39721. * Fires each time a drag starts
  39722. */
  39723. onDragStartObservable: Observable<{}>;
  39724. /**
  39725. * Fires each time a drag ends (eg. mouse release after drag)
  39726. */
  39727. onDragEndObservable: Observable<{}>;
  39728. /**
  39729. * 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
  39730. */
  39731. constructor();
  39732. /**
  39733. * The name of the behavior
  39734. */
  39735. get name(): string;
  39736. /**
  39737. * Initializes the behavior
  39738. */
  39739. init(): void;
  39740. /**
  39741. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39742. */
  39743. private get _pointerCamera();
  39744. /**
  39745. * Attaches the scale behavior the passed in mesh
  39746. * @param ownerNode The mesh that will be scaled around once attached
  39747. */
  39748. attach(ownerNode: Mesh): void;
  39749. /**
  39750. * Detaches the behavior from the mesh
  39751. */
  39752. detach(): void;
  39753. }
  39754. }
  39755. declare module BABYLON {
  39756. /**
  39757. * Class used to apply inverse kinematics to bones
  39758. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39759. */
  39760. export class BoneIKController {
  39761. private static _tmpVecs;
  39762. private static _tmpQuat;
  39763. private static _tmpMats;
  39764. /**
  39765. * Gets or sets the target mesh
  39766. */
  39767. targetMesh: AbstractMesh;
  39768. /** Gets or sets the mesh used as pole */
  39769. poleTargetMesh: AbstractMesh;
  39770. /**
  39771. * Gets or sets the bone used as pole
  39772. */
  39773. poleTargetBone: Nullable<Bone>;
  39774. /**
  39775. * Gets or sets the target position
  39776. */
  39777. targetPosition: Vector3;
  39778. /**
  39779. * Gets or sets the pole target position
  39780. */
  39781. poleTargetPosition: Vector3;
  39782. /**
  39783. * Gets or sets the pole target local offset
  39784. */
  39785. poleTargetLocalOffset: Vector3;
  39786. /**
  39787. * Gets or sets the pole angle
  39788. */
  39789. poleAngle: number;
  39790. /**
  39791. * Gets or sets the mesh associated with the controller
  39792. */
  39793. mesh: AbstractMesh;
  39794. /**
  39795. * 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)
  39796. */
  39797. slerpAmount: number;
  39798. private _bone1Quat;
  39799. private _bone1Mat;
  39800. private _bone2Ang;
  39801. private _bone1;
  39802. private _bone2;
  39803. private _bone1Length;
  39804. private _bone2Length;
  39805. private _maxAngle;
  39806. private _maxReach;
  39807. private _rightHandedSystem;
  39808. private _bendAxis;
  39809. private _slerping;
  39810. private _adjustRoll;
  39811. /**
  39812. * Gets or sets maximum allowed angle
  39813. */
  39814. get maxAngle(): number;
  39815. set maxAngle(value: number);
  39816. /**
  39817. * Creates a new BoneIKController
  39818. * @param mesh defines the mesh to control
  39819. * @param bone defines the bone to control
  39820. * @param options defines options to set up the controller
  39821. */
  39822. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39823. targetMesh?: AbstractMesh;
  39824. poleTargetMesh?: AbstractMesh;
  39825. poleTargetBone?: Bone;
  39826. poleTargetLocalOffset?: Vector3;
  39827. poleAngle?: number;
  39828. bendAxis?: Vector3;
  39829. maxAngle?: number;
  39830. slerpAmount?: number;
  39831. });
  39832. private _setMaxAngle;
  39833. /**
  39834. * Force the controller to update the bones
  39835. */
  39836. update(): void;
  39837. }
  39838. }
  39839. declare module BABYLON {
  39840. /**
  39841. * Class used to make a bone look toward a point in space
  39842. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  39843. */
  39844. export class BoneLookController {
  39845. private static _tmpVecs;
  39846. private static _tmpQuat;
  39847. private static _tmpMats;
  39848. /**
  39849. * The target Vector3 that the bone will look at
  39850. */
  39851. target: Vector3;
  39852. /**
  39853. * The mesh that the bone is attached to
  39854. */
  39855. mesh: AbstractMesh;
  39856. /**
  39857. * The bone that will be looking to the target
  39858. */
  39859. bone: Bone;
  39860. /**
  39861. * The up axis of the coordinate system that is used when the bone is rotated
  39862. */
  39863. upAxis: Vector3;
  39864. /**
  39865. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  39866. */
  39867. upAxisSpace: Space;
  39868. /**
  39869. * Used to make an adjustment to the yaw of the bone
  39870. */
  39871. adjustYaw: number;
  39872. /**
  39873. * Used to make an adjustment to the pitch of the bone
  39874. */
  39875. adjustPitch: number;
  39876. /**
  39877. * Used to make an adjustment to the roll of the bone
  39878. */
  39879. adjustRoll: number;
  39880. /**
  39881. * 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)
  39882. */
  39883. slerpAmount: number;
  39884. private _minYaw;
  39885. private _maxYaw;
  39886. private _minPitch;
  39887. private _maxPitch;
  39888. private _minYawSin;
  39889. private _minYawCos;
  39890. private _maxYawSin;
  39891. private _maxYawCos;
  39892. private _midYawConstraint;
  39893. private _minPitchTan;
  39894. private _maxPitchTan;
  39895. private _boneQuat;
  39896. private _slerping;
  39897. private _transformYawPitch;
  39898. private _transformYawPitchInv;
  39899. private _firstFrameSkipped;
  39900. private _yawRange;
  39901. private _fowardAxis;
  39902. /**
  39903. * Gets or sets the minimum yaw angle that the bone can look to
  39904. */
  39905. get minYaw(): number;
  39906. set minYaw(value: number);
  39907. /**
  39908. * Gets or sets the maximum yaw angle that the bone can look to
  39909. */
  39910. get maxYaw(): number;
  39911. set maxYaw(value: number);
  39912. /**
  39913. * Gets or sets the minimum pitch angle that the bone can look to
  39914. */
  39915. get minPitch(): number;
  39916. set minPitch(value: number);
  39917. /**
  39918. * Gets or sets the maximum pitch angle that the bone can look to
  39919. */
  39920. get maxPitch(): number;
  39921. set maxPitch(value: number);
  39922. /**
  39923. * Create a BoneLookController
  39924. * @param mesh the mesh that the bone belongs to
  39925. * @param bone the bone that will be looking to the target
  39926. * @param target the target Vector3 to look at
  39927. * @param options optional settings:
  39928. * * maxYaw: the maximum angle the bone will yaw to
  39929. * * minYaw: the minimum angle the bone will yaw to
  39930. * * maxPitch: the maximum angle the bone will pitch to
  39931. * * minPitch: the minimum angle the bone will yaw to
  39932. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  39933. * * upAxis: the up axis of the coordinate system
  39934. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  39935. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  39936. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  39937. * * adjustYaw: used to make an adjustment to the yaw of the bone
  39938. * * adjustPitch: used to make an adjustment to the pitch of the bone
  39939. * * adjustRoll: used to make an adjustment to the roll of the bone
  39940. **/
  39941. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  39942. maxYaw?: number;
  39943. minYaw?: number;
  39944. maxPitch?: number;
  39945. minPitch?: number;
  39946. slerpAmount?: number;
  39947. upAxis?: Vector3;
  39948. upAxisSpace?: Space;
  39949. yawAxis?: Vector3;
  39950. pitchAxis?: Vector3;
  39951. adjustYaw?: number;
  39952. adjustPitch?: number;
  39953. adjustRoll?: number;
  39954. });
  39955. /**
  39956. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  39957. */
  39958. update(): void;
  39959. private _getAngleDiff;
  39960. private _getAngleBetween;
  39961. private _isAngleBetween;
  39962. }
  39963. }
  39964. declare module BABYLON {
  39965. /**
  39966. * Manage the gamepad inputs to control an arc rotate camera.
  39967. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39968. */
  39969. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  39970. /**
  39971. * Defines the camera the input is attached to.
  39972. */
  39973. camera: ArcRotateCamera;
  39974. /**
  39975. * Defines the gamepad the input is gathering event from.
  39976. */
  39977. gamepad: Nullable<Gamepad>;
  39978. /**
  39979. * Defines the gamepad rotation sensiblity.
  39980. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39981. */
  39982. gamepadRotationSensibility: number;
  39983. /**
  39984. * Defines the gamepad move sensiblity.
  39985. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39986. */
  39987. gamepadMoveSensibility: number;
  39988. private _yAxisScale;
  39989. /**
  39990. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39991. */
  39992. get invertYAxis(): boolean;
  39993. set invertYAxis(value: boolean);
  39994. private _onGamepadConnectedObserver;
  39995. private _onGamepadDisconnectedObserver;
  39996. /**
  39997. * Attach the input controls to a specific dom element to get the input from.
  39998. * @param element Defines the element the controls should be listened from
  39999. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40000. */
  40001. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40002. /**
  40003. * Detach the current controls from the specified dom element.
  40004. * @param element Defines the element to stop listening the inputs from
  40005. */
  40006. detachControl(element: Nullable<HTMLElement>): void;
  40007. /**
  40008. * Update the current camera state depending on the inputs that have been used this frame.
  40009. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40010. */
  40011. checkInputs(): void;
  40012. /**
  40013. * Gets the class name of the current intput.
  40014. * @returns the class name
  40015. */
  40016. getClassName(): string;
  40017. /**
  40018. * Get the friendly name associated with the input class.
  40019. * @returns the input friendly name
  40020. */
  40021. getSimpleName(): string;
  40022. }
  40023. }
  40024. declare module BABYLON {
  40025. interface ArcRotateCameraInputsManager {
  40026. /**
  40027. * Add orientation input support to the input manager.
  40028. * @returns the current input manager
  40029. */
  40030. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40031. }
  40032. /**
  40033. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40034. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40035. */
  40036. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40037. /**
  40038. * Defines the camera the input is attached to.
  40039. */
  40040. camera: ArcRotateCamera;
  40041. /**
  40042. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40043. */
  40044. alphaCorrection: number;
  40045. /**
  40046. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40047. */
  40048. gammaCorrection: number;
  40049. private _alpha;
  40050. private _gamma;
  40051. private _dirty;
  40052. private _deviceOrientationHandler;
  40053. /**
  40054. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40055. */
  40056. constructor();
  40057. /**
  40058. * Attach the input controls to a specific dom element to get the input from.
  40059. * @param element Defines the element the controls should be listened from
  40060. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40061. */
  40062. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40063. /** @hidden */
  40064. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40065. /**
  40066. * Update the current camera state depending on the inputs that have been used this frame.
  40067. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40068. */
  40069. checkInputs(): void;
  40070. /**
  40071. * Detach the current controls from the specified dom element.
  40072. * @param element Defines the element to stop listening the inputs from
  40073. */
  40074. detachControl(element: Nullable<HTMLElement>): void;
  40075. /**
  40076. * Gets the class name of the current intput.
  40077. * @returns the class name
  40078. */
  40079. getClassName(): string;
  40080. /**
  40081. * Get the friendly name associated with the input class.
  40082. * @returns the input friendly name
  40083. */
  40084. getSimpleName(): string;
  40085. }
  40086. }
  40087. declare module BABYLON {
  40088. /**
  40089. * Listen to mouse events to control the camera.
  40090. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40091. */
  40092. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40093. /**
  40094. * Defines the camera the input is attached to.
  40095. */
  40096. camera: FlyCamera;
  40097. /**
  40098. * Defines if touch is enabled. (Default is true.)
  40099. */
  40100. touchEnabled: boolean;
  40101. /**
  40102. * Defines the buttons associated with the input to handle camera rotation.
  40103. */
  40104. buttons: number[];
  40105. /**
  40106. * Assign buttons for Yaw control.
  40107. */
  40108. buttonsYaw: number[];
  40109. /**
  40110. * Assign buttons for Pitch control.
  40111. */
  40112. buttonsPitch: number[];
  40113. /**
  40114. * Assign buttons for Roll control.
  40115. */
  40116. buttonsRoll: number[];
  40117. /**
  40118. * Detect if any button is being pressed while mouse is moved.
  40119. * -1 = Mouse locked.
  40120. * 0 = Left button.
  40121. * 1 = Middle Button.
  40122. * 2 = Right Button.
  40123. */
  40124. activeButton: number;
  40125. /**
  40126. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40127. * Higher values reduce its sensitivity.
  40128. */
  40129. angularSensibility: number;
  40130. private _mousemoveCallback;
  40131. private _observer;
  40132. private _rollObserver;
  40133. private previousPosition;
  40134. private noPreventDefault;
  40135. private element;
  40136. /**
  40137. * Listen to mouse events to control the camera.
  40138. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40139. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40140. */
  40141. constructor(touchEnabled?: boolean);
  40142. /**
  40143. * Attach the mouse control to the HTML DOM element.
  40144. * @param element Defines the element that listens to the input events.
  40145. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40146. */
  40147. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40148. /**
  40149. * Detach the current controls from the specified dom element.
  40150. * @param element Defines the element to stop listening the inputs from
  40151. */
  40152. detachControl(element: Nullable<HTMLElement>): void;
  40153. /**
  40154. * Gets the class name of the current input.
  40155. * @returns the class name.
  40156. */
  40157. getClassName(): string;
  40158. /**
  40159. * Get the friendly name associated with the input class.
  40160. * @returns the input's friendly name.
  40161. */
  40162. getSimpleName(): string;
  40163. private _pointerInput;
  40164. private _onMouseMove;
  40165. /**
  40166. * Rotate camera by mouse offset.
  40167. */
  40168. private rotateCamera;
  40169. }
  40170. }
  40171. declare module BABYLON {
  40172. /**
  40173. * Default Inputs manager for the FlyCamera.
  40174. * It groups all the default supported inputs for ease of use.
  40175. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40176. */
  40177. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40178. /**
  40179. * Instantiates a new FlyCameraInputsManager.
  40180. * @param camera Defines the camera the inputs belong to.
  40181. */
  40182. constructor(camera: FlyCamera);
  40183. /**
  40184. * Add keyboard input support to the input manager.
  40185. * @returns the new FlyCameraKeyboardMoveInput().
  40186. */
  40187. addKeyboard(): FlyCameraInputsManager;
  40188. /**
  40189. * Add mouse input support to the input manager.
  40190. * @param touchEnabled Enable touch screen support.
  40191. * @returns the new FlyCameraMouseInput().
  40192. */
  40193. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40194. }
  40195. }
  40196. declare module BABYLON {
  40197. /**
  40198. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40199. * such as in a 3D Space Shooter or a Flight Simulator.
  40200. */
  40201. export class FlyCamera extends TargetCamera {
  40202. /**
  40203. * Define the collision ellipsoid of the camera.
  40204. * This is helpful for simulating a camera body, like a player's body.
  40205. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40206. */
  40207. ellipsoid: Vector3;
  40208. /**
  40209. * Define an offset for the position of the ellipsoid around the camera.
  40210. * This can be helpful if the camera is attached away from the player's body center,
  40211. * such as at its head.
  40212. */
  40213. ellipsoidOffset: Vector3;
  40214. /**
  40215. * Enable or disable collisions of the camera with the rest of the scene objects.
  40216. */
  40217. checkCollisions: boolean;
  40218. /**
  40219. * Enable or disable gravity on the camera.
  40220. */
  40221. applyGravity: boolean;
  40222. /**
  40223. * Define the current direction the camera is moving to.
  40224. */
  40225. cameraDirection: Vector3;
  40226. /**
  40227. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40228. * This overrides and empties cameraRotation.
  40229. */
  40230. rotationQuaternion: Quaternion;
  40231. /**
  40232. * Track Roll to maintain the wanted Rolling when looking around.
  40233. */
  40234. _trackRoll: number;
  40235. /**
  40236. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40237. */
  40238. rollCorrect: number;
  40239. /**
  40240. * Mimic a banked turn, Rolling the camera when Yawing.
  40241. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40242. */
  40243. bankedTurn: boolean;
  40244. /**
  40245. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40246. */
  40247. bankedTurnLimit: number;
  40248. /**
  40249. * Value of 0 disables the banked Roll.
  40250. * Value of 1 is equal to the Yaw angle in radians.
  40251. */
  40252. bankedTurnMultiplier: number;
  40253. /**
  40254. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40255. */
  40256. inputs: FlyCameraInputsManager;
  40257. /**
  40258. * Gets the input sensibility for mouse input.
  40259. * Higher values reduce sensitivity.
  40260. */
  40261. get angularSensibility(): number;
  40262. /**
  40263. * Sets the input sensibility for a mouse input.
  40264. * Higher values reduce sensitivity.
  40265. */
  40266. set angularSensibility(value: number);
  40267. /**
  40268. * Get the keys for camera movement forward.
  40269. */
  40270. get keysForward(): number[];
  40271. /**
  40272. * Set the keys for camera movement forward.
  40273. */
  40274. set keysForward(value: number[]);
  40275. /**
  40276. * Get the keys for camera movement backward.
  40277. */
  40278. get keysBackward(): number[];
  40279. set keysBackward(value: number[]);
  40280. /**
  40281. * Get the keys for camera movement up.
  40282. */
  40283. get keysUp(): number[];
  40284. /**
  40285. * Set the keys for camera movement up.
  40286. */
  40287. set keysUp(value: number[]);
  40288. /**
  40289. * Get the keys for camera movement down.
  40290. */
  40291. get keysDown(): number[];
  40292. /**
  40293. * Set the keys for camera movement down.
  40294. */
  40295. set keysDown(value: number[]);
  40296. /**
  40297. * Get the keys for camera movement left.
  40298. */
  40299. get keysLeft(): number[];
  40300. /**
  40301. * Set the keys for camera movement left.
  40302. */
  40303. set keysLeft(value: number[]);
  40304. /**
  40305. * Set the keys for camera movement right.
  40306. */
  40307. get keysRight(): number[];
  40308. /**
  40309. * Set the keys for camera movement right.
  40310. */
  40311. set keysRight(value: number[]);
  40312. /**
  40313. * Event raised when the camera collides with a mesh in the scene.
  40314. */
  40315. onCollide: (collidedMesh: AbstractMesh) => void;
  40316. private _collider;
  40317. private _needMoveForGravity;
  40318. private _oldPosition;
  40319. private _diffPosition;
  40320. private _newPosition;
  40321. /** @hidden */
  40322. _localDirection: Vector3;
  40323. /** @hidden */
  40324. _transformedDirection: Vector3;
  40325. /**
  40326. * Instantiates a FlyCamera.
  40327. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40328. * such as in a 3D Space Shooter or a Flight Simulator.
  40329. * @param name Define the name of the camera in the scene.
  40330. * @param position Define the starting position of the camera in the scene.
  40331. * @param scene Define the scene the camera belongs to.
  40332. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40333. */
  40334. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40335. /**
  40336. * Attach a control to the HTML DOM element.
  40337. * @param element Defines the element that listens to the input events.
  40338. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40339. */
  40340. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40341. /**
  40342. * Detach a control from the HTML DOM element.
  40343. * The camera will stop reacting to that input.
  40344. * @param element Defines the element that listens to the input events.
  40345. */
  40346. detachControl(element: HTMLElement): void;
  40347. private _collisionMask;
  40348. /**
  40349. * Get the mask that the camera ignores in collision events.
  40350. */
  40351. get collisionMask(): number;
  40352. /**
  40353. * Set the mask that the camera ignores in collision events.
  40354. */
  40355. set collisionMask(mask: number);
  40356. /** @hidden */
  40357. _collideWithWorld(displacement: Vector3): void;
  40358. /** @hidden */
  40359. private _onCollisionPositionChange;
  40360. /** @hidden */
  40361. _checkInputs(): void;
  40362. /** @hidden */
  40363. _decideIfNeedsToMove(): boolean;
  40364. /** @hidden */
  40365. _updatePosition(): void;
  40366. /**
  40367. * Restore the Roll to its target value at the rate specified.
  40368. * @param rate - Higher means slower restoring.
  40369. * @hidden
  40370. */
  40371. restoreRoll(rate: number): void;
  40372. /**
  40373. * Destroy the camera and release the current resources held by it.
  40374. */
  40375. dispose(): void;
  40376. /**
  40377. * Get the current object class name.
  40378. * @returns the class name.
  40379. */
  40380. getClassName(): string;
  40381. }
  40382. }
  40383. declare module BABYLON {
  40384. /**
  40385. * Listen to keyboard events to control the camera.
  40386. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40387. */
  40388. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40389. /**
  40390. * Defines the camera the input is attached to.
  40391. */
  40392. camera: FlyCamera;
  40393. /**
  40394. * The list of keyboard keys used to control the forward move of the camera.
  40395. */
  40396. keysForward: number[];
  40397. /**
  40398. * The list of keyboard keys used to control the backward move of the camera.
  40399. */
  40400. keysBackward: number[];
  40401. /**
  40402. * The list of keyboard keys used to control the forward move of the camera.
  40403. */
  40404. keysUp: number[];
  40405. /**
  40406. * The list of keyboard keys used to control the backward move of the camera.
  40407. */
  40408. keysDown: number[];
  40409. /**
  40410. * The list of keyboard keys used to control the right strafe move of the camera.
  40411. */
  40412. keysRight: number[];
  40413. /**
  40414. * The list of keyboard keys used to control the left strafe move of the camera.
  40415. */
  40416. keysLeft: number[];
  40417. private _keys;
  40418. private _onCanvasBlurObserver;
  40419. private _onKeyboardObserver;
  40420. private _engine;
  40421. private _scene;
  40422. /**
  40423. * Attach the input controls to a specific dom element to get the input from.
  40424. * @param element Defines the element the controls should be listened from
  40425. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40426. */
  40427. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40428. /**
  40429. * Detach the current controls from the specified dom element.
  40430. * @param element Defines the element to stop listening the inputs from
  40431. */
  40432. detachControl(element: Nullable<HTMLElement>): void;
  40433. /**
  40434. * Gets the class name of the current intput.
  40435. * @returns the class name
  40436. */
  40437. getClassName(): string;
  40438. /** @hidden */
  40439. _onLostFocus(e: FocusEvent): void;
  40440. /**
  40441. * Get the friendly name associated with the input class.
  40442. * @returns the input friendly name
  40443. */
  40444. getSimpleName(): string;
  40445. /**
  40446. * Update the current camera state depending on the inputs that have been used this frame.
  40447. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40448. */
  40449. checkInputs(): void;
  40450. }
  40451. }
  40452. declare module BABYLON {
  40453. /**
  40454. * Manage the mouse wheel inputs to control a follow camera.
  40455. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40456. */
  40457. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40458. /**
  40459. * Defines the camera the input is attached to.
  40460. */
  40461. camera: FollowCamera;
  40462. /**
  40463. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40464. */
  40465. axisControlRadius: boolean;
  40466. /**
  40467. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40468. */
  40469. axisControlHeight: boolean;
  40470. /**
  40471. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40472. */
  40473. axisControlRotation: boolean;
  40474. /**
  40475. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40476. * relation to mouseWheel events.
  40477. */
  40478. wheelPrecision: number;
  40479. /**
  40480. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40481. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40482. */
  40483. wheelDeltaPercentage: number;
  40484. private _wheel;
  40485. private _observer;
  40486. /**
  40487. * Attach the input controls to a specific dom element to get the input from.
  40488. * @param element Defines the element the controls should be listened from
  40489. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40490. */
  40491. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40492. /**
  40493. * Detach the current controls from the specified dom element.
  40494. * @param element Defines the element to stop listening the inputs from
  40495. */
  40496. detachControl(element: Nullable<HTMLElement>): void;
  40497. /**
  40498. * Gets the class name of the current intput.
  40499. * @returns the class name
  40500. */
  40501. getClassName(): string;
  40502. /**
  40503. * Get the friendly name associated with the input class.
  40504. * @returns the input friendly name
  40505. */
  40506. getSimpleName(): string;
  40507. }
  40508. }
  40509. declare module BABYLON {
  40510. /**
  40511. * Manage the pointers inputs to control an follow camera.
  40512. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40513. */
  40514. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40515. /**
  40516. * Defines the camera the input is attached to.
  40517. */
  40518. camera: FollowCamera;
  40519. /**
  40520. * Gets the class name of the current input.
  40521. * @returns the class name
  40522. */
  40523. getClassName(): string;
  40524. /**
  40525. * Defines the pointer angular sensibility along the X axis or how fast is
  40526. * the camera rotating.
  40527. * A negative number will reverse the axis direction.
  40528. */
  40529. angularSensibilityX: number;
  40530. /**
  40531. * Defines the pointer angular sensibility along the Y axis or how fast is
  40532. * the camera rotating.
  40533. * A negative number will reverse the axis direction.
  40534. */
  40535. angularSensibilityY: number;
  40536. /**
  40537. * Defines the pointer pinch precision or how fast is the camera zooming.
  40538. * A negative number will reverse the axis direction.
  40539. */
  40540. pinchPrecision: number;
  40541. /**
  40542. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40543. * from 0.
  40544. * It defines the percentage of current camera.radius to use as delta when
  40545. * pinch zoom is used.
  40546. */
  40547. pinchDeltaPercentage: number;
  40548. /**
  40549. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40550. */
  40551. axisXControlRadius: boolean;
  40552. /**
  40553. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40554. */
  40555. axisXControlHeight: boolean;
  40556. /**
  40557. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40558. */
  40559. axisXControlRotation: boolean;
  40560. /**
  40561. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40562. */
  40563. axisYControlRadius: boolean;
  40564. /**
  40565. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40566. */
  40567. axisYControlHeight: boolean;
  40568. /**
  40569. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40570. */
  40571. axisYControlRotation: boolean;
  40572. /**
  40573. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40574. */
  40575. axisPinchControlRadius: boolean;
  40576. /**
  40577. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40578. */
  40579. axisPinchControlHeight: boolean;
  40580. /**
  40581. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40582. */
  40583. axisPinchControlRotation: boolean;
  40584. /**
  40585. * Log error messages if basic misconfiguration has occurred.
  40586. */
  40587. warningEnable: boolean;
  40588. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40589. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40590. private _warningCounter;
  40591. private _warning;
  40592. }
  40593. }
  40594. declare module BABYLON {
  40595. /**
  40596. * Default Inputs manager for the FollowCamera.
  40597. * It groups all the default supported inputs for ease of use.
  40598. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40599. */
  40600. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40601. /**
  40602. * Instantiates a new FollowCameraInputsManager.
  40603. * @param camera Defines the camera the inputs belong to
  40604. */
  40605. constructor(camera: FollowCamera);
  40606. /**
  40607. * Add keyboard input support to the input manager.
  40608. * @returns the current input manager
  40609. */
  40610. addKeyboard(): FollowCameraInputsManager;
  40611. /**
  40612. * Add mouse wheel input support to the input manager.
  40613. * @returns the current input manager
  40614. */
  40615. addMouseWheel(): FollowCameraInputsManager;
  40616. /**
  40617. * Add pointers input support to the input manager.
  40618. * @returns the current input manager
  40619. */
  40620. addPointers(): FollowCameraInputsManager;
  40621. /**
  40622. * Add orientation input support to the input manager.
  40623. * @returns the current input manager
  40624. */
  40625. addVRDeviceOrientation(): FollowCameraInputsManager;
  40626. }
  40627. }
  40628. declare module BABYLON {
  40629. /**
  40630. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40631. * an arc rotate version arcFollowCamera are available.
  40632. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40633. */
  40634. export class FollowCamera extends TargetCamera {
  40635. /**
  40636. * Distance the follow camera should follow an object at
  40637. */
  40638. radius: number;
  40639. /**
  40640. * Minimum allowed distance of the camera to the axis of rotation
  40641. * (The camera can not get closer).
  40642. * This can help limiting how the Camera is able to move in the scene.
  40643. */
  40644. lowerRadiusLimit: Nullable<number>;
  40645. /**
  40646. * Maximum allowed distance of the camera to the axis of rotation
  40647. * (The camera can not get further).
  40648. * This can help limiting how the Camera is able to move in the scene.
  40649. */
  40650. upperRadiusLimit: Nullable<number>;
  40651. /**
  40652. * Define a rotation offset between the camera and the object it follows
  40653. */
  40654. rotationOffset: number;
  40655. /**
  40656. * Minimum allowed angle to camera position relative to target object.
  40657. * This can help limiting how the Camera is able to move in the scene.
  40658. */
  40659. lowerRotationOffsetLimit: Nullable<number>;
  40660. /**
  40661. * Maximum allowed angle to camera position relative to target object.
  40662. * This can help limiting how the Camera is able to move in the scene.
  40663. */
  40664. upperRotationOffsetLimit: Nullable<number>;
  40665. /**
  40666. * Define a height offset between the camera and the object it follows.
  40667. * It can help following an object from the top (like a car chaing a plane)
  40668. */
  40669. heightOffset: number;
  40670. /**
  40671. * Minimum allowed height of camera position relative to target object.
  40672. * This can help limiting how the Camera is able to move in the scene.
  40673. */
  40674. lowerHeightOffsetLimit: Nullable<number>;
  40675. /**
  40676. * Maximum allowed height of camera position relative to target object.
  40677. * This can help limiting how the Camera is able to move in the scene.
  40678. */
  40679. upperHeightOffsetLimit: Nullable<number>;
  40680. /**
  40681. * Define how fast the camera can accelerate to follow it s target.
  40682. */
  40683. cameraAcceleration: number;
  40684. /**
  40685. * Define the speed limit of the camera following an object.
  40686. */
  40687. maxCameraSpeed: number;
  40688. /**
  40689. * Define the target of the camera.
  40690. */
  40691. lockedTarget: Nullable<AbstractMesh>;
  40692. /**
  40693. * Defines the input associated with the camera.
  40694. */
  40695. inputs: FollowCameraInputsManager;
  40696. /**
  40697. * Instantiates the follow camera.
  40698. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40699. * @param name Define the name of the camera in the scene
  40700. * @param position Define the position of the camera
  40701. * @param scene Define the scene the camera belong to
  40702. * @param lockedTarget Define the target of the camera
  40703. */
  40704. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40705. private _follow;
  40706. /**
  40707. * Attached controls to the current camera.
  40708. * @param element Defines the element the controls should be listened from
  40709. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40710. */
  40711. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40712. /**
  40713. * Detach the current controls from the camera.
  40714. * The camera will stop reacting to inputs.
  40715. * @param element Defines the element to stop listening the inputs from
  40716. */
  40717. detachControl(element: HTMLElement): void;
  40718. /** @hidden */
  40719. _checkInputs(): void;
  40720. private _checkLimits;
  40721. /**
  40722. * Gets the camera class name.
  40723. * @returns the class name
  40724. */
  40725. getClassName(): string;
  40726. }
  40727. /**
  40728. * Arc Rotate version of the follow camera.
  40729. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40730. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40731. */
  40732. export class ArcFollowCamera extends TargetCamera {
  40733. /** The longitudinal angle of the camera */
  40734. alpha: number;
  40735. /** The latitudinal angle of the camera */
  40736. beta: number;
  40737. /** The radius of the camera from its target */
  40738. radius: number;
  40739. /** Define the camera target (the messh it should follow) */
  40740. target: Nullable<AbstractMesh>;
  40741. private _cartesianCoordinates;
  40742. /**
  40743. * Instantiates a new ArcFollowCamera
  40744. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40745. * @param name Define the name of the camera
  40746. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40747. * @param beta Define the rotation angle of the camera around the elevation axis
  40748. * @param radius Define the radius of the camera from its target point
  40749. * @param target Define the target of the camera
  40750. * @param scene Define the scene the camera belongs to
  40751. */
  40752. constructor(name: string,
  40753. /** The longitudinal angle of the camera */
  40754. alpha: number,
  40755. /** The latitudinal angle of the camera */
  40756. beta: number,
  40757. /** The radius of the camera from its target */
  40758. radius: number,
  40759. /** Define the camera target (the messh it should follow) */
  40760. target: Nullable<AbstractMesh>, scene: Scene);
  40761. private _follow;
  40762. /** @hidden */
  40763. _checkInputs(): void;
  40764. /**
  40765. * Returns the class name of the object.
  40766. * It is mostly used internally for serialization purposes.
  40767. */
  40768. getClassName(): string;
  40769. }
  40770. }
  40771. declare module BABYLON {
  40772. /**
  40773. * Manage the keyboard inputs to control the movement of a follow camera.
  40774. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40775. */
  40776. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40777. /**
  40778. * Defines the camera the input is attached to.
  40779. */
  40780. camera: FollowCamera;
  40781. /**
  40782. * Defines the list of key codes associated with the up action (increase heightOffset)
  40783. */
  40784. keysHeightOffsetIncr: number[];
  40785. /**
  40786. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40787. */
  40788. keysHeightOffsetDecr: number[];
  40789. /**
  40790. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40791. */
  40792. keysHeightOffsetModifierAlt: boolean;
  40793. /**
  40794. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40795. */
  40796. keysHeightOffsetModifierCtrl: boolean;
  40797. /**
  40798. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40799. */
  40800. keysHeightOffsetModifierShift: boolean;
  40801. /**
  40802. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40803. */
  40804. keysRotationOffsetIncr: number[];
  40805. /**
  40806. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40807. */
  40808. keysRotationOffsetDecr: number[];
  40809. /**
  40810. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40811. */
  40812. keysRotationOffsetModifierAlt: boolean;
  40813. /**
  40814. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40815. */
  40816. keysRotationOffsetModifierCtrl: boolean;
  40817. /**
  40818. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  40819. */
  40820. keysRotationOffsetModifierShift: boolean;
  40821. /**
  40822. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  40823. */
  40824. keysRadiusIncr: number[];
  40825. /**
  40826. * Defines the list of key codes associated with the zoom-out action (increase radius)
  40827. */
  40828. keysRadiusDecr: number[];
  40829. /**
  40830. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  40831. */
  40832. keysRadiusModifierAlt: boolean;
  40833. /**
  40834. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  40835. */
  40836. keysRadiusModifierCtrl: boolean;
  40837. /**
  40838. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  40839. */
  40840. keysRadiusModifierShift: boolean;
  40841. /**
  40842. * Defines the rate of change of heightOffset.
  40843. */
  40844. heightSensibility: number;
  40845. /**
  40846. * Defines the rate of change of rotationOffset.
  40847. */
  40848. rotationSensibility: number;
  40849. /**
  40850. * Defines the rate of change of radius.
  40851. */
  40852. radiusSensibility: number;
  40853. private _keys;
  40854. private _ctrlPressed;
  40855. private _altPressed;
  40856. private _shiftPressed;
  40857. private _onCanvasBlurObserver;
  40858. private _onKeyboardObserver;
  40859. private _engine;
  40860. private _scene;
  40861. /**
  40862. * Attach the input controls to a specific dom element to get the input from.
  40863. * @param element Defines the element the controls should be listened from
  40864. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40865. */
  40866. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40867. /**
  40868. * Detach the current controls from the specified dom element.
  40869. * @param element Defines the element to stop listening the inputs from
  40870. */
  40871. detachControl(element: Nullable<HTMLElement>): void;
  40872. /**
  40873. * Update the current camera state depending on the inputs that have been used this frame.
  40874. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40875. */
  40876. checkInputs(): void;
  40877. /**
  40878. * Gets the class name of the current input.
  40879. * @returns the class name
  40880. */
  40881. getClassName(): string;
  40882. /**
  40883. * Get the friendly name associated with the input class.
  40884. * @returns the input friendly name
  40885. */
  40886. getSimpleName(): string;
  40887. /**
  40888. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40889. * allow modification of the heightOffset value.
  40890. */
  40891. private _modifierHeightOffset;
  40892. /**
  40893. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40894. * allow modification of the rotationOffset value.
  40895. */
  40896. private _modifierRotationOffset;
  40897. /**
  40898. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40899. * allow modification of the radius value.
  40900. */
  40901. private _modifierRadius;
  40902. }
  40903. }
  40904. declare module BABYLON {
  40905. interface FreeCameraInputsManager {
  40906. /**
  40907. * @hidden
  40908. */
  40909. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  40910. /**
  40911. * Add orientation input support to the input manager.
  40912. * @returns the current input manager
  40913. */
  40914. addDeviceOrientation(): FreeCameraInputsManager;
  40915. }
  40916. /**
  40917. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40918. * Screen rotation is taken into account.
  40919. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40920. */
  40921. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40922. private _camera;
  40923. private _screenOrientationAngle;
  40924. private _constantTranform;
  40925. private _screenQuaternion;
  40926. private _alpha;
  40927. private _beta;
  40928. private _gamma;
  40929. /**
  40930. * Can be used to detect if a device orientation sensor is available on a device
  40931. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40932. * @returns a promise that will resolve on orientation change
  40933. */
  40934. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40935. /**
  40936. * @hidden
  40937. */
  40938. _onDeviceOrientationChangedObservable: Observable<void>;
  40939. /**
  40940. * Instantiates a new input
  40941. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40942. */
  40943. constructor();
  40944. /**
  40945. * Define the camera controlled by the input.
  40946. */
  40947. get camera(): FreeCamera;
  40948. set camera(camera: FreeCamera);
  40949. /**
  40950. * Attach the input controls to a specific dom element to get the input from.
  40951. * @param element Defines the element the controls should be listened from
  40952. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40953. */
  40954. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40955. private _orientationChanged;
  40956. private _deviceOrientation;
  40957. /**
  40958. * Detach the current controls from the specified dom element.
  40959. * @param element Defines the element to stop listening the inputs from
  40960. */
  40961. detachControl(element: Nullable<HTMLElement>): void;
  40962. /**
  40963. * Update the current camera state depending on the inputs that have been used this frame.
  40964. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40965. */
  40966. checkInputs(): void;
  40967. /**
  40968. * Gets the class name of the current intput.
  40969. * @returns the class name
  40970. */
  40971. getClassName(): string;
  40972. /**
  40973. * Get the friendly name associated with the input class.
  40974. * @returns the input friendly name
  40975. */
  40976. getSimpleName(): string;
  40977. }
  40978. }
  40979. declare module BABYLON {
  40980. /**
  40981. * Manage the gamepad inputs to control a free camera.
  40982. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40983. */
  40984. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  40985. /**
  40986. * Define the camera the input is attached to.
  40987. */
  40988. camera: FreeCamera;
  40989. /**
  40990. * Define the Gamepad controlling the input
  40991. */
  40992. gamepad: Nullable<Gamepad>;
  40993. /**
  40994. * Defines the gamepad rotation sensiblity.
  40995. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40996. */
  40997. gamepadAngularSensibility: number;
  40998. /**
  40999. * Defines the gamepad move sensiblity.
  41000. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41001. */
  41002. gamepadMoveSensibility: number;
  41003. private _yAxisScale;
  41004. /**
  41005. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41006. */
  41007. get invertYAxis(): boolean;
  41008. set invertYAxis(value: boolean);
  41009. private _onGamepadConnectedObserver;
  41010. private _onGamepadDisconnectedObserver;
  41011. private _cameraTransform;
  41012. private _deltaTransform;
  41013. private _vector3;
  41014. private _vector2;
  41015. /**
  41016. * Attach the input controls to a specific dom element to get the input from.
  41017. * @param element Defines the element the controls should be listened from
  41018. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41019. */
  41020. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41021. /**
  41022. * Detach the current controls from the specified dom element.
  41023. * @param element Defines the element to stop listening the inputs from
  41024. */
  41025. detachControl(element: Nullable<HTMLElement>): void;
  41026. /**
  41027. * Update the current camera state depending on the inputs that have been used this frame.
  41028. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41029. */
  41030. checkInputs(): void;
  41031. /**
  41032. * Gets the class name of the current intput.
  41033. * @returns the class name
  41034. */
  41035. getClassName(): string;
  41036. /**
  41037. * Get the friendly name associated with the input class.
  41038. * @returns the input friendly name
  41039. */
  41040. getSimpleName(): string;
  41041. }
  41042. }
  41043. declare module BABYLON {
  41044. /**
  41045. * Defines the potential axis of a Joystick
  41046. */
  41047. export enum JoystickAxis {
  41048. /** X axis */
  41049. X = 0,
  41050. /** Y axis */
  41051. Y = 1,
  41052. /** Z axis */
  41053. Z = 2
  41054. }
  41055. /**
  41056. * Class used to define virtual joystick (used in touch mode)
  41057. */
  41058. export class VirtualJoystick {
  41059. /**
  41060. * Gets or sets a boolean indicating that left and right values must be inverted
  41061. */
  41062. reverseLeftRight: boolean;
  41063. /**
  41064. * Gets or sets a boolean indicating that up and down values must be inverted
  41065. */
  41066. reverseUpDown: boolean;
  41067. /**
  41068. * Gets the offset value for the position (ie. the change of the position value)
  41069. */
  41070. deltaPosition: Vector3;
  41071. /**
  41072. * Gets a boolean indicating if the virtual joystick was pressed
  41073. */
  41074. pressed: boolean;
  41075. /**
  41076. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41077. */
  41078. static Canvas: Nullable<HTMLCanvasElement>;
  41079. private static _globalJoystickIndex;
  41080. private static vjCanvasContext;
  41081. private static vjCanvasWidth;
  41082. private static vjCanvasHeight;
  41083. private static halfWidth;
  41084. private _action;
  41085. private _axisTargetedByLeftAndRight;
  41086. private _axisTargetedByUpAndDown;
  41087. private _joystickSensibility;
  41088. private _inversedSensibility;
  41089. private _joystickPointerID;
  41090. private _joystickColor;
  41091. private _joystickPointerPos;
  41092. private _joystickPreviousPointerPos;
  41093. private _joystickPointerStartPos;
  41094. private _deltaJoystickVector;
  41095. private _leftJoystick;
  41096. private _touches;
  41097. private _onPointerDownHandlerRef;
  41098. private _onPointerMoveHandlerRef;
  41099. private _onPointerUpHandlerRef;
  41100. private _onResize;
  41101. /**
  41102. * Creates a new virtual joystick
  41103. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41104. */
  41105. constructor(leftJoystick?: boolean);
  41106. /**
  41107. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41108. * @param newJoystickSensibility defines the new sensibility
  41109. */
  41110. setJoystickSensibility(newJoystickSensibility: number): void;
  41111. private _onPointerDown;
  41112. private _onPointerMove;
  41113. private _onPointerUp;
  41114. /**
  41115. * Change the color of the virtual joystick
  41116. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41117. */
  41118. setJoystickColor(newColor: string): void;
  41119. /**
  41120. * Defines a callback to call when the joystick is touched
  41121. * @param action defines the callback
  41122. */
  41123. setActionOnTouch(action: () => any): void;
  41124. /**
  41125. * Defines which axis you'd like to control for left & right
  41126. * @param axis defines the axis to use
  41127. */
  41128. setAxisForLeftRight(axis: JoystickAxis): void;
  41129. /**
  41130. * Defines which axis you'd like to control for up & down
  41131. * @param axis defines the axis to use
  41132. */
  41133. setAxisForUpDown(axis: JoystickAxis): void;
  41134. private _drawVirtualJoystick;
  41135. /**
  41136. * Release internal HTML canvas
  41137. */
  41138. releaseCanvas(): void;
  41139. }
  41140. }
  41141. declare module BABYLON {
  41142. interface FreeCameraInputsManager {
  41143. /**
  41144. * Add virtual joystick input support to the input manager.
  41145. * @returns the current input manager
  41146. */
  41147. addVirtualJoystick(): FreeCameraInputsManager;
  41148. }
  41149. /**
  41150. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41151. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41152. */
  41153. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41154. /**
  41155. * Defines the camera the input is attached to.
  41156. */
  41157. camera: FreeCamera;
  41158. private _leftjoystick;
  41159. private _rightjoystick;
  41160. /**
  41161. * Gets the left stick of the virtual joystick.
  41162. * @returns The virtual Joystick
  41163. */
  41164. getLeftJoystick(): VirtualJoystick;
  41165. /**
  41166. * Gets the right stick of the virtual joystick.
  41167. * @returns The virtual Joystick
  41168. */
  41169. getRightJoystick(): VirtualJoystick;
  41170. /**
  41171. * Update the current camera state depending on the inputs that have been used this frame.
  41172. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41173. */
  41174. checkInputs(): void;
  41175. /**
  41176. * Attach the input controls to a specific dom element to get the input from.
  41177. * @param element Defines the element the controls should be listened from
  41178. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41179. */
  41180. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41181. /**
  41182. * Detach the current controls from the specified dom element.
  41183. * @param element Defines the element to stop listening the inputs from
  41184. */
  41185. detachControl(element: Nullable<HTMLElement>): void;
  41186. /**
  41187. * Gets the class name of the current intput.
  41188. * @returns the class name
  41189. */
  41190. getClassName(): string;
  41191. /**
  41192. * Get the friendly name associated with the input class.
  41193. * @returns the input friendly name
  41194. */
  41195. getSimpleName(): string;
  41196. }
  41197. }
  41198. declare module BABYLON {
  41199. /**
  41200. * This represents a FPS type of camera controlled by touch.
  41201. * This is like a universal camera minus the Gamepad controls.
  41202. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41203. */
  41204. export class TouchCamera extends FreeCamera {
  41205. /**
  41206. * Defines the touch sensibility for rotation.
  41207. * The higher the faster.
  41208. */
  41209. get touchAngularSensibility(): number;
  41210. set touchAngularSensibility(value: number);
  41211. /**
  41212. * Defines the touch sensibility for move.
  41213. * The higher the faster.
  41214. */
  41215. get touchMoveSensibility(): number;
  41216. set touchMoveSensibility(value: number);
  41217. /**
  41218. * Instantiates a new touch camera.
  41219. * This represents a FPS type of camera controlled by touch.
  41220. * This is like a universal camera minus the Gamepad controls.
  41221. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41222. * @param name Define the name of the camera in the scene
  41223. * @param position Define the start position of the camera in the scene
  41224. * @param scene Define the scene the camera belongs to
  41225. */
  41226. constructor(name: string, position: Vector3, scene: Scene);
  41227. /**
  41228. * Gets the current object class name.
  41229. * @return the class name
  41230. */
  41231. getClassName(): string;
  41232. /** @hidden */
  41233. _setupInputs(): void;
  41234. }
  41235. }
  41236. declare module BABYLON {
  41237. /**
  41238. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41239. * being tilted forward or back and left or right.
  41240. */
  41241. export class DeviceOrientationCamera extends FreeCamera {
  41242. private _initialQuaternion;
  41243. private _quaternionCache;
  41244. private _tmpDragQuaternion;
  41245. private _disablePointerInputWhenUsingDeviceOrientation;
  41246. /**
  41247. * Creates a new device orientation camera
  41248. * @param name The name of the camera
  41249. * @param position The start position camera
  41250. * @param scene The scene the camera belongs to
  41251. */
  41252. constructor(name: string, position: Vector3, scene: Scene);
  41253. /**
  41254. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41255. */
  41256. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  41257. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  41258. private _dragFactor;
  41259. /**
  41260. * Enabled turning on the y axis when the orientation sensor is active
  41261. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41262. */
  41263. enableHorizontalDragging(dragFactor?: number): void;
  41264. /**
  41265. * Gets the current instance class name ("DeviceOrientationCamera").
  41266. * This helps avoiding instanceof at run time.
  41267. * @returns the class name
  41268. */
  41269. getClassName(): string;
  41270. /**
  41271. * @hidden
  41272. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  41273. */
  41274. _checkInputs(): void;
  41275. /**
  41276. * Reset the camera to its default orientation on the specified axis only.
  41277. * @param axis The axis to reset
  41278. */
  41279. resetToCurrentRotation(axis?: Axis): void;
  41280. }
  41281. }
  41282. declare module BABYLON {
  41283. /**
  41284. * Defines supported buttons for XBox360 compatible gamepads
  41285. */
  41286. export enum Xbox360Button {
  41287. /** A */
  41288. A = 0,
  41289. /** B */
  41290. B = 1,
  41291. /** X */
  41292. X = 2,
  41293. /** Y */
  41294. Y = 3,
  41295. /** Left button */
  41296. LB = 4,
  41297. /** Right button */
  41298. RB = 5,
  41299. /** Back */
  41300. Back = 8,
  41301. /** Start */
  41302. Start = 9,
  41303. /** Left stick */
  41304. LeftStick = 10,
  41305. /** Right stick */
  41306. RightStick = 11
  41307. }
  41308. /** Defines values for XBox360 DPad */
  41309. export enum Xbox360Dpad {
  41310. /** Up */
  41311. Up = 12,
  41312. /** Down */
  41313. Down = 13,
  41314. /** Left */
  41315. Left = 14,
  41316. /** Right */
  41317. Right = 15
  41318. }
  41319. /**
  41320. * Defines a XBox360 gamepad
  41321. */
  41322. export class Xbox360Pad extends Gamepad {
  41323. private _leftTrigger;
  41324. private _rightTrigger;
  41325. private _onlefttriggerchanged;
  41326. private _onrighttriggerchanged;
  41327. private _onbuttondown;
  41328. private _onbuttonup;
  41329. private _ondpaddown;
  41330. private _ondpadup;
  41331. /** Observable raised when a button is pressed */
  41332. onButtonDownObservable: Observable<Xbox360Button>;
  41333. /** Observable raised when a button is released */
  41334. onButtonUpObservable: Observable<Xbox360Button>;
  41335. /** Observable raised when a pad is pressed */
  41336. onPadDownObservable: Observable<Xbox360Dpad>;
  41337. /** Observable raised when a pad is released */
  41338. onPadUpObservable: Observable<Xbox360Dpad>;
  41339. private _buttonA;
  41340. private _buttonB;
  41341. private _buttonX;
  41342. private _buttonY;
  41343. private _buttonBack;
  41344. private _buttonStart;
  41345. private _buttonLB;
  41346. private _buttonRB;
  41347. private _buttonLeftStick;
  41348. private _buttonRightStick;
  41349. private _dPadUp;
  41350. private _dPadDown;
  41351. private _dPadLeft;
  41352. private _dPadRight;
  41353. private _isXboxOnePad;
  41354. /**
  41355. * Creates a new XBox360 gamepad object
  41356. * @param id defines the id of this gamepad
  41357. * @param index defines its index
  41358. * @param gamepad defines the internal HTML gamepad object
  41359. * @param xboxOne defines if it is a XBox One gamepad
  41360. */
  41361. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41362. /**
  41363. * Defines the callback to call when left trigger is pressed
  41364. * @param callback defines the callback to use
  41365. */
  41366. onlefttriggerchanged(callback: (value: number) => void): void;
  41367. /**
  41368. * Defines the callback to call when right trigger is pressed
  41369. * @param callback defines the callback to use
  41370. */
  41371. onrighttriggerchanged(callback: (value: number) => void): void;
  41372. /**
  41373. * Gets the left trigger value
  41374. */
  41375. get leftTrigger(): number;
  41376. /**
  41377. * Sets the left trigger value
  41378. */
  41379. set leftTrigger(newValue: number);
  41380. /**
  41381. * Gets the right trigger value
  41382. */
  41383. get rightTrigger(): number;
  41384. /**
  41385. * Sets the right trigger value
  41386. */
  41387. set rightTrigger(newValue: number);
  41388. /**
  41389. * Defines the callback to call when a button is pressed
  41390. * @param callback defines the callback to use
  41391. */
  41392. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41393. /**
  41394. * Defines the callback to call when a button is released
  41395. * @param callback defines the callback to use
  41396. */
  41397. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41398. /**
  41399. * Defines the callback to call when a pad is pressed
  41400. * @param callback defines the callback to use
  41401. */
  41402. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41403. /**
  41404. * Defines the callback to call when a pad is released
  41405. * @param callback defines the callback to use
  41406. */
  41407. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41408. private _setButtonValue;
  41409. private _setDPadValue;
  41410. /**
  41411. * Gets the value of the `A` button
  41412. */
  41413. get buttonA(): number;
  41414. /**
  41415. * Sets the value of the `A` button
  41416. */
  41417. set buttonA(value: number);
  41418. /**
  41419. * Gets the value of the `B` button
  41420. */
  41421. get buttonB(): number;
  41422. /**
  41423. * Sets the value of the `B` button
  41424. */
  41425. set buttonB(value: number);
  41426. /**
  41427. * Gets the value of the `X` button
  41428. */
  41429. get buttonX(): number;
  41430. /**
  41431. * Sets the value of the `X` button
  41432. */
  41433. set buttonX(value: number);
  41434. /**
  41435. * Gets the value of the `Y` button
  41436. */
  41437. get buttonY(): number;
  41438. /**
  41439. * Sets the value of the `Y` button
  41440. */
  41441. set buttonY(value: number);
  41442. /**
  41443. * Gets the value of the `Start` button
  41444. */
  41445. get buttonStart(): number;
  41446. /**
  41447. * Sets the value of the `Start` button
  41448. */
  41449. set buttonStart(value: number);
  41450. /**
  41451. * Gets the value of the `Back` button
  41452. */
  41453. get buttonBack(): number;
  41454. /**
  41455. * Sets the value of the `Back` button
  41456. */
  41457. set buttonBack(value: number);
  41458. /**
  41459. * Gets the value of the `Left` button
  41460. */
  41461. get buttonLB(): number;
  41462. /**
  41463. * Sets the value of the `Left` button
  41464. */
  41465. set buttonLB(value: number);
  41466. /**
  41467. * Gets the value of the `Right` button
  41468. */
  41469. get buttonRB(): number;
  41470. /**
  41471. * Sets the value of the `Right` button
  41472. */
  41473. set buttonRB(value: number);
  41474. /**
  41475. * Gets the value of the Left joystick
  41476. */
  41477. get buttonLeftStick(): number;
  41478. /**
  41479. * Sets the value of the Left joystick
  41480. */
  41481. set buttonLeftStick(value: number);
  41482. /**
  41483. * Gets the value of the Right joystick
  41484. */
  41485. get buttonRightStick(): number;
  41486. /**
  41487. * Sets the value of the Right joystick
  41488. */
  41489. set buttonRightStick(value: number);
  41490. /**
  41491. * Gets the value of D-pad up
  41492. */
  41493. get dPadUp(): number;
  41494. /**
  41495. * Sets the value of D-pad up
  41496. */
  41497. set dPadUp(value: number);
  41498. /**
  41499. * Gets the value of D-pad down
  41500. */
  41501. get dPadDown(): number;
  41502. /**
  41503. * Sets the value of D-pad down
  41504. */
  41505. set dPadDown(value: number);
  41506. /**
  41507. * Gets the value of D-pad left
  41508. */
  41509. get dPadLeft(): number;
  41510. /**
  41511. * Sets the value of D-pad left
  41512. */
  41513. set dPadLeft(value: number);
  41514. /**
  41515. * Gets the value of D-pad right
  41516. */
  41517. get dPadRight(): number;
  41518. /**
  41519. * Sets the value of D-pad right
  41520. */
  41521. set dPadRight(value: number);
  41522. /**
  41523. * Force the gamepad to synchronize with device values
  41524. */
  41525. update(): void;
  41526. /**
  41527. * Disposes the gamepad
  41528. */
  41529. dispose(): void;
  41530. }
  41531. }
  41532. declare module BABYLON {
  41533. /**
  41534. * Defines supported buttons for DualShock compatible gamepads
  41535. */
  41536. export enum DualShockButton {
  41537. /** Cross */
  41538. Cross = 0,
  41539. /** Circle */
  41540. Circle = 1,
  41541. /** Square */
  41542. Square = 2,
  41543. /** Triangle */
  41544. Triangle = 3,
  41545. /** L1 */
  41546. L1 = 4,
  41547. /** R1 */
  41548. R1 = 5,
  41549. /** Share */
  41550. Share = 8,
  41551. /** Options */
  41552. Options = 9,
  41553. /** Left stick */
  41554. LeftStick = 10,
  41555. /** Right stick */
  41556. RightStick = 11
  41557. }
  41558. /** Defines values for DualShock DPad */
  41559. export enum DualShockDpad {
  41560. /** Up */
  41561. Up = 12,
  41562. /** Down */
  41563. Down = 13,
  41564. /** Left */
  41565. Left = 14,
  41566. /** Right */
  41567. Right = 15
  41568. }
  41569. /**
  41570. * Defines a DualShock gamepad
  41571. */
  41572. export class DualShockPad extends Gamepad {
  41573. private _leftTrigger;
  41574. private _rightTrigger;
  41575. private _onlefttriggerchanged;
  41576. private _onrighttriggerchanged;
  41577. private _onbuttondown;
  41578. private _onbuttonup;
  41579. private _ondpaddown;
  41580. private _ondpadup;
  41581. /** Observable raised when a button is pressed */
  41582. onButtonDownObservable: Observable<DualShockButton>;
  41583. /** Observable raised when a button is released */
  41584. onButtonUpObservable: Observable<DualShockButton>;
  41585. /** Observable raised when a pad is pressed */
  41586. onPadDownObservable: Observable<DualShockDpad>;
  41587. /** Observable raised when a pad is released */
  41588. onPadUpObservable: Observable<DualShockDpad>;
  41589. private _buttonCross;
  41590. private _buttonCircle;
  41591. private _buttonSquare;
  41592. private _buttonTriangle;
  41593. private _buttonShare;
  41594. private _buttonOptions;
  41595. private _buttonL1;
  41596. private _buttonR1;
  41597. private _buttonLeftStick;
  41598. private _buttonRightStick;
  41599. private _dPadUp;
  41600. private _dPadDown;
  41601. private _dPadLeft;
  41602. private _dPadRight;
  41603. /**
  41604. * Creates a new DualShock gamepad object
  41605. * @param id defines the id of this gamepad
  41606. * @param index defines its index
  41607. * @param gamepad defines the internal HTML gamepad object
  41608. */
  41609. constructor(id: string, index: number, gamepad: any);
  41610. /**
  41611. * Defines the callback to call when left trigger is pressed
  41612. * @param callback defines the callback to use
  41613. */
  41614. onlefttriggerchanged(callback: (value: number) => void): void;
  41615. /**
  41616. * Defines the callback to call when right trigger is pressed
  41617. * @param callback defines the callback to use
  41618. */
  41619. onrighttriggerchanged(callback: (value: number) => void): void;
  41620. /**
  41621. * Gets the left trigger value
  41622. */
  41623. get leftTrigger(): number;
  41624. /**
  41625. * Sets the left trigger value
  41626. */
  41627. set leftTrigger(newValue: number);
  41628. /**
  41629. * Gets the right trigger value
  41630. */
  41631. get rightTrigger(): number;
  41632. /**
  41633. * Sets the right trigger value
  41634. */
  41635. set rightTrigger(newValue: number);
  41636. /**
  41637. * Defines the callback to call when a button is pressed
  41638. * @param callback defines the callback to use
  41639. */
  41640. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41641. /**
  41642. * Defines the callback to call when a button is released
  41643. * @param callback defines the callback to use
  41644. */
  41645. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41646. /**
  41647. * Defines the callback to call when a pad is pressed
  41648. * @param callback defines the callback to use
  41649. */
  41650. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41651. /**
  41652. * Defines the callback to call when a pad is released
  41653. * @param callback defines the callback to use
  41654. */
  41655. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41656. private _setButtonValue;
  41657. private _setDPadValue;
  41658. /**
  41659. * Gets the value of the `Cross` button
  41660. */
  41661. get buttonCross(): number;
  41662. /**
  41663. * Sets the value of the `Cross` button
  41664. */
  41665. set buttonCross(value: number);
  41666. /**
  41667. * Gets the value of the `Circle` button
  41668. */
  41669. get buttonCircle(): number;
  41670. /**
  41671. * Sets the value of the `Circle` button
  41672. */
  41673. set buttonCircle(value: number);
  41674. /**
  41675. * Gets the value of the `Square` button
  41676. */
  41677. get buttonSquare(): number;
  41678. /**
  41679. * Sets the value of the `Square` button
  41680. */
  41681. set buttonSquare(value: number);
  41682. /**
  41683. * Gets the value of the `Triangle` button
  41684. */
  41685. get buttonTriangle(): number;
  41686. /**
  41687. * Sets the value of the `Triangle` button
  41688. */
  41689. set buttonTriangle(value: number);
  41690. /**
  41691. * Gets the value of the `Options` button
  41692. */
  41693. get buttonOptions(): number;
  41694. /**
  41695. * Sets the value of the `Options` button
  41696. */
  41697. set buttonOptions(value: number);
  41698. /**
  41699. * Gets the value of the `Share` button
  41700. */
  41701. get buttonShare(): number;
  41702. /**
  41703. * Sets the value of the `Share` button
  41704. */
  41705. set buttonShare(value: number);
  41706. /**
  41707. * Gets the value of the `L1` button
  41708. */
  41709. get buttonL1(): number;
  41710. /**
  41711. * Sets the value of the `L1` button
  41712. */
  41713. set buttonL1(value: number);
  41714. /**
  41715. * Gets the value of the `R1` button
  41716. */
  41717. get buttonR1(): number;
  41718. /**
  41719. * Sets the value of the `R1` button
  41720. */
  41721. set buttonR1(value: number);
  41722. /**
  41723. * Gets the value of the Left joystick
  41724. */
  41725. get buttonLeftStick(): number;
  41726. /**
  41727. * Sets the value of the Left joystick
  41728. */
  41729. set buttonLeftStick(value: number);
  41730. /**
  41731. * Gets the value of the Right joystick
  41732. */
  41733. get buttonRightStick(): number;
  41734. /**
  41735. * Sets the value of the Right joystick
  41736. */
  41737. set buttonRightStick(value: number);
  41738. /**
  41739. * Gets the value of D-pad up
  41740. */
  41741. get dPadUp(): number;
  41742. /**
  41743. * Sets the value of D-pad up
  41744. */
  41745. set dPadUp(value: number);
  41746. /**
  41747. * Gets the value of D-pad down
  41748. */
  41749. get dPadDown(): number;
  41750. /**
  41751. * Sets the value of D-pad down
  41752. */
  41753. set dPadDown(value: number);
  41754. /**
  41755. * Gets the value of D-pad left
  41756. */
  41757. get dPadLeft(): number;
  41758. /**
  41759. * Sets the value of D-pad left
  41760. */
  41761. set dPadLeft(value: number);
  41762. /**
  41763. * Gets the value of D-pad right
  41764. */
  41765. get dPadRight(): number;
  41766. /**
  41767. * Sets the value of D-pad right
  41768. */
  41769. set dPadRight(value: number);
  41770. /**
  41771. * Force the gamepad to synchronize with device values
  41772. */
  41773. update(): void;
  41774. /**
  41775. * Disposes the gamepad
  41776. */
  41777. dispose(): void;
  41778. }
  41779. }
  41780. declare module BABYLON {
  41781. /**
  41782. * Manager for handling gamepads
  41783. */
  41784. export class GamepadManager {
  41785. private _scene?;
  41786. private _babylonGamepads;
  41787. private _oneGamepadConnected;
  41788. /** @hidden */
  41789. _isMonitoring: boolean;
  41790. private _gamepadEventSupported;
  41791. private _gamepadSupport?;
  41792. /**
  41793. * observable to be triggered when the gamepad controller has been connected
  41794. */
  41795. onGamepadConnectedObservable: Observable<Gamepad>;
  41796. /**
  41797. * observable to be triggered when the gamepad controller has been disconnected
  41798. */
  41799. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41800. private _onGamepadConnectedEvent;
  41801. private _onGamepadDisconnectedEvent;
  41802. /**
  41803. * Initializes the gamepad manager
  41804. * @param _scene BabylonJS scene
  41805. */
  41806. constructor(_scene?: Scene | undefined);
  41807. /**
  41808. * The gamepads in the game pad manager
  41809. */
  41810. get gamepads(): Gamepad[];
  41811. /**
  41812. * Get the gamepad controllers based on type
  41813. * @param type The type of gamepad controller
  41814. * @returns Nullable gamepad
  41815. */
  41816. getGamepadByType(type?: number): Nullable<Gamepad>;
  41817. /**
  41818. * Disposes the gamepad manager
  41819. */
  41820. dispose(): void;
  41821. private _addNewGamepad;
  41822. private _startMonitoringGamepads;
  41823. private _stopMonitoringGamepads;
  41824. /** @hidden */
  41825. _checkGamepadsStatus(): void;
  41826. private _updateGamepadObjects;
  41827. }
  41828. }
  41829. declare module BABYLON {
  41830. interface Scene {
  41831. /** @hidden */
  41832. _gamepadManager: Nullable<GamepadManager>;
  41833. /**
  41834. * Gets the gamepad manager associated with the scene
  41835. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  41836. */
  41837. gamepadManager: GamepadManager;
  41838. }
  41839. /**
  41840. * Interface representing a free camera inputs manager
  41841. */
  41842. interface FreeCameraInputsManager {
  41843. /**
  41844. * Adds gamepad input support to the FreeCameraInputsManager.
  41845. * @returns the FreeCameraInputsManager
  41846. */
  41847. addGamepad(): FreeCameraInputsManager;
  41848. }
  41849. /**
  41850. * Interface representing an arc rotate camera inputs manager
  41851. */
  41852. interface ArcRotateCameraInputsManager {
  41853. /**
  41854. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41855. * @returns the camera inputs manager
  41856. */
  41857. addGamepad(): ArcRotateCameraInputsManager;
  41858. }
  41859. /**
  41860. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41861. */
  41862. export class GamepadSystemSceneComponent implements ISceneComponent {
  41863. /**
  41864. * The component name helpfull to identify the component in the list of scene components.
  41865. */
  41866. readonly name: string;
  41867. /**
  41868. * The scene the component belongs to.
  41869. */
  41870. scene: Scene;
  41871. /**
  41872. * Creates a new instance of the component for the given scene
  41873. * @param scene Defines the scene to register the component in
  41874. */
  41875. constructor(scene: Scene);
  41876. /**
  41877. * Registers the component in a given scene
  41878. */
  41879. register(): void;
  41880. /**
  41881. * Rebuilds the elements related to this component in case of
  41882. * context lost for instance.
  41883. */
  41884. rebuild(): void;
  41885. /**
  41886. * Disposes the component and the associated ressources
  41887. */
  41888. dispose(): void;
  41889. private _beforeCameraUpdate;
  41890. }
  41891. }
  41892. declare module BABYLON {
  41893. /**
  41894. * 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,
  41895. * which still works and will still be found in many Playgrounds.
  41896. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41897. */
  41898. export class UniversalCamera extends TouchCamera {
  41899. /**
  41900. * Defines the gamepad rotation sensiblity.
  41901. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41902. */
  41903. get gamepadAngularSensibility(): number;
  41904. set gamepadAngularSensibility(value: number);
  41905. /**
  41906. * Defines the gamepad move sensiblity.
  41907. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41908. */
  41909. get gamepadMoveSensibility(): number;
  41910. set gamepadMoveSensibility(value: number);
  41911. /**
  41912. * 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,
  41913. * which still works and will still be found in many Playgrounds.
  41914. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41915. * @param name Define the name of the camera in the scene
  41916. * @param position Define the start position of the camera in the scene
  41917. * @param scene Define the scene the camera belongs to
  41918. */
  41919. constructor(name: string, position: Vector3, scene: Scene);
  41920. /**
  41921. * Gets the current object class name.
  41922. * @return the class name
  41923. */
  41924. getClassName(): string;
  41925. }
  41926. }
  41927. declare module BABYLON {
  41928. /**
  41929. * This represents a FPS type of camera. This is only here for back compat purpose.
  41930. * Please use the UniversalCamera instead as both are identical.
  41931. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41932. */
  41933. export class GamepadCamera extends UniversalCamera {
  41934. /**
  41935. * Instantiates a new Gamepad Camera
  41936. * This represents a FPS type of camera. This is only here for back compat purpose.
  41937. * Please use the UniversalCamera instead as both are identical.
  41938. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41939. * @param name Define the name of the camera in the scene
  41940. * @param position Define the start position of the camera in the scene
  41941. * @param scene Define the scene the camera belongs to
  41942. */
  41943. constructor(name: string, position: Vector3, scene: Scene);
  41944. /**
  41945. * Gets the current object class name.
  41946. * @return the class name
  41947. */
  41948. getClassName(): string;
  41949. }
  41950. }
  41951. declare module BABYLON {
  41952. /** @hidden */
  41953. export var passPixelShader: {
  41954. name: string;
  41955. shader: string;
  41956. };
  41957. }
  41958. declare module BABYLON {
  41959. /** @hidden */
  41960. export var passCubePixelShader: {
  41961. name: string;
  41962. shader: string;
  41963. };
  41964. }
  41965. declare module BABYLON {
  41966. /**
  41967. * PassPostProcess which produces an output the same as it's input
  41968. */
  41969. export class PassPostProcess extends PostProcess {
  41970. /**
  41971. * Creates the PassPostProcess
  41972. * @param name The name of the effect.
  41973. * @param options The required width/height ratio to downsize to before computing the render pass.
  41974. * @param camera The camera to apply the render pass to.
  41975. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41976. * @param engine The engine which the post process will be applied. (default: current engine)
  41977. * @param reusable If the post process can be reused on the same frame. (default: false)
  41978. * @param textureType The type of texture to be used when performing the post processing.
  41979. * @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)
  41980. */
  41981. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41982. }
  41983. /**
  41984. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  41985. */
  41986. export class PassCubePostProcess extends PostProcess {
  41987. private _face;
  41988. /**
  41989. * Gets or sets the cube face to display.
  41990. * * 0 is +X
  41991. * * 1 is -X
  41992. * * 2 is +Y
  41993. * * 3 is -Y
  41994. * * 4 is +Z
  41995. * * 5 is -Z
  41996. */
  41997. get face(): number;
  41998. set face(value: number);
  41999. /**
  42000. * Creates the PassCubePostProcess
  42001. * @param name The name of the effect.
  42002. * @param options The required width/height ratio to downsize to before computing the render pass.
  42003. * @param camera The camera to apply the render pass to.
  42004. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42005. * @param engine The engine which the post process will be applied. (default: current engine)
  42006. * @param reusable If the post process can be reused on the same frame. (default: false)
  42007. * @param textureType The type of texture to be used when performing the post processing.
  42008. * @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)
  42009. */
  42010. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42011. }
  42012. }
  42013. declare module BABYLON {
  42014. /** @hidden */
  42015. export var anaglyphPixelShader: {
  42016. name: string;
  42017. shader: string;
  42018. };
  42019. }
  42020. declare module BABYLON {
  42021. /**
  42022. * Postprocess used to generate anaglyphic rendering
  42023. */
  42024. export class AnaglyphPostProcess extends PostProcess {
  42025. private _passedProcess;
  42026. /**
  42027. * Creates a new AnaglyphPostProcess
  42028. * @param name defines postprocess name
  42029. * @param options defines creation options or target ratio scale
  42030. * @param rigCameras defines cameras using this postprocess
  42031. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42032. * @param engine defines hosting engine
  42033. * @param reusable defines if the postprocess will be reused multiple times per frame
  42034. */
  42035. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42036. }
  42037. }
  42038. declare module BABYLON {
  42039. /**
  42040. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42041. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42042. */
  42043. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42044. /**
  42045. * Creates a new AnaglyphArcRotateCamera
  42046. * @param name defines camera name
  42047. * @param alpha defines alpha angle (in radians)
  42048. * @param beta defines beta angle (in radians)
  42049. * @param radius defines radius
  42050. * @param target defines camera target
  42051. * @param interaxialDistance defines distance between each color axis
  42052. * @param scene defines the hosting scene
  42053. */
  42054. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42055. /**
  42056. * Gets camera class name
  42057. * @returns AnaglyphArcRotateCamera
  42058. */
  42059. getClassName(): string;
  42060. }
  42061. }
  42062. declare module BABYLON {
  42063. /**
  42064. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42065. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42066. */
  42067. export class AnaglyphFreeCamera extends FreeCamera {
  42068. /**
  42069. * Creates a new AnaglyphFreeCamera
  42070. * @param name defines camera name
  42071. * @param position defines initial position
  42072. * @param interaxialDistance defines distance between each color axis
  42073. * @param scene defines the hosting scene
  42074. */
  42075. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42076. /**
  42077. * Gets camera class name
  42078. * @returns AnaglyphFreeCamera
  42079. */
  42080. getClassName(): string;
  42081. }
  42082. }
  42083. declare module BABYLON {
  42084. /**
  42085. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42086. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42087. */
  42088. export class AnaglyphGamepadCamera extends GamepadCamera {
  42089. /**
  42090. * Creates a new AnaglyphGamepadCamera
  42091. * @param name defines camera name
  42092. * @param position defines initial position
  42093. * @param interaxialDistance defines distance between each color axis
  42094. * @param scene defines the hosting scene
  42095. */
  42096. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42097. /**
  42098. * Gets camera class name
  42099. * @returns AnaglyphGamepadCamera
  42100. */
  42101. getClassName(): string;
  42102. }
  42103. }
  42104. declare module BABYLON {
  42105. /**
  42106. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42107. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42108. */
  42109. export class AnaglyphUniversalCamera extends UniversalCamera {
  42110. /**
  42111. * Creates a new AnaglyphUniversalCamera
  42112. * @param name defines camera name
  42113. * @param position defines initial position
  42114. * @param interaxialDistance defines distance between each color axis
  42115. * @param scene defines the hosting scene
  42116. */
  42117. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42118. /**
  42119. * Gets camera class name
  42120. * @returns AnaglyphUniversalCamera
  42121. */
  42122. getClassName(): string;
  42123. }
  42124. }
  42125. declare module BABYLON {
  42126. /** @hidden */
  42127. export var stereoscopicInterlacePixelShader: {
  42128. name: string;
  42129. shader: string;
  42130. };
  42131. }
  42132. declare module BABYLON {
  42133. /**
  42134. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  42135. */
  42136. export class StereoscopicInterlacePostProcessI extends PostProcess {
  42137. private _stepSize;
  42138. private _passedProcess;
  42139. /**
  42140. * Initializes a StereoscopicInterlacePostProcessI
  42141. * @param name The name of the effect.
  42142. * @param rigCameras The rig cameras to be appled to the post process
  42143. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  42144. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  42145. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42146. * @param engine The engine which the post process will be applied. (default: current engine)
  42147. * @param reusable If the post process can be reused on the same frame. (default: false)
  42148. */
  42149. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42150. }
  42151. /**
  42152. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  42153. */
  42154. export class StereoscopicInterlacePostProcess extends PostProcess {
  42155. private _stepSize;
  42156. private _passedProcess;
  42157. /**
  42158. * Initializes a StereoscopicInterlacePostProcess
  42159. * @param name The name of the effect.
  42160. * @param rigCameras The rig cameras to be appled to the post process
  42161. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  42162. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42163. * @param engine The engine which the post process will be applied. (default: current engine)
  42164. * @param reusable If the post process can be reused on the same frame. (default: false)
  42165. */
  42166. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42167. }
  42168. }
  42169. declare module BABYLON {
  42170. /**
  42171. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42172. * @see http://doc.babylonjs.com/features/cameras
  42173. */
  42174. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42175. /**
  42176. * Creates a new StereoscopicArcRotateCamera
  42177. * @param name defines camera name
  42178. * @param alpha defines alpha angle (in radians)
  42179. * @param beta defines beta angle (in radians)
  42180. * @param radius defines radius
  42181. * @param target defines camera target
  42182. * @param interaxialDistance defines distance between each color axis
  42183. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42184. * @param scene defines the hosting scene
  42185. */
  42186. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42187. /**
  42188. * Gets camera class name
  42189. * @returns StereoscopicArcRotateCamera
  42190. */
  42191. getClassName(): string;
  42192. }
  42193. }
  42194. declare module BABYLON {
  42195. /**
  42196. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42197. * @see http://doc.babylonjs.com/features/cameras
  42198. */
  42199. export class StereoscopicFreeCamera extends FreeCamera {
  42200. /**
  42201. * Creates a new StereoscopicFreeCamera
  42202. * @param name defines camera name
  42203. * @param position defines initial position
  42204. * @param interaxialDistance defines distance between each color axis
  42205. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42206. * @param scene defines the hosting scene
  42207. */
  42208. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42209. /**
  42210. * Gets camera class name
  42211. * @returns StereoscopicFreeCamera
  42212. */
  42213. getClassName(): string;
  42214. }
  42215. }
  42216. declare module BABYLON {
  42217. /**
  42218. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42219. * @see http://doc.babylonjs.com/features/cameras
  42220. */
  42221. export class StereoscopicGamepadCamera extends GamepadCamera {
  42222. /**
  42223. * Creates a new StereoscopicGamepadCamera
  42224. * @param name defines camera name
  42225. * @param position defines initial position
  42226. * @param interaxialDistance defines distance between each color axis
  42227. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42228. * @param scene defines the hosting scene
  42229. */
  42230. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42231. /**
  42232. * Gets camera class name
  42233. * @returns StereoscopicGamepadCamera
  42234. */
  42235. getClassName(): string;
  42236. }
  42237. }
  42238. declare module BABYLON {
  42239. /**
  42240. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42241. * @see http://doc.babylonjs.com/features/cameras
  42242. */
  42243. export class StereoscopicUniversalCamera extends UniversalCamera {
  42244. /**
  42245. * Creates a new StereoscopicUniversalCamera
  42246. * @param name defines camera name
  42247. * @param position defines initial position
  42248. * @param interaxialDistance defines distance between each color axis
  42249. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42250. * @param scene defines the hosting scene
  42251. */
  42252. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42253. /**
  42254. * Gets camera class name
  42255. * @returns StereoscopicUniversalCamera
  42256. */
  42257. getClassName(): string;
  42258. }
  42259. }
  42260. declare module BABYLON {
  42261. /**
  42262. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  42263. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42264. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42265. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42266. */
  42267. export class VirtualJoysticksCamera extends FreeCamera {
  42268. /**
  42269. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  42270. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42271. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42272. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42273. * @param name Define the name of the camera in the scene
  42274. * @param position Define the start position of the camera in the scene
  42275. * @param scene Define the scene the camera belongs to
  42276. */
  42277. constructor(name: string, position: Vector3, scene: Scene);
  42278. /**
  42279. * Gets the current object class name.
  42280. * @return the class name
  42281. */
  42282. getClassName(): string;
  42283. }
  42284. }
  42285. declare module BABYLON {
  42286. /**
  42287. * This represents all the required metrics to create a VR camera.
  42288. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42289. */
  42290. export class VRCameraMetrics {
  42291. /**
  42292. * Define the horizontal resolution off the screen.
  42293. */
  42294. hResolution: number;
  42295. /**
  42296. * Define the vertical resolution off the screen.
  42297. */
  42298. vResolution: number;
  42299. /**
  42300. * Define the horizontal screen size.
  42301. */
  42302. hScreenSize: number;
  42303. /**
  42304. * Define the vertical screen size.
  42305. */
  42306. vScreenSize: number;
  42307. /**
  42308. * Define the vertical screen center position.
  42309. */
  42310. vScreenCenter: number;
  42311. /**
  42312. * Define the distance of the eyes to the screen.
  42313. */
  42314. eyeToScreenDistance: number;
  42315. /**
  42316. * Define the distance between both lenses
  42317. */
  42318. lensSeparationDistance: number;
  42319. /**
  42320. * Define the distance between both viewer's eyes.
  42321. */
  42322. interpupillaryDistance: number;
  42323. /**
  42324. * Define the distortion factor of the VR postprocess.
  42325. * Please, touch with care.
  42326. */
  42327. distortionK: number[];
  42328. /**
  42329. * Define the chromatic aberration correction factors for the VR post process.
  42330. */
  42331. chromaAbCorrection: number[];
  42332. /**
  42333. * Define the scale factor of the post process.
  42334. * The smaller the better but the slower.
  42335. */
  42336. postProcessScaleFactor: number;
  42337. /**
  42338. * Define an offset for the lens center.
  42339. */
  42340. lensCenterOffset: number;
  42341. /**
  42342. * Define if the current vr camera should compensate the distortion of the lense or not.
  42343. */
  42344. compensateDistortion: boolean;
  42345. /**
  42346. * Defines if multiview should be enabled when rendering (Default: false)
  42347. */
  42348. multiviewEnabled: boolean;
  42349. /**
  42350. * Gets the rendering aspect ratio based on the provided resolutions.
  42351. */
  42352. get aspectRatio(): number;
  42353. /**
  42354. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42355. */
  42356. get aspectRatioFov(): number;
  42357. /**
  42358. * @hidden
  42359. */
  42360. get leftHMatrix(): Matrix;
  42361. /**
  42362. * @hidden
  42363. */
  42364. get rightHMatrix(): Matrix;
  42365. /**
  42366. * @hidden
  42367. */
  42368. get leftPreViewMatrix(): Matrix;
  42369. /**
  42370. * @hidden
  42371. */
  42372. get rightPreViewMatrix(): Matrix;
  42373. /**
  42374. * Get the default VRMetrics based on the most generic setup.
  42375. * @returns the default vr metrics
  42376. */
  42377. static GetDefault(): VRCameraMetrics;
  42378. }
  42379. }
  42380. declare module BABYLON {
  42381. /** @hidden */
  42382. export var vrDistortionCorrectionPixelShader: {
  42383. name: string;
  42384. shader: string;
  42385. };
  42386. }
  42387. declare module BABYLON {
  42388. /**
  42389. * VRDistortionCorrectionPostProcess used for mobile VR
  42390. */
  42391. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42392. private _isRightEye;
  42393. private _distortionFactors;
  42394. private _postProcessScaleFactor;
  42395. private _lensCenterOffset;
  42396. private _scaleIn;
  42397. private _scaleFactor;
  42398. private _lensCenter;
  42399. /**
  42400. * Initializes the VRDistortionCorrectionPostProcess
  42401. * @param name The name of the effect.
  42402. * @param camera The camera to apply the render pass to.
  42403. * @param isRightEye If this is for the right eye distortion
  42404. * @param vrMetrics All the required metrics for the VR camera
  42405. */
  42406. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42407. }
  42408. }
  42409. declare module BABYLON {
  42410. /**
  42411. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42412. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42413. */
  42414. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42415. /**
  42416. * Creates a new VRDeviceOrientationArcRotateCamera
  42417. * @param name defines camera name
  42418. * @param alpha defines the camera rotation along the logitudinal axis
  42419. * @param beta defines the camera rotation along the latitudinal axis
  42420. * @param radius defines the camera distance from its target
  42421. * @param target defines the camera target
  42422. * @param scene defines the scene the camera belongs to
  42423. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42424. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42425. */
  42426. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42427. /**
  42428. * Gets camera class name
  42429. * @returns VRDeviceOrientationArcRotateCamera
  42430. */
  42431. getClassName(): string;
  42432. }
  42433. }
  42434. declare module BABYLON {
  42435. /**
  42436. * Camera used to simulate VR rendering (based on FreeCamera)
  42437. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42438. */
  42439. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42440. /**
  42441. * Creates a new VRDeviceOrientationFreeCamera
  42442. * @param name defines camera name
  42443. * @param position defines the start position of the camera
  42444. * @param scene defines the scene the camera belongs to
  42445. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42446. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42447. */
  42448. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42449. /**
  42450. * Gets camera class name
  42451. * @returns VRDeviceOrientationFreeCamera
  42452. */
  42453. getClassName(): string;
  42454. }
  42455. }
  42456. declare module BABYLON {
  42457. /**
  42458. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42459. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42460. */
  42461. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42462. /**
  42463. * Creates a new VRDeviceOrientationGamepadCamera
  42464. * @param name defines camera name
  42465. * @param position defines the start position of the camera
  42466. * @param scene defines the scene the camera belongs to
  42467. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42468. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42469. */
  42470. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42471. /**
  42472. * Gets camera class name
  42473. * @returns VRDeviceOrientationGamepadCamera
  42474. */
  42475. getClassName(): string;
  42476. }
  42477. }
  42478. declare module BABYLON {
  42479. /** @hidden */
  42480. export var imageProcessingPixelShader: {
  42481. name: string;
  42482. shader: string;
  42483. };
  42484. }
  42485. declare module BABYLON {
  42486. /**
  42487. * ImageProcessingPostProcess
  42488. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42489. */
  42490. export class ImageProcessingPostProcess extends PostProcess {
  42491. /**
  42492. * Default configuration related to image processing available in the PBR Material.
  42493. */
  42494. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42495. /**
  42496. * Gets the image processing configuration used either in this material.
  42497. */
  42498. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42499. /**
  42500. * Sets the Default image processing configuration used either in the this material.
  42501. *
  42502. * If sets to null, the scene one is in use.
  42503. */
  42504. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42505. /**
  42506. * Keep track of the image processing observer to allow dispose and replace.
  42507. */
  42508. private _imageProcessingObserver;
  42509. /**
  42510. * Attaches a new image processing configuration to the PBR Material.
  42511. * @param configuration
  42512. */
  42513. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42514. /**
  42515. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42516. */
  42517. get colorCurves(): Nullable<ColorCurves>;
  42518. /**
  42519. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42520. */
  42521. set colorCurves(value: Nullable<ColorCurves>);
  42522. /**
  42523. * Gets wether the color curves effect is enabled.
  42524. */
  42525. get colorCurvesEnabled(): boolean;
  42526. /**
  42527. * Sets wether the color curves effect is enabled.
  42528. */
  42529. set colorCurvesEnabled(value: boolean);
  42530. /**
  42531. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42532. */
  42533. get colorGradingTexture(): Nullable<BaseTexture>;
  42534. /**
  42535. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42536. */
  42537. set colorGradingTexture(value: Nullable<BaseTexture>);
  42538. /**
  42539. * Gets wether the color grading effect is enabled.
  42540. */
  42541. get colorGradingEnabled(): boolean;
  42542. /**
  42543. * Gets wether the color grading effect is enabled.
  42544. */
  42545. set colorGradingEnabled(value: boolean);
  42546. /**
  42547. * Gets exposure used in the effect.
  42548. */
  42549. get exposure(): number;
  42550. /**
  42551. * Sets exposure used in the effect.
  42552. */
  42553. set exposure(value: number);
  42554. /**
  42555. * Gets wether tonemapping is enabled or not.
  42556. */
  42557. get toneMappingEnabled(): boolean;
  42558. /**
  42559. * Sets wether tonemapping is enabled or not
  42560. */
  42561. set toneMappingEnabled(value: boolean);
  42562. /**
  42563. * Gets the type of tone mapping effect.
  42564. */
  42565. get toneMappingType(): number;
  42566. /**
  42567. * Sets the type of tone mapping effect.
  42568. */
  42569. set toneMappingType(value: number);
  42570. /**
  42571. * Gets contrast used in the effect.
  42572. */
  42573. get contrast(): number;
  42574. /**
  42575. * Sets contrast used in the effect.
  42576. */
  42577. set contrast(value: number);
  42578. /**
  42579. * Gets Vignette stretch size.
  42580. */
  42581. get vignetteStretch(): number;
  42582. /**
  42583. * Sets Vignette stretch size.
  42584. */
  42585. set vignetteStretch(value: number);
  42586. /**
  42587. * Gets Vignette centre X Offset.
  42588. */
  42589. get vignetteCentreX(): number;
  42590. /**
  42591. * Sets Vignette centre X Offset.
  42592. */
  42593. set vignetteCentreX(value: number);
  42594. /**
  42595. * Gets Vignette centre Y Offset.
  42596. */
  42597. get vignetteCentreY(): number;
  42598. /**
  42599. * Sets Vignette centre Y Offset.
  42600. */
  42601. set vignetteCentreY(value: number);
  42602. /**
  42603. * Gets Vignette weight or intensity of the vignette effect.
  42604. */
  42605. get vignetteWeight(): number;
  42606. /**
  42607. * Sets Vignette weight or intensity of the vignette effect.
  42608. */
  42609. set vignetteWeight(value: number);
  42610. /**
  42611. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42612. * if vignetteEnabled is set to true.
  42613. */
  42614. get vignetteColor(): Color4;
  42615. /**
  42616. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42617. * if vignetteEnabled is set to true.
  42618. */
  42619. set vignetteColor(value: Color4);
  42620. /**
  42621. * Gets Camera field of view used by the Vignette effect.
  42622. */
  42623. get vignetteCameraFov(): number;
  42624. /**
  42625. * Sets Camera field of view used by the Vignette effect.
  42626. */
  42627. set vignetteCameraFov(value: number);
  42628. /**
  42629. * Gets the vignette blend mode allowing different kind of effect.
  42630. */
  42631. get vignetteBlendMode(): number;
  42632. /**
  42633. * Sets the vignette blend mode allowing different kind of effect.
  42634. */
  42635. set vignetteBlendMode(value: number);
  42636. /**
  42637. * Gets wether the vignette effect is enabled.
  42638. */
  42639. get vignetteEnabled(): boolean;
  42640. /**
  42641. * Sets wether the vignette effect is enabled.
  42642. */
  42643. set vignetteEnabled(value: boolean);
  42644. private _fromLinearSpace;
  42645. /**
  42646. * Gets wether the input of the processing is in Gamma or Linear Space.
  42647. */
  42648. get fromLinearSpace(): boolean;
  42649. /**
  42650. * Sets wether the input of the processing is in Gamma or Linear Space.
  42651. */
  42652. set fromLinearSpace(value: boolean);
  42653. /**
  42654. * Defines cache preventing GC.
  42655. */
  42656. private _defines;
  42657. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42658. /**
  42659. * "ImageProcessingPostProcess"
  42660. * @returns "ImageProcessingPostProcess"
  42661. */
  42662. getClassName(): string;
  42663. protected _updateParameters(): void;
  42664. dispose(camera?: Camera): void;
  42665. }
  42666. }
  42667. declare module BABYLON {
  42668. /**
  42669. * Class containing static functions to help procedurally build meshes
  42670. */
  42671. export class GroundBuilder {
  42672. /**
  42673. * Creates a ground mesh
  42674. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42675. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42676. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42677. * @param name defines the name of the mesh
  42678. * @param options defines the options used to create the mesh
  42679. * @param scene defines the hosting scene
  42680. * @returns the ground mesh
  42681. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42682. */
  42683. static CreateGround(name: string, options: {
  42684. width?: number;
  42685. height?: number;
  42686. subdivisions?: number;
  42687. subdivisionsX?: number;
  42688. subdivisionsY?: number;
  42689. updatable?: boolean;
  42690. }, scene: any): Mesh;
  42691. /**
  42692. * Creates a tiled ground mesh
  42693. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42694. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42695. * * 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
  42696. * * 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
  42697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42698. * @param name defines the name of the mesh
  42699. * @param options defines the options used to create the mesh
  42700. * @param scene defines the hosting scene
  42701. * @returns the tiled ground mesh
  42702. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42703. */
  42704. static CreateTiledGround(name: string, options: {
  42705. xmin: number;
  42706. zmin: number;
  42707. xmax: number;
  42708. zmax: number;
  42709. subdivisions?: {
  42710. w: number;
  42711. h: number;
  42712. };
  42713. precision?: {
  42714. w: number;
  42715. h: number;
  42716. };
  42717. updatable?: boolean;
  42718. }, scene?: Nullable<Scene>): Mesh;
  42719. /**
  42720. * Creates a ground mesh from a height map
  42721. * * The parameter `url` sets the URL of the height map image resource.
  42722. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42723. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42724. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42725. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42726. * * 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.
  42727. * * 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).
  42728. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42729. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42730. * @param name defines the name of the mesh
  42731. * @param url defines the url to the height map
  42732. * @param options defines the options used to create the mesh
  42733. * @param scene defines the hosting scene
  42734. * @returns the ground mesh
  42735. * @see https://doc.babylonjs.com/babylon101/height_map
  42736. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42737. */
  42738. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42739. width?: number;
  42740. height?: number;
  42741. subdivisions?: number;
  42742. minHeight?: number;
  42743. maxHeight?: number;
  42744. colorFilter?: Color3;
  42745. alphaFilter?: number;
  42746. updatable?: boolean;
  42747. onReady?: (mesh: GroundMesh) => void;
  42748. }, scene?: Nullable<Scene>): GroundMesh;
  42749. }
  42750. }
  42751. declare module BABYLON {
  42752. /**
  42753. * Class containing static functions to help procedurally build meshes
  42754. */
  42755. export class TorusBuilder {
  42756. /**
  42757. * Creates a torus mesh
  42758. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42759. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42760. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42761. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42762. * * 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
  42763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42764. * @param name defines the name of the mesh
  42765. * @param options defines the options used to create the mesh
  42766. * @param scene defines the hosting scene
  42767. * @returns the torus mesh
  42768. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42769. */
  42770. static CreateTorus(name: string, options: {
  42771. diameter?: number;
  42772. thickness?: number;
  42773. tessellation?: number;
  42774. updatable?: boolean;
  42775. sideOrientation?: number;
  42776. frontUVs?: Vector4;
  42777. backUVs?: Vector4;
  42778. }, scene: any): Mesh;
  42779. }
  42780. }
  42781. declare module BABYLON {
  42782. /**
  42783. * Class containing static functions to help procedurally build meshes
  42784. */
  42785. export class CylinderBuilder {
  42786. /**
  42787. * Creates a cylinder or a cone mesh
  42788. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42789. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42790. * * 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.
  42791. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42792. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42793. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42794. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42795. * * 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).
  42796. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42797. * * 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).
  42798. * * 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
  42799. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42800. * * 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
  42801. * * 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.
  42802. * * If `enclose` is false, a ring surface is one element.
  42803. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42804. * * 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
  42805. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42806. * * 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
  42807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42808. * @param name defines the name of the mesh
  42809. * @param options defines the options used to create the mesh
  42810. * @param scene defines the hosting scene
  42811. * @returns the cylinder mesh
  42812. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42813. */
  42814. static CreateCylinder(name: string, options: {
  42815. height?: number;
  42816. diameterTop?: number;
  42817. diameterBottom?: number;
  42818. diameter?: number;
  42819. tessellation?: number;
  42820. subdivisions?: number;
  42821. arc?: number;
  42822. faceColors?: Color4[];
  42823. faceUV?: Vector4[];
  42824. updatable?: boolean;
  42825. hasRings?: boolean;
  42826. enclose?: boolean;
  42827. cap?: number;
  42828. sideOrientation?: number;
  42829. frontUVs?: Vector4;
  42830. backUVs?: Vector4;
  42831. }, scene: any): Mesh;
  42832. }
  42833. }
  42834. declare module BABYLON {
  42835. /**
  42836. * States of the webXR experience
  42837. */
  42838. export enum WebXRState {
  42839. /**
  42840. * Transitioning to being in XR mode
  42841. */
  42842. ENTERING_XR = 0,
  42843. /**
  42844. * Transitioning to non XR mode
  42845. */
  42846. EXITING_XR = 1,
  42847. /**
  42848. * In XR mode and presenting
  42849. */
  42850. IN_XR = 2,
  42851. /**
  42852. * Not entered XR mode
  42853. */
  42854. NOT_IN_XR = 3
  42855. }
  42856. /**
  42857. * Abstraction of the XR render target
  42858. */
  42859. export interface WebXRRenderTarget extends IDisposable {
  42860. /**
  42861. * xrpresent context of the canvas which can be used to display/mirror xr content
  42862. */
  42863. canvasContext: WebGLRenderingContext;
  42864. /**
  42865. * xr layer for the canvas
  42866. */
  42867. xrLayer: Nullable<XRWebGLLayer>;
  42868. /**
  42869. * Initializes the xr layer for the session
  42870. * @param xrSession xr session
  42871. * @returns a promise that will resolve once the XR Layer has been created
  42872. */
  42873. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42874. }
  42875. }
  42876. declare module BABYLON {
  42877. /**
  42878. * COnfiguration object for WebXR output canvas
  42879. */
  42880. export class WebXRManagedOutputCanvasOptions {
  42881. /**
  42882. * An optional canvas in case you wish to create it yourself and provide it here.
  42883. * If not provided, a new canvas will be created
  42884. */
  42885. canvasElement?: HTMLCanvasElement;
  42886. /**
  42887. * Options for this XR Layer output
  42888. */
  42889. canvasOptions?: XRWebGLLayerOptions;
  42890. /**
  42891. * CSS styling for a newly created canvas (if not provided)
  42892. */
  42893. newCanvasCssStyle?: string;
  42894. /**
  42895. * Get the default values of the configuration object
  42896. * @returns default values of this configuration object
  42897. */
  42898. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  42899. }
  42900. /**
  42901. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42902. */
  42903. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  42904. private _options;
  42905. private _canvas;
  42906. private _engine;
  42907. /**
  42908. * Rendering context of the canvas which can be used to display/mirror xr content
  42909. */
  42910. canvasContext: WebGLRenderingContext;
  42911. /**
  42912. * xr layer for the canvas
  42913. */
  42914. xrLayer: Nullable<XRWebGLLayer>;
  42915. /**
  42916. * Initializes the canvas to be added/removed upon entering/exiting xr
  42917. * @param _xrSessionManager The XR Session manager
  42918. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  42919. */
  42920. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  42921. /**
  42922. * Disposes of the object
  42923. */
  42924. dispose(): void;
  42925. /**
  42926. * Initializes the xr layer for the session
  42927. * @param xrSession xr session
  42928. * @returns a promise that will resolve once the XR Layer has been created
  42929. */
  42930. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42931. private _addCanvas;
  42932. private _removeCanvas;
  42933. private _setManagedOutputCanvas;
  42934. }
  42935. }
  42936. declare module BABYLON {
  42937. /**
  42938. * Manages an XRSession to work with Babylon's engine
  42939. * @see https://doc.babylonjs.com/how_to/webxr
  42940. */
  42941. export class WebXRSessionManager implements IDisposable {
  42942. /** The scene which the session should be created for */
  42943. scene: Scene;
  42944. private _referenceSpace;
  42945. private _rttProvider;
  42946. private _sessionEnded;
  42947. private _xrNavigator;
  42948. private baseLayer;
  42949. /**
  42950. * The base reference space from which the session started. good if you want to reset your
  42951. * reference space
  42952. */
  42953. baseReferenceSpace: XRReferenceSpace;
  42954. /**
  42955. * Current XR frame
  42956. */
  42957. currentFrame: Nullable<XRFrame>;
  42958. /** WebXR timestamp updated every frame */
  42959. currentTimestamp: number;
  42960. /**
  42961. * Used just in case of a failure to initialize an immersive session.
  42962. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  42963. */
  42964. defaultHeightCompensation: number;
  42965. /**
  42966. * Fires every time a new xrFrame arrives which can be used to update the camera
  42967. */
  42968. onXRFrameObservable: Observable<XRFrame>;
  42969. /**
  42970. * Fires when the reference space changed
  42971. */
  42972. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  42973. /**
  42974. * Fires when the xr session is ended either by the device or manually done
  42975. */
  42976. onXRSessionEnded: Observable<any>;
  42977. /**
  42978. * Fires when the xr session is ended either by the device or manually done
  42979. */
  42980. onXRSessionInit: Observable<XRSession>;
  42981. /**
  42982. * Underlying xr session
  42983. */
  42984. session: XRSession;
  42985. /**
  42986. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  42987. * or get the offset the player is currently at.
  42988. */
  42989. viewerReferenceSpace: XRReferenceSpace;
  42990. /**
  42991. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42992. * @param scene The scene which the session should be created for
  42993. */
  42994. constructor(
  42995. /** The scene which the session should be created for */
  42996. scene: Scene);
  42997. /**
  42998. * The current reference space used in this session. This reference space can constantly change!
  42999. * It is mainly used to offset the camera's position.
  43000. */
  43001. get referenceSpace(): XRReferenceSpace;
  43002. /**
  43003. * Set a new reference space and triggers the observable
  43004. */
  43005. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  43006. /**
  43007. * Disposes of the session manager
  43008. */
  43009. dispose(): void;
  43010. /**
  43011. * Stops the xrSession and restores the render loop
  43012. * @returns Promise which resolves after it exits XR
  43013. */
  43014. exitXRAsync(): Promise<void>;
  43015. /**
  43016. * Gets the correct render target texture to be rendered this frame for this eye
  43017. * @param eye the eye for which to get the render target
  43018. * @returns the render target for the specified eye
  43019. */
  43020. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43021. /**
  43022. * Creates a WebXRRenderTarget object for the XR session
  43023. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43024. * @param options optional options to provide when creating a new render target
  43025. * @returns a WebXR render target to which the session can render
  43026. */
  43027. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43028. /**
  43029. * Initializes the manager
  43030. * After initialization enterXR can be called to start an XR session
  43031. * @returns Promise which resolves after it is initialized
  43032. */
  43033. initializeAsync(): Promise<void>;
  43034. /**
  43035. * Initializes an xr session
  43036. * @param xrSessionMode mode to initialize
  43037. * @param xrSessionInit defines optional and required values to pass to the session builder
  43038. * @returns a promise which will resolve once the session has been initialized
  43039. */
  43040. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  43041. /**
  43042. * Checks if a session would be supported for the creation options specified
  43043. * @param sessionMode session mode to check if supported eg. immersive-vr
  43044. * @returns A Promise that resolves to true if supported and false if not
  43045. */
  43046. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43047. /**
  43048. * Resets the reference space to the one started the session
  43049. */
  43050. resetReferenceSpace(): void;
  43051. /**
  43052. * Starts rendering to the xr layer
  43053. */
  43054. runXRRenderLoop(): void;
  43055. /**
  43056. * Sets the reference space on the xr session
  43057. * @param referenceSpaceType space to set
  43058. * @returns a promise that will resolve once the reference space has been set
  43059. */
  43060. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  43061. /**
  43062. * Updates the render state of the session
  43063. * @param state state to set
  43064. * @returns a promise that resolves once the render state has been updated
  43065. */
  43066. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43067. /**
  43068. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  43069. * @param sessionMode defines the session to test
  43070. * @returns a promise with boolean as final value
  43071. */
  43072. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43073. private _createRenderTargetTexture;
  43074. }
  43075. }
  43076. declare module BABYLON {
  43077. /**
  43078. * WebXR Camera which holds the views for the xrSession
  43079. * @see https://doc.babylonjs.com/how_to/webxr_camera
  43080. */
  43081. export class WebXRCamera extends FreeCamera {
  43082. private _xrSessionManager;
  43083. private _firstFrame;
  43084. private _referenceQuaternion;
  43085. private _referencedPosition;
  43086. private _xrInvPositionCache;
  43087. private _xrInvQuaternionCache;
  43088. /**
  43089. * Should position compensation execute on first frame.
  43090. * This is used when copying the position from a native (non XR) camera
  43091. */
  43092. compensateOnFirstFrame: boolean;
  43093. /**
  43094. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43095. * @param name the name of the camera
  43096. * @param scene the scene to add the camera to
  43097. * @param _xrSessionManager a constructed xr session manager
  43098. */
  43099. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  43100. /**
  43101. * Return the user's height, unrelated to the current ground.
  43102. * This will be the y position of this camera, when ground level is 0.
  43103. */
  43104. get realWorldHeight(): number;
  43105. /** @hidden */
  43106. _updateForDualEyeDebugging(): void;
  43107. /**
  43108. * Sets this camera's transformation based on a non-vr camera
  43109. * @param otherCamera the non-vr camera to copy the transformation from
  43110. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  43111. */
  43112. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  43113. /**
  43114. * Gets the current instance class name ("WebXRCamera").
  43115. * @returns the class name
  43116. */
  43117. getClassName(): string;
  43118. private _updateFromXRSession;
  43119. private _updateNumberOfRigCameras;
  43120. private _updateReferenceSpace;
  43121. private _updateReferenceSpaceOffset;
  43122. }
  43123. }
  43124. declare module BABYLON {
  43125. /**
  43126. * Defining the interface required for a (webxr) feature
  43127. */
  43128. export interface IWebXRFeature extends IDisposable {
  43129. /**
  43130. * Is this feature attached
  43131. */
  43132. attached: boolean;
  43133. /**
  43134. * Should auto-attach be disabled?
  43135. */
  43136. disableAutoAttach: boolean;
  43137. /**
  43138. * Attach the feature to the session
  43139. * Will usually be called by the features manager
  43140. *
  43141. * @param force should attachment be forced (even when already attached)
  43142. * @returns true if successful.
  43143. */
  43144. attach(force?: boolean): boolean;
  43145. /**
  43146. * Detach the feature from the session
  43147. * Will usually be called by the features manager
  43148. *
  43149. * @returns true if successful.
  43150. */
  43151. detach(): boolean;
  43152. }
  43153. /**
  43154. * A list of the currently available features without referencing them
  43155. */
  43156. export class WebXRFeatureName {
  43157. /**
  43158. * The name of the anchor system feature
  43159. */
  43160. static ANCHOR_SYSTEM: string;
  43161. /**
  43162. * The name of the background remover feature
  43163. */
  43164. static BACKGROUND_REMOVER: string;
  43165. /**
  43166. * The name of the hit test feature
  43167. */
  43168. static HIT_TEST: string;
  43169. /**
  43170. * physics impostors for xr controllers feature
  43171. */
  43172. static PHYSICS_CONTROLLERS: string;
  43173. /**
  43174. * The name of the plane detection feature
  43175. */
  43176. static PLANE_DETECTION: string;
  43177. /**
  43178. * The name of the pointer selection feature
  43179. */
  43180. static POINTER_SELECTION: string;
  43181. /**
  43182. * The name of the teleportation feature
  43183. */
  43184. static TELEPORTATION: string;
  43185. }
  43186. /**
  43187. * Defining the constructor of a feature. Used to register the modules.
  43188. */
  43189. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  43190. /**
  43191. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  43192. * It is mainly used in AR sessions.
  43193. *
  43194. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  43195. */
  43196. export class WebXRFeaturesManager implements IDisposable {
  43197. private _xrSessionManager;
  43198. private static readonly _AvailableFeatures;
  43199. private _features;
  43200. /**
  43201. * constructs a new features manages.
  43202. *
  43203. * @param _xrSessionManager an instance of WebXRSessionManager
  43204. */
  43205. constructor(_xrSessionManager: WebXRSessionManager);
  43206. /**
  43207. * Used to register a module. After calling this function a developer can use this feature in the scene.
  43208. * Mainly used internally.
  43209. *
  43210. * @param featureName the name of the feature to register
  43211. * @param constructorFunction the function used to construct the module
  43212. * @param version the (babylon) version of the module
  43213. * @param stable is that a stable version of this module
  43214. */
  43215. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  43216. /**
  43217. * Returns a constructor of a specific feature.
  43218. *
  43219. * @param featureName the name of the feature to construct
  43220. * @param version the version of the feature to load
  43221. * @param xrSessionManager the xrSessionManager. Used to construct the module
  43222. * @param options optional options provided to the module.
  43223. * @returns a function that, when called, will return a new instance of this feature
  43224. */
  43225. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  43226. /**
  43227. * Can be used to return the list of features currently registered
  43228. *
  43229. * @returns an Array of available features
  43230. */
  43231. static GetAvailableFeatures(): string[];
  43232. /**
  43233. * Gets the versions available for a specific feature
  43234. * @param featureName the name of the feature
  43235. * @returns an array with the available versions
  43236. */
  43237. static GetAvailableVersions(featureName: string): string[];
  43238. /**
  43239. * Return the latest unstable version of this feature
  43240. * @param featureName the name of the feature to search
  43241. * @returns the version number. if not found will return -1
  43242. */
  43243. static GetLatestVersionOfFeature(featureName: string): number;
  43244. /**
  43245. * Return the latest stable version of this feature
  43246. * @param featureName the name of the feature to search
  43247. * @returns the version number. if not found will return -1
  43248. */
  43249. static GetStableVersionOfFeature(featureName: string): number;
  43250. /**
  43251. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  43252. * Can be used during a session to start a feature
  43253. * @param featureName the name of feature to attach
  43254. */
  43255. attachFeature(featureName: string): void;
  43256. /**
  43257. * Can be used inside a session or when the session ends to detach a specific feature
  43258. * @param featureName the name of the feature to detach
  43259. */
  43260. detachFeature(featureName: string): void;
  43261. /**
  43262. * Used to disable an already-enabled feature
  43263. * The feature will be disposed and will be recreated once enabled.
  43264. * @param featureName the feature to disable
  43265. * @returns true if disable was successful
  43266. */
  43267. disableFeature(featureName: string | {
  43268. Name: string;
  43269. }): boolean;
  43270. /**
  43271. * dispose this features manager
  43272. */
  43273. dispose(): void;
  43274. /**
  43275. * 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.
  43276. * 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.
  43277. *
  43278. * @param featureName the name of the feature to load or the class of the feature
  43279. * @param version optional version to load. if not provided the latest version will be enabled
  43280. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  43281. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  43282. * @returns a new constructed feature or throws an error if feature not found.
  43283. */
  43284. enableFeature(featureName: string | {
  43285. Name: string;
  43286. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  43287. /**
  43288. * get the implementation of an enabled feature.
  43289. * @param featureName the name of the feature to load
  43290. * @returns the feature class, if found
  43291. */
  43292. getEnabledFeature(featureName: string): IWebXRFeature;
  43293. /**
  43294. * Get the list of enabled features
  43295. * @returns an array of enabled features
  43296. */
  43297. getEnabledFeatures(): string[];
  43298. }
  43299. }
  43300. declare module BABYLON {
  43301. /**
  43302. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  43303. * @see https://doc.babylonjs.com/how_to/webxr
  43304. */
  43305. export class WebXRExperienceHelper implements IDisposable {
  43306. private scene;
  43307. private _nonVRCamera;
  43308. private _originalSceneAutoClear;
  43309. private _supported;
  43310. /**
  43311. * Camera used to render xr content
  43312. */
  43313. camera: WebXRCamera;
  43314. /** A features manager for this xr session */
  43315. featuresManager: WebXRFeaturesManager;
  43316. /**
  43317. * Observers registered here will be triggered after the camera's initial transformation is set
  43318. * This can be used to set a different ground level or an extra rotation.
  43319. *
  43320. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  43321. * to the position set after this observable is done executing.
  43322. */
  43323. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  43324. /**
  43325. * Fires when the state of the experience helper has changed
  43326. */
  43327. onStateChangedObservable: Observable<WebXRState>;
  43328. /** Session manager used to keep track of xr session */
  43329. sessionManager: WebXRSessionManager;
  43330. /**
  43331. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43332. */
  43333. state: WebXRState;
  43334. /**
  43335. * Creates a WebXRExperienceHelper
  43336. * @param scene The scene the helper should be created in
  43337. */
  43338. private constructor();
  43339. /**
  43340. * Creates the experience helper
  43341. * @param scene the scene to attach the experience helper to
  43342. * @returns a promise for the experience helper
  43343. */
  43344. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43345. /**
  43346. * Disposes of the experience helper
  43347. */
  43348. dispose(): void;
  43349. /**
  43350. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43351. * @param sessionMode options for the XR session
  43352. * @param referenceSpaceType frame of reference of the XR session
  43353. * @param renderTarget the output canvas that will be used to enter XR mode
  43354. * @returns promise that resolves after xr mode has entered
  43355. */
  43356. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43357. /**
  43358. * Exits XR mode and returns the scene to its original state
  43359. * @returns promise that resolves after xr mode has exited
  43360. */
  43361. exitXRAsync(): Promise<void>;
  43362. private _nonXRToXRCamera;
  43363. private _setState;
  43364. }
  43365. }
  43366. declare module BABYLON {
  43367. /**
  43368. * X-Y values for axes in WebXR
  43369. */
  43370. export interface IWebXRMotionControllerAxesValue {
  43371. /**
  43372. * The value of the x axis
  43373. */
  43374. x: number;
  43375. /**
  43376. * The value of the y-axis
  43377. */
  43378. y: number;
  43379. }
  43380. /**
  43381. * changed / previous values for the values of this component
  43382. */
  43383. export interface IWebXRMotionControllerComponentChangesValues<T> {
  43384. /**
  43385. * current (this frame) value
  43386. */
  43387. current: T;
  43388. /**
  43389. * previous (last change) value
  43390. */
  43391. previous: T;
  43392. }
  43393. /**
  43394. * Represents changes in the component between current frame and last values recorded
  43395. */
  43396. export interface IWebXRMotionControllerComponentChanges {
  43397. /**
  43398. * will be populated with previous and current values if axes changed
  43399. */
  43400. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  43401. /**
  43402. * will be populated with previous and current values if pressed changed
  43403. */
  43404. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43405. /**
  43406. * will be populated with previous and current values if touched changed
  43407. */
  43408. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43409. /**
  43410. * will be populated with previous and current values if value changed
  43411. */
  43412. value?: IWebXRMotionControllerComponentChangesValues<number>;
  43413. }
  43414. /**
  43415. * This class represents a single component (for example button or thumbstick) of a motion controller
  43416. */
  43417. export class WebXRControllerComponent implements IDisposable {
  43418. /**
  43419. * the id of this component
  43420. */
  43421. id: string;
  43422. /**
  43423. * the type of the component
  43424. */
  43425. type: MotionControllerComponentType;
  43426. private _buttonIndex;
  43427. private _axesIndices;
  43428. private _axes;
  43429. private _changes;
  43430. private _currentValue;
  43431. private _hasChanges;
  43432. private _pressed;
  43433. private _touched;
  43434. /**
  43435. * button component type
  43436. */
  43437. static BUTTON_TYPE: MotionControllerComponentType;
  43438. /**
  43439. * squeeze component type
  43440. */
  43441. static SQUEEZE_TYPE: MotionControllerComponentType;
  43442. /**
  43443. * Thumbstick component type
  43444. */
  43445. static THUMBSTICK_TYPE: MotionControllerComponentType;
  43446. /**
  43447. * Touchpad component type
  43448. */
  43449. static TOUCHPAD_TYPE: MotionControllerComponentType;
  43450. /**
  43451. * trigger component type
  43452. */
  43453. static TRIGGER_TYPE: MotionControllerComponentType;
  43454. /**
  43455. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  43456. * the axes data changes
  43457. */
  43458. onAxisValueChangedObservable: Observable<{
  43459. x: number;
  43460. y: number;
  43461. }>;
  43462. /**
  43463. * Observers registered here will be triggered when the state of a button changes
  43464. * State change is either pressed / touched / value
  43465. */
  43466. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  43467. /**
  43468. * Creates a new component for a motion controller.
  43469. * It is created by the motion controller itself
  43470. *
  43471. * @param id the id of this component
  43472. * @param type the type of the component
  43473. * @param _buttonIndex index in the buttons array of the gamepad
  43474. * @param _axesIndices indices of the values in the axes array of the gamepad
  43475. */
  43476. constructor(
  43477. /**
  43478. * the id of this component
  43479. */
  43480. id: string,
  43481. /**
  43482. * the type of the component
  43483. */
  43484. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43485. /**
  43486. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43487. */
  43488. get axes(): IWebXRMotionControllerAxesValue;
  43489. /**
  43490. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43491. */
  43492. get changes(): IWebXRMotionControllerComponentChanges;
  43493. /**
  43494. * Return whether or not the component changed the last frame
  43495. */
  43496. get hasChanges(): boolean;
  43497. /**
  43498. * is the button currently pressed
  43499. */
  43500. get pressed(): boolean;
  43501. /**
  43502. * is the button currently touched
  43503. */
  43504. get touched(): boolean;
  43505. /**
  43506. * Get the current value of this component
  43507. */
  43508. get value(): number;
  43509. /**
  43510. * Dispose this component
  43511. */
  43512. dispose(): void;
  43513. /**
  43514. * Are there axes correlating to this component
  43515. * @return true is axes data is available
  43516. */
  43517. isAxes(): boolean;
  43518. /**
  43519. * Is this component a button (hence - pressable)
  43520. * @returns true if can be pressed
  43521. */
  43522. isButton(): boolean;
  43523. /**
  43524. * update this component using the gamepad object it is in. Called on every frame
  43525. * @param nativeController the native gamepad controller object
  43526. */
  43527. update(nativeController: IMinimalMotionControllerObject): void;
  43528. }
  43529. }
  43530. declare module BABYLON {
  43531. /**
  43532. * Class used to represent data loading progression
  43533. */
  43534. export class SceneLoaderProgressEvent {
  43535. /** defines if data length to load can be evaluated */
  43536. readonly lengthComputable: boolean;
  43537. /** defines the loaded data length */
  43538. readonly loaded: number;
  43539. /** defines the data length to load */
  43540. readonly total: number;
  43541. /**
  43542. * Create a new progress event
  43543. * @param lengthComputable defines if data length to load can be evaluated
  43544. * @param loaded defines the loaded data length
  43545. * @param total defines the data length to load
  43546. */
  43547. constructor(
  43548. /** defines if data length to load can be evaluated */
  43549. lengthComputable: boolean,
  43550. /** defines the loaded data length */
  43551. loaded: number,
  43552. /** defines the data length to load */
  43553. total: number);
  43554. /**
  43555. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43556. * @param event defines the source event
  43557. * @returns a new SceneLoaderProgressEvent
  43558. */
  43559. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43560. }
  43561. /**
  43562. * Interface used by SceneLoader plugins to define supported file extensions
  43563. */
  43564. export interface ISceneLoaderPluginExtensions {
  43565. /**
  43566. * Defines the list of supported extensions
  43567. */
  43568. [extension: string]: {
  43569. isBinary: boolean;
  43570. };
  43571. }
  43572. /**
  43573. * Interface used by SceneLoader plugin factory
  43574. */
  43575. export interface ISceneLoaderPluginFactory {
  43576. /**
  43577. * Defines the name of the factory
  43578. */
  43579. name: string;
  43580. /**
  43581. * Function called to create a new plugin
  43582. * @return the new plugin
  43583. */
  43584. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43585. /**
  43586. * The callback that returns true if the data can be directly loaded.
  43587. * @param data string containing the file data
  43588. * @returns if the data can be loaded directly
  43589. */
  43590. canDirectLoad?(data: string): boolean;
  43591. }
  43592. /**
  43593. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43594. */
  43595. export interface ISceneLoaderPluginBase {
  43596. /**
  43597. * The friendly name of this plugin.
  43598. */
  43599. name: string;
  43600. /**
  43601. * The file extensions supported by this plugin.
  43602. */
  43603. extensions: string | ISceneLoaderPluginExtensions;
  43604. /**
  43605. * The callback called when loading from a url.
  43606. * @param scene scene loading this url
  43607. * @param url url to load
  43608. * @param onSuccess callback called when the file successfully loads
  43609. * @param onProgress callback called while file is loading (if the server supports this mode)
  43610. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43611. * @param onError callback called when the file fails to load
  43612. * @returns a file request object
  43613. */
  43614. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43615. /**
  43616. * The callback called when loading from a file object.
  43617. * @param scene scene loading this file
  43618. * @param file defines the file to load
  43619. * @param onSuccess defines the callback to call when data is loaded
  43620. * @param onProgress defines the callback to call during loading process
  43621. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43622. * @param onError defines the callback to call when an error occurs
  43623. * @returns a file request object
  43624. */
  43625. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43626. /**
  43627. * The callback that returns true if the data can be directly loaded.
  43628. * @param data string containing the file data
  43629. * @returns if the data can be loaded directly
  43630. */
  43631. canDirectLoad?(data: string): boolean;
  43632. /**
  43633. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43634. * @param scene scene loading this data
  43635. * @param data string containing the data
  43636. * @returns data to pass to the plugin
  43637. */
  43638. directLoad?(scene: Scene, data: string): any;
  43639. /**
  43640. * The callback that allows custom handling of the root url based on the response url.
  43641. * @param rootUrl the original root url
  43642. * @param responseURL the response url if available
  43643. * @returns the new root url
  43644. */
  43645. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43646. }
  43647. /**
  43648. * Interface used to define a SceneLoader plugin
  43649. */
  43650. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43651. /**
  43652. * Import meshes into a scene.
  43653. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43654. * @param scene The scene to import into
  43655. * @param data The data to import
  43656. * @param rootUrl The root url for scene and resources
  43657. * @param meshes The meshes array to import into
  43658. * @param particleSystems The particle systems array to import into
  43659. * @param skeletons The skeletons array to import into
  43660. * @param onError The callback when import fails
  43661. * @returns True if successful or false otherwise
  43662. */
  43663. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43664. /**
  43665. * Load into a scene.
  43666. * @param scene The scene to load into
  43667. * @param data The data to import
  43668. * @param rootUrl The root url for scene and resources
  43669. * @param onError The callback when import fails
  43670. * @returns True if successful or false otherwise
  43671. */
  43672. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43673. /**
  43674. * Load into an asset container.
  43675. * @param scene The scene to load into
  43676. * @param data The data to import
  43677. * @param rootUrl The root url for scene and resources
  43678. * @param onError The callback when import fails
  43679. * @returns The loaded asset container
  43680. */
  43681. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43682. }
  43683. /**
  43684. * Interface used to define an async SceneLoader plugin
  43685. */
  43686. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43687. /**
  43688. * Import meshes into a scene.
  43689. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43690. * @param scene The scene to import into
  43691. * @param data The data to import
  43692. * @param rootUrl The root url for scene and resources
  43693. * @param onProgress The callback when the load progresses
  43694. * @param fileName Defines the name of the file to load
  43695. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43696. */
  43697. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43698. meshes: AbstractMesh[];
  43699. particleSystems: IParticleSystem[];
  43700. skeletons: Skeleton[];
  43701. animationGroups: AnimationGroup[];
  43702. }>;
  43703. /**
  43704. * Load into a scene.
  43705. * @param scene The scene to load into
  43706. * @param data The data to import
  43707. * @param rootUrl The root url for scene and resources
  43708. * @param onProgress The callback when the load progresses
  43709. * @param fileName Defines the name of the file to load
  43710. * @returns Nothing
  43711. */
  43712. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43713. /**
  43714. * Load into an asset container.
  43715. * @param scene The scene to load into
  43716. * @param data The data to import
  43717. * @param rootUrl The root url for scene and resources
  43718. * @param onProgress The callback when the load progresses
  43719. * @param fileName Defines the name of the file to load
  43720. * @returns The loaded asset container
  43721. */
  43722. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43723. }
  43724. /**
  43725. * Mode that determines how to handle old animation groups before loading new ones.
  43726. */
  43727. export enum SceneLoaderAnimationGroupLoadingMode {
  43728. /**
  43729. * Reset all old animations to initial state then dispose them.
  43730. */
  43731. Clean = 0,
  43732. /**
  43733. * Stop all old animations.
  43734. */
  43735. Stop = 1,
  43736. /**
  43737. * Restart old animations from first frame.
  43738. */
  43739. Sync = 2,
  43740. /**
  43741. * Old animations remains untouched.
  43742. */
  43743. NoSync = 3
  43744. }
  43745. /**
  43746. * Class used to load scene from various file formats using registered plugins
  43747. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43748. */
  43749. export class SceneLoader {
  43750. /**
  43751. * No logging while loading
  43752. */
  43753. static readonly NO_LOGGING: number;
  43754. /**
  43755. * Minimal logging while loading
  43756. */
  43757. static readonly MINIMAL_LOGGING: number;
  43758. /**
  43759. * Summary logging while loading
  43760. */
  43761. static readonly SUMMARY_LOGGING: number;
  43762. /**
  43763. * Detailled logging while loading
  43764. */
  43765. static readonly DETAILED_LOGGING: number;
  43766. /**
  43767. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43768. */
  43769. static get ForceFullSceneLoadingForIncremental(): boolean;
  43770. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43771. /**
  43772. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43773. */
  43774. static get ShowLoadingScreen(): boolean;
  43775. static set ShowLoadingScreen(value: boolean);
  43776. /**
  43777. * Defines the current logging level (while loading the scene)
  43778. * @ignorenaming
  43779. */
  43780. static get loggingLevel(): number;
  43781. static set loggingLevel(value: number);
  43782. /**
  43783. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43784. */
  43785. static get CleanBoneMatrixWeights(): boolean;
  43786. static set CleanBoneMatrixWeights(value: boolean);
  43787. /**
  43788. * Event raised when a plugin is used to load a scene
  43789. */
  43790. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43791. private static _registeredPlugins;
  43792. private static _getDefaultPlugin;
  43793. private static _getPluginForExtension;
  43794. private static _getPluginForDirectLoad;
  43795. private static _getPluginForFilename;
  43796. private static _getDirectLoad;
  43797. private static _loadData;
  43798. private static _getFileInfo;
  43799. /**
  43800. * Gets a plugin that can load the given extension
  43801. * @param extension defines the extension to load
  43802. * @returns a plugin or null if none works
  43803. */
  43804. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43805. /**
  43806. * Gets a boolean indicating that the given extension can be loaded
  43807. * @param extension defines the extension to load
  43808. * @returns true if the extension is supported
  43809. */
  43810. static IsPluginForExtensionAvailable(extension: string): boolean;
  43811. /**
  43812. * Adds a new plugin to the list of registered plugins
  43813. * @param plugin defines the plugin to add
  43814. */
  43815. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43816. /**
  43817. * Import meshes into a scene
  43818. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43819. * @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)
  43820. * @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)
  43821. * @param scene the instance of BABYLON.Scene to append to
  43822. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43823. * @param onProgress a callback with a progress event for each file being loaded
  43824. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43825. * @param pluginExtension the extension used to determine the plugin
  43826. * @returns The loaded plugin
  43827. */
  43828. 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>;
  43829. /**
  43830. * Import meshes into a scene
  43831. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43832. * @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)
  43833. * @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)
  43834. * @param scene the instance of BABYLON.Scene to append to
  43835. * @param onProgress a callback with a progress event for each file being loaded
  43836. * @param pluginExtension the extension used to determine the plugin
  43837. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43838. */
  43839. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43840. meshes: AbstractMesh[];
  43841. particleSystems: IParticleSystem[];
  43842. skeletons: Skeleton[];
  43843. animationGroups: AnimationGroup[];
  43844. }>;
  43845. /**
  43846. * Load a scene
  43847. * @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)
  43848. * @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)
  43849. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43850. * @param onSuccess a callback with the scene when import succeeds
  43851. * @param onProgress a callback with a progress event for each file being loaded
  43852. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43853. * @param pluginExtension the extension used to determine the plugin
  43854. * @returns The loaded plugin
  43855. */
  43856. 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>;
  43857. /**
  43858. * Load a scene
  43859. * @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)
  43860. * @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)
  43861. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43862. * @param onProgress a callback with a progress event for each file being loaded
  43863. * @param pluginExtension the extension used to determine the plugin
  43864. * @returns The loaded scene
  43865. */
  43866. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43867. /**
  43868. * Append a scene
  43869. * @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)
  43870. * @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)
  43871. * @param scene is the instance of BABYLON.Scene to append to
  43872. * @param onSuccess a callback with the scene when import succeeds
  43873. * @param onProgress a callback with a progress event for each file being loaded
  43874. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43875. * @param pluginExtension the extension used to determine the plugin
  43876. * @returns The loaded plugin
  43877. */
  43878. 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>;
  43879. /**
  43880. * Append a scene
  43881. * @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)
  43882. * @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)
  43883. * @param scene is the instance of BABYLON.Scene to append to
  43884. * @param onProgress a callback with a progress event for each file being loaded
  43885. * @param pluginExtension the extension used to determine the plugin
  43886. * @returns The given scene
  43887. */
  43888. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43889. /**
  43890. * Load a scene into an asset container
  43891. * @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)
  43892. * @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)
  43893. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43894. * @param onSuccess a callback with the scene when import succeeds
  43895. * @param onProgress a callback with a progress event for each file being loaded
  43896. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43897. * @param pluginExtension the extension used to determine the plugin
  43898. * @returns The loaded plugin
  43899. */
  43900. 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>;
  43901. /**
  43902. * Load a scene into an asset container
  43903. * @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)
  43904. * @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)
  43905. * @param scene is the instance of Scene to append to
  43906. * @param onProgress a callback with a progress event for each file being loaded
  43907. * @param pluginExtension the extension used to determine the plugin
  43908. * @returns The loaded asset container
  43909. */
  43910. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43911. /**
  43912. * Import animations from a file into a scene
  43913. * @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)
  43914. * @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)
  43915. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43916. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43917. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43918. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43919. * @param onSuccess a callback with the scene when import succeeds
  43920. * @param onProgress a callback with a progress event for each file being loaded
  43921. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43922. */
  43923. 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;
  43924. /**
  43925. * Import animations from a file into a scene
  43926. * @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)
  43927. * @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)
  43928. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43929. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43930. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43931. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43932. * @param onSuccess a callback with the scene when import succeeds
  43933. * @param onProgress a callback with a progress event for each file being loaded
  43934. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43935. * @returns the updated scene with imported animations
  43936. */
  43937. 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>;
  43938. }
  43939. }
  43940. declare module BABYLON {
  43941. /**
  43942. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  43943. */
  43944. export type MotionControllerHandness = "none" | "left" | "right";
  43945. /**
  43946. * The type of components available in motion controllers.
  43947. * This is not the name of the component.
  43948. */
  43949. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  43950. /**
  43951. * The state of a controller component
  43952. */
  43953. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  43954. /**
  43955. * The schema of motion controller layout.
  43956. * No object will be initialized using this interface
  43957. * This is used just to define the profile.
  43958. */
  43959. export interface IMotionControllerLayout {
  43960. /**
  43961. * Path to load the assets. Usually relative to the base path
  43962. */
  43963. assetPath: string;
  43964. /**
  43965. * Available components (unsorted)
  43966. */
  43967. components: {
  43968. /**
  43969. * A map of component Ids
  43970. */
  43971. [componentId: string]: {
  43972. /**
  43973. * The type of input the component outputs
  43974. */
  43975. type: MotionControllerComponentType;
  43976. /**
  43977. * The indices of this component in the gamepad object
  43978. */
  43979. gamepadIndices: {
  43980. /**
  43981. * Index of button
  43982. */
  43983. button?: number;
  43984. /**
  43985. * If available, index of x-axis
  43986. */
  43987. xAxis?: number;
  43988. /**
  43989. * If available, index of y-axis
  43990. */
  43991. yAxis?: number;
  43992. };
  43993. /**
  43994. * The mesh's root node name
  43995. */
  43996. rootNodeName: string;
  43997. /**
  43998. * Animation definitions for this model
  43999. */
  44000. visualResponses: {
  44001. [stateKey: string]: {
  44002. /**
  44003. * What property will be animated
  44004. */
  44005. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  44006. /**
  44007. * What states influence this visual response
  44008. */
  44009. states: MotionControllerComponentStateType[];
  44010. /**
  44011. * Type of animation - movement or visibility
  44012. */
  44013. valueNodeProperty: "transform" | "visibility";
  44014. /**
  44015. * Base node name to move. Its position will be calculated according to the min and max nodes
  44016. */
  44017. valueNodeName?: string;
  44018. /**
  44019. * Minimum movement node
  44020. */
  44021. minNodeName?: string;
  44022. /**
  44023. * Max movement node
  44024. */
  44025. maxNodeName?: string;
  44026. };
  44027. };
  44028. /**
  44029. * If touch enabled, what is the name of node to display user feedback
  44030. */
  44031. touchPointNodeName?: string;
  44032. };
  44033. };
  44034. /**
  44035. * Is it xr standard mapping or not
  44036. */
  44037. gamepadMapping: "" | "xr-standard";
  44038. /**
  44039. * Base root node of this entire model
  44040. */
  44041. rootNodeName: string;
  44042. /**
  44043. * Defines the main button component id
  44044. */
  44045. selectComponentId: string;
  44046. }
  44047. /**
  44048. * A definition for the layout map in the input profile
  44049. */
  44050. export interface IMotionControllerLayoutMap {
  44051. /**
  44052. * Layouts with handness type as a key
  44053. */
  44054. [handness: string]: IMotionControllerLayout;
  44055. }
  44056. /**
  44057. * The XR Input profile schema
  44058. * Profiles can be found here:
  44059. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  44060. */
  44061. export interface IMotionControllerProfile {
  44062. /**
  44063. * fallback profiles for this profileId
  44064. */
  44065. fallbackProfileIds: string[];
  44066. /**
  44067. * The layout map, with handness as key
  44068. */
  44069. layouts: IMotionControllerLayoutMap;
  44070. /**
  44071. * The id of this profile
  44072. * correlates to the profile(s) in the xrInput.profiles array
  44073. */
  44074. profileId: string;
  44075. }
  44076. /**
  44077. * A helper-interface for the 3 meshes needed for controller button animation
  44078. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  44079. */
  44080. export interface IMotionControllerButtonMeshMap {
  44081. /**
  44082. * the mesh that defines the pressed value mesh position.
  44083. * This is used to find the max-position of this button
  44084. */
  44085. pressedMesh: AbstractMesh;
  44086. /**
  44087. * the mesh that defines the unpressed value mesh position.
  44088. * This is used to find the min (or initial) position of this button
  44089. */
  44090. unpressedMesh: AbstractMesh;
  44091. /**
  44092. * The mesh that will be changed when value changes
  44093. */
  44094. valueMesh: AbstractMesh;
  44095. }
  44096. /**
  44097. * A helper-interface for the 3 meshes needed for controller axis animation.
  44098. * This will be expanded when touchpad animations are fully supported
  44099. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  44100. */
  44101. export interface IMotionControllerMeshMap {
  44102. /**
  44103. * the mesh that defines the maximum value mesh position.
  44104. */
  44105. maxMesh?: AbstractMesh;
  44106. /**
  44107. * the mesh that defines the minimum value mesh position.
  44108. */
  44109. minMesh?: AbstractMesh;
  44110. /**
  44111. * The mesh that will be changed when axis value changes
  44112. */
  44113. valueMesh: AbstractMesh;
  44114. }
  44115. /**
  44116. * The elements needed for change-detection of the gamepad objects in motion controllers
  44117. */
  44118. export interface IMinimalMotionControllerObject {
  44119. /**
  44120. * Available axes of this controller
  44121. */
  44122. axes: number[];
  44123. /**
  44124. * An array of available buttons
  44125. */
  44126. buttons: Array<{
  44127. /**
  44128. * Value of the button/trigger
  44129. */
  44130. value: number;
  44131. /**
  44132. * If the button/trigger is currently touched
  44133. */
  44134. touched: boolean;
  44135. /**
  44136. * If the button/trigger is currently pressed
  44137. */
  44138. pressed: boolean;
  44139. }>;
  44140. }
  44141. /**
  44142. * An Abstract Motion controller
  44143. * This class receives an xrInput and a profile layout and uses those to initialize the components
  44144. * Each component has an observable to check for changes in value and state
  44145. */
  44146. export abstract class WebXRAbstractMotionController implements IDisposable {
  44147. protected scene: Scene;
  44148. protected layout: IMotionControllerLayout;
  44149. /**
  44150. * The gamepad object correlating to this controller
  44151. */
  44152. gamepadObject: IMinimalMotionControllerObject;
  44153. /**
  44154. * handness (left/right/none) of this controller
  44155. */
  44156. handness: MotionControllerHandness;
  44157. private _initComponent;
  44158. private _modelReady;
  44159. /**
  44160. * A map of components (WebXRControllerComponent) in this motion controller
  44161. * Components have a ComponentType and can also have both button and axis definitions
  44162. */
  44163. readonly components: {
  44164. [id: string]: WebXRControllerComponent;
  44165. };
  44166. /**
  44167. * Disable the model's animation. Can be set at any time.
  44168. */
  44169. disableAnimation: boolean;
  44170. /**
  44171. * Observers registered here will be triggered when the model of this controller is done loading
  44172. */
  44173. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  44174. /**
  44175. * The profile id of this motion controller
  44176. */
  44177. abstract profileId: string;
  44178. /**
  44179. * The root mesh of the model. It is null if the model was not yet initialized
  44180. */
  44181. rootMesh: Nullable<AbstractMesh>;
  44182. /**
  44183. * constructs a new abstract motion controller
  44184. * @param scene the scene to which the model of the controller will be added
  44185. * @param layout The profile layout to load
  44186. * @param gamepadObject The gamepad object correlating to this controller
  44187. * @param handness handness (left/right/none) of this controller
  44188. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  44189. */
  44190. constructor(scene: Scene, layout: IMotionControllerLayout,
  44191. /**
  44192. * The gamepad object correlating to this controller
  44193. */
  44194. gamepadObject: IMinimalMotionControllerObject,
  44195. /**
  44196. * handness (left/right/none) of this controller
  44197. */
  44198. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  44199. /**
  44200. * Dispose this controller, the model mesh and all its components
  44201. */
  44202. dispose(): void;
  44203. /**
  44204. * Returns all components of specific type
  44205. * @param type the type to search for
  44206. * @return an array of components with this type
  44207. */
  44208. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  44209. /**
  44210. * get a component based an its component id as defined in layout.components
  44211. * @param id the id of the component
  44212. * @returns the component correlates to the id or undefined if not found
  44213. */
  44214. getComponent(id: string): WebXRControllerComponent;
  44215. /**
  44216. * Get the list of components available in this motion controller
  44217. * @returns an array of strings correlating to available components
  44218. */
  44219. getComponentIds(): string[];
  44220. /**
  44221. * Get the first component of specific type
  44222. * @param type type of component to find
  44223. * @return a controller component or null if not found
  44224. */
  44225. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  44226. /**
  44227. * Get the main (Select) component of this controller as defined in the layout
  44228. * @returns the main component of this controller
  44229. */
  44230. getMainComponent(): WebXRControllerComponent;
  44231. /**
  44232. * Loads the model correlating to this controller
  44233. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  44234. * @returns A promise fulfilled with the result of the model loading
  44235. */
  44236. loadModel(): Promise<boolean>;
  44237. /**
  44238. * Update this model using the current XRFrame
  44239. * @param xrFrame the current xr frame to use and update the model
  44240. */
  44241. updateFromXRFrame(xrFrame: XRFrame): void;
  44242. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44243. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44244. /**
  44245. * Moves the axis on the controller mesh based on its current state
  44246. * @param axis the index of the axis
  44247. * @param axisValue the value of the axis which determines the meshes new position
  44248. * @hidden
  44249. */
  44250. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  44251. /**
  44252. * Update the model itself with the current frame data
  44253. * @param xrFrame the frame to use for updating the model mesh
  44254. */
  44255. protected updateModel(xrFrame: XRFrame): void;
  44256. /**
  44257. * Get the filename and path for this controller's model
  44258. * @returns a map of filename and path
  44259. */
  44260. protected abstract _getFilenameAndPath(): {
  44261. filename: string;
  44262. path: string;
  44263. };
  44264. /**
  44265. * This function is called before the mesh is loaded. It checks for loading constraints.
  44266. * For example, this function can check if the GLB loader is available
  44267. * If this function returns false, the generic controller will be loaded instead
  44268. * @returns Is the client ready to load the mesh
  44269. */
  44270. protected abstract _getModelLoadingConstraints(): boolean;
  44271. /**
  44272. * This function will be called after the model was successfully loaded and can be used
  44273. * for mesh transformations before it is available for the user
  44274. * @param meshes the loaded meshes
  44275. */
  44276. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  44277. /**
  44278. * Set the root mesh for this controller. Important for the WebXR controller class
  44279. * @param meshes the loaded meshes
  44280. */
  44281. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  44282. /**
  44283. * A function executed each frame that updates the mesh (if needed)
  44284. * @param xrFrame the current xrFrame
  44285. */
  44286. protected abstract _updateModel(xrFrame: XRFrame): void;
  44287. private _getGenericFilenameAndPath;
  44288. private _getGenericParentMesh;
  44289. }
  44290. }
  44291. declare module BABYLON {
  44292. /**
  44293. * A generic trigger-only motion controller for WebXR
  44294. */
  44295. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  44296. /**
  44297. * Static version of the profile id of this controller
  44298. */
  44299. static ProfileId: string;
  44300. profileId: string;
  44301. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  44302. protected _getFilenameAndPath(): {
  44303. filename: string;
  44304. path: string;
  44305. };
  44306. protected _getModelLoadingConstraints(): boolean;
  44307. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  44308. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44309. protected _updateModel(): void;
  44310. }
  44311. }
  44312. declare module BABYLON {
  44313. /**
  44314. * Class containing static functions to help procedurally build meshes
  44315. */
  44316. export class SphereBuilder {
  44317. /**
  44318. * Creates a sphere mesh
  44319. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44320. * * 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`)
  44321. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44322. * * 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
  44323. * * 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)
  44324. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44325. * * 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
  44326. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44327. * @param name defines the name of the mesh
  44328. * @param options defines the options used to create the mesh
  44329. * @param scene defines the hosting scene
  44330. * @returns the sphere mesh
  44331. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44332. */
  44333. static CreateSphere(name: string, options: {
  44334. segments?: number;
  44335. diameter?: number;
  44336. diameterX?: number;
  44337. diameterY?: number;
  44338. diameterZ?: number;
  44339. arc?: number;
  44340. slice?: number;
  44341. sideOrientation?: number;
  44342. frontUVs?: Vector4;
  44343. backUVs?: Vector4;
  44344. updatable?: boolean;
  44345. }, scene?: Nullable<Scene>): Mesh;
  44346. }
  44347. }
  44348. declare module BABYLON {
  44349. /**
  44350. * A profiled motion controller has its profile loaded from an online repository.
  44351. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  44352. */
  44353. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  44354. private _repositoryUrl;
  44355. private _buttonMeshMapping;
  44356. private _touchDots;
  44357. /**
  44358. * The profile ID of this controller. Will be populated when the controller initializes.
  44359. */
  44360. profileId: string;
  44361. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  44362. dispose(): void;
  44363. protected _getFilenameAndPath(): {
  44364. filename: string;
  44365. path: string;
  44366. };
  44367. protected _getModelLoadingConstraints(): boolean;
  44368. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44369. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44370. protected _updateModel(_xrFrame: XRFrame): void;
  44371. }
  44372. }
  44373. declare module BABYLON {
  44374. /**
  44375. * A construction function type to create a new controller based on an xrInput object
  44376. */
  44377. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  44378. /**
  44379. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  44380. *
  44381. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  44382. * it should be replaced with auto-loaded controllers.
  44383. *
  44384. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  44385. */
  44386. export class WebXRMotionControllerManager {
  44387. private static _AvailableControllers;
  44388. private static _Fallbacks;
  44389. private static _ProfileLoadingPromises;
  44390. private static _ProfilesList;
  44391. /**
  44392. * The base URL of the online controller repository. Can be changed at any time.
  44393. */
  44394. static BaseRepositoryUrl: string;
  44395. /**
  44396. * Which repository gets priority - local or online
  44397. */
  44398. static PrioritizeOnlineRepository: boolean;
  44399. /**
  44400. * Use the online repository, or use only locally-defined controllers
  44401. */
  44402. static UseOnlineRepository: boolean;
  44403. /**
  44404. * Clear the cache used for profile loading and reload when requested again
  44405. */
  44406. static ClearProfilesCache(): void;
  44407. /**
  44408. * Register the default fallbacks.
  44409. * This function is called automatically when this file is imported.
  44410. */
  44411. static DefaultFallbacks(): void;
  44412. /**
  44413. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  44414. * @param profileId the profile to which a fallback needs to be found
  44415. * @return an array with corresponding fallback profiles
  44416. */
  44417. static FindFallbackWithProfileId(profileId: string): string[];
  44418. /**
  44419. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  44420. * The order of search:
  44421. *
  44422. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  44423. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  44424. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  44425. * 4) return the generic trigger controller if none were found
  44426. *
  44427. * @param xrInput the xrInput to which a new controller is initialized
  44428. * @param scene the scene to which the model will be added
  44429. * @param forceProfile force a certain profile for this controller
  44430. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  44431. */
  44432. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  44433. /**
  44434. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  44435. *
  44436. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  44437. *
  44438. * @param type the profile type to register
  44439. * @param constructFunction the function to be called when loading this profile
  44440. */
  44441. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  44442. /**
  44443. * Register a fallback to a specific profile.
  44444. * @param profileId the profileId that will receive the fallbacks
  44445. * @param fallbacks A list of fallback profiles
  44446. */
  44447. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  44448. /**
  44449. * Will update the list of profiles available in the repository
  44450. * @return a promise that resolves to a map of profiles available online
  44451. */
  44452. static UpdateProfilesList(): Promise<{
  44453. [profile: string]: string;
  44454. }>;
  44455. private static _LoadProfileFromRepository;
  44456. private static _LoadProfilesFromAvailableControllers;
  44457. }
  44458. }
  44459. declare module BABYLON {
  44460. /**
  44461. * Configuration options for the WebXR controller creation
  44462. */
  44463. export interface IWebXRControllerOptions {
  44464. /**
  44465. * Should the controller mesh be animated when a user interacts with it
  44466. * The pressed buttons / thumbstick and touchpad animations will be disabled
  44467. */
  44468. disableMotionControllerAnimation?: boolean;
  44469. /**
  44470. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  44471. */
  44472. doNotLoadControllerMesh?: boolean;
  44473. /**
  44474. * Force a specific controller type for this controller.
  44475. * This can be used when creating your own profile or when testing different controllers
  44476. */
  44477. forceControllerProfile?: string;
  44478. }
  44479. /**
  44480. * Represents an XR controller
  44481. */
  44482. export class WebXRInputSource {
  44483. private _scene;
  44484. /** The underlying input source for the controller */
  44485. inputSource: XRInputSource;
  44486. private _options;
  44487. private _tmpQuaternion;
  44488. private _tmpVector;
  44489. private _uniqueId;
  44490. /**
  44491. * 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
  44492. */
  44493. grip?: AbstractMesh;
  44494. /**
  44495. * If available, this is the gamepad object related to this controller.
  44496. * Using this object it is possible to get click events and trackpad changes of the
  44497. * webxr controller that is currently being used.
  44498. */
  44499. motionController?: WebXRAbstractMotionController;
  44500. /**
  44501. * Event that fires when the controller is removed/disposed.
  44502. * The object provided as event data is this controller, after associated assets were disposed.
  44503. * uniqueId is still available.
  44504. */
  44505. onDisposeObservable: Observable<WebXRInputSource>;
  44506. /**
  44507. * Will be triggered when the mesh associated with the motion controller is done loading.
  44508. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  44509. * A shortened version of controller -> motion controller -> on mesh loaded.
  44510. */
  44511. onMeshLoadedObservable: Observable<AbstractMesh>;
  44512. /**
  44513. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  44514. */
  44515. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  44516. /**
  44517. * Pointer which can be used to select objects or attach a visible laser to
  44518. */
  44519. pointer: AbstractMesh;
  44520. /**
  44521. * Creates the controller
  44522. * @see https://doc.babylonjs.com/how_to/webxr
  44523. * @param _scene the scene which the controller should be associated to
  44524. * @param inputSource the underlying input source for the controller
  44525. * @param _options options for this controller creation
  44526. */
  44527. constructor(_scene: Scene,
  44528. /** The underlying input source for the controller */
  44529. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  44530. /**
  44531. * Get this controllers unique id
  44532. */
  44533. get uniqueId(): string;
  44534. /**
  44535. * Disposes of the object
  44536. */
  44537. dispose(): void;
  44538. /**
  44539. * Gets a world space ray coming from the pointer or grip
  44540. * @param result the resulting ray
  44541. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  44542. */
  44543. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  44544. /**
  44545. * Updates the controller pose based on the given XRFrame
  44546. * @param xrFrame xr frame to update the pose with
  44547. * @param referenceSpace reference space to use
  44548. */
  44549. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44550. }
  44551. }
  44552. declare module BABYLON {
  44553. /**
  44554. * The schema for initialization options of the XR Input class
  44555. */
  44556. export interface IWebXRInputOptions {
  44557. /**
  44558. * If set to true no model will be automatically loaded
  44559. */
  44560. doNotLoadControllerMeshes?: boolean;
  44561. /**
  44562. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  44563. * If not found, the xr input profile data will be used.
  44564. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  44565. */
  44566. forceInputProfile?: string;
  44567. /**
  44568. * Do not send a request to the controller repository to load the profile.
  44569. *
  44570. * Instead, use the controllers available in babylon itself.
  44571. */
  44572. disableOnlineControllerRepository?: boolean;
  44573. /**
  44574. * A custom URL for the controllers repository
  44575. */
  44576. customControllersRepositoryURL?: string;
  44577. /**
  44578. * Should the controller model's components not move according to the user input
  44579. */
  44580. disableControllerAnimation?: boolean;
  44581. }
  44582. /**
  44583. * XR input used to track XR inputs such as controllers/rays
  44584. */
  44585. export class WebXRInput implements IDisposable {
  44586. /**
  44587. * the xr session manager for this session
  44588. */
  44589. xrSessionManager: WebXRSessionManager;
  44590. /**
  44591. * the WebXR camera for this session. Mainly used for teleportation
  44592. */
  44593. xrCamera: WebXRCamera;
  44594. private readonly options;
  44595. /**
  44596. * XR controllers being tracked
  44597. */
  44598. controllers: Array<WebXRInputSource>;
  44599. private _frameObserver;
  44600. private _sessionEndedObserver;
  44601. private _sessionInitObserver;
  44602. /**
  44603. * Event when a controller has been connected/added
  44604. */
  44605. onControllerAddedObservable: Observable<WebXRInputSource>;
  44606. /**
  44607. * Event when a controller has been removed/disconnected
  44608. */
  44609. onControllerRemovedObservable: Observable<WebXRInputSource>;
  44610. /**
  44611. * Initializes the WebXRInput
  44612. * @param xrSessionManager the xr session manager for this session
  44613. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  44614. * @param options = initialization options for this xr input
  44615. */
  44616. constructor(
  44617. /**
  44618. * the xr session manager for this session
  44619. */
  44620. xrSessionManager: WebXRSessionManager,
  44621. /**
  44622. * the WebXR camera for this session. Mainly used for teleportation
  44623. */
  44624. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  44625. private _onInputSourcesChange;
  44626. private _addAndRemoveControllers;
  44627. /**
  44628. * Disposes of the object
  44629. */
  44630. dispose(): void;
  44631. }
  44632. }
  44633. declare module BABYLON {
  44634. /**
  44635. * This is the base class for all WebXR features.
  44636. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  44637. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  44638. */
  44639. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  44640. protected _xrSessionManager: WebXRSessionManager;
  44641. private _attached;
  44642. private _removeOnDetach;
  44643. /**
  44644. * Should auto-attach be disabled?
  44645. */
  44646. disableAutoAttach: boolean;
  44647. /**
  44648. * Construct a new (abstract) WebXR feature
  44649. * @param _xrSessionManager the xr session manager for this feature
  44650. */
  44651. constructor(_xrSessionManager: WebXRSessionManager);
  44652. /**
  44653. * Is this feature attached
  44654. */
  44655. get attached(): boolean;
  44656. /**
  44657. * attach this feature
  44658. *
  44659. * @param force should attachment be forced (even when already attached)
  44660. * @returns true if successful, false is failed or already attached
  44661. */
  44662. attach(force?: boolean): boolean;
  44663. /**
  44664. * detach this feature.
  44665. *
  44666. * @returns true if successful, false if failed or already detached
  44667. */
  44668. detach(): boolean;
  44669. /**
  44670. * Dispose this feature and all of the resources attached
  44671. */
  44672. dispose(): void;
  44673. /**
  44674. * This is used to register callbacks that will automatically be removed when detach is called.
  44675. * @param observable the observable to which the observer will be attached
  44676. * @param callback the callback to register
  44677. */
  44678. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  44679. /**
  44680. * Code in this function will be executed on each xrFrame received from the browser.
  44681. * This function will not execute after the feature is detached.
  44682. * @param _xrFrame the current frame
  44683. */
  44684. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  44685. }
  44686. }
  44687. declare module BABYLON {
  44688. /**
  44689. * Renders a layer on top of an existing scene
  44690. */
  44691. export class UtilityLayerRenderer implements IDisposable {
  44692. /** the original scene that will be rendered on top of */
  44693. originalScene: Scene;
  44694. private _pointerCaptures;
  44695. private _lastPointerEvents;
  44696. private static _DefaultUtilityLayer;
  44697. private static _DefaultKeepDepthUtilityLayer;
  44698. private _sharedGizmoLight;
  44699. private _renderCamera;
  44700. /**
  44701. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44702. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  44703. * @returns the camera that is used when rendering the utility layer
  44704. */
  44705. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  44706. /**
  44707. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44708. * @param cam the camera that should be used when rendering the utility layer
  44709. */
  44710. setRenderCamera(cam: Nullable<Camera>): void;
  44711. /**
  44712. * @hidden
  44713. * Light which used by gizmos to get light shading
  44714. */
  44715. _getSharedGizmoLight(): HemisphericLight;
  44716. /**
  44717. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44718. */
  44719. pickUtilitySceneFirst: boolean;
  44720. /**
  44721. * 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)
  44722. */
  44723. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44724. /**
  44725. * 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)
  44726. */
  44727. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44728. /**
  44729. * The scene that is rendered on top of the original scene
  44730. */
  44731. utilityLayerScene: Scene;
  44732. /**
  44733. * If the utility layer should automatically be rendered on top of existing scene
  44734. */
  44735. shouldRender: boolean;
  44736. /**
  44737. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44738. */
  44739. onlyCheckPointerDownEvents: boolean;
  44740. /**
  44741. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44742. */
  44743. processAllEvents: boolean;
  44744. /**
  44745. * Observable raised when the pointer move from the utility layer scene to the main scene
  44746. */
  44747. onPointerOutObservable: Observable<number>;
  44748. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44749. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44750. private _afterRenderObserver;
  44751. private _sceneDisposeObserver;
  44752. private _originalPointerObserver;
  44753. /**
  44754. * Instantiates a UtilityLayerRenderer
  44755. * @param originalScene the original scene that will be rendered on top of
  44756. * @param handleEvents boolean indicating if the utility layer should handle events
  44757. */
  44758. constructor(
  44759. /** the original scene that will be rendered on top of */
  44760. originalScene: Scene, handleEvents?: boolean);
  44761. private _notifyObservers;
  44762. /**
  44763. * Renders the utility layers scene on top of the original scene
  44764. */
  44765. render(): void;
  44766. /**
  44767. * Disposes of the renderer
  44768. */
  44769. dispose(): void;
  44770. private _updateCamera;
  44771. }
  44772. }
  44773. declare module BABYLON {
  44774. /**
  44775. * Options interface for the pointer selection module
  44776. */
  44777. export interface IWebXRControllerPointerSelectionOptions {
  44778. /**
  44779. * if provided, this scene will be used to render meshes.
  44780. */
  44781. customUtilityLayerScene?: Scene;
  44782. /**
  44783. * 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)
  44784. * If not disabled, the last picked point will be used to execute a pointer up event
  44785. * If disabled, pointer up event will be triggered right after the pointer down event.
  44786. * Used in screen and gaze target ray mode only
  44787. */
  44788. disablePointerUpOnTouchOut: boolean;
  44789. /**
  44790. * For gaze mode (time to select instead of press)
  44791. */
  44792. forceGazeMode: boolean;
  44793. /**
  44794. * 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
  44795. * to start a new countdown to the pointer down event.
  44796. * Defaults to 1.
  44797. */
  44798. gazeModePointerMovedFactor?: number;
  44799. /**
  44800. * Different button type to use instead of the main component
  44801. */
  44802. overrideButtonId?: string;
  44803. /**
  44804. * use this rendering group id for the meshes (optional)
  44805. */
  44806. renderingGroupId?: number;
  44807. /**
  44808. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  44809. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  44810. * 3000 means 3 seconds between pointing at something and selecting it
  44811. */
  44812. timeToSelect?: number;
  44813. /**
  44814. * Should meshes created here be added to a utility layer or the main scene
  44815. */
  44816. useUtilityLayer?: boolean;
  44817. /**
  44818. * the xr input to use with this pointer selection
  44819. */
  44820. xrInput: WebXRInput;
  44821. }
  44822. /**
  44823. * A module that will enable pointer selection for motion controllers of XR Input Sources
  44824. */
  44825. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  44826. private readonly _options;
  44827. private static _idCounter;
  44828. private _attachController;
  44829. private _controllers;
  44830. private _scene;
  44831. private _tmpVectorForPickCompare;
  44832. /**
  44833. * The module's name
  44834. */
  44835. static readonly Name: string;
  44836. /**
  44837. * The (Babylon) version of this module.
  44838. * This is an integer representing the implementation version.
  44839. * This number does not correspond to the WebXR specs version
  44840. */
  44841. static readonly Version: number;
  44842. /**
  44843. * Disable lighting on the laser pointer (so it will always be visible)
  44844. */
  44845. disablePointerLighting: boolean;
  44846. /**
  44847. * Disable lighting on the selection mesh (so it will always be visible)
  44848. */
  44849. disableSelectionMeshLighting: boolean;
  44850. /**
  44851. * Should the laser pointer be displayed
  44852. */
  44853. displayLaserPointer: boolean;
  44854. /**
  44855. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  44856. */
  44857. displaySelectionMesh: boolean;
  44858. /**
  44859. * This color will be set to the laser pointer when selection is triggered
  44860. */
  44861. laserPointerPickedColor: Color3;
  44862. /**
  44863. * Default color of the laser pointer
  44864. */
  44865. lasterPointerDefaultColor: Color3;
  44866. /**
  44867. * default color of the selection ring
  44868. */
  44869. selectionMeshDefaultColor: Color3;
  44870. /**
  44871. * This color will be applied to the selection ring when selection is triggered
  44872. */
  44873. selectionMeshPickedColor: Color3;
  44874. /**
  44875. * Optional filter to be used for ray selection. This predicate shares behavior with
  44876. * scene.pointerMovePredicate which takes priority if it is also assigned.
  44877. */
  44878. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  44879. /**
  44880. * constructs a new background remover module
  44881. * @param _xrSessionManager the session manager for this module
  44882. * @param _options read-only options to be used in this module
  44883. */
  44884. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  44885. /**
  44886. * attach this feature
  44887. * Will usually be called by the features manager
  44888. *
  44889. * @returns true if successful.
  44890. */
  44891. attach(): boolean;
  44892. /**
  44893. * detach this feature.
  44894. * Will usually be called by the features manager
  44895. *
  44896. * @returns true if successful.
  44897. */
  44898. detach(): boolean;
  44899. /**
  44900. * Will get the mesh under a specific pointer.
  44901. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  44902. * @param controllerId the controllerId to check
  44903. * @returns The mesh under pointer or null if no mesh is under the pointer
  44904. */
  44905. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  44906. /**
  44907. * Get the xr controller that correlates to the pointer id in the pointer event
  44908. *
  44909. * @param id the pointer id to search for
  44910. * @returns the controller that correlates to this id or null if not found
  44911. */
  44912. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  44913. protected _onXRFrame(_xrFrame: XRFrame): void;
  44914. private _attachGazeMode;
  44915. private _attachScreenRayMode;
  44916. private _attachTrackedPointerRayMode;
  44917. private _convertNormalToDirectionOfRay;
  44918. private _detachController;
  44919. private _generateNewMeshPair;
  44920. private _pickingMoved;
  44921. private _updatePointerDistance;
  44922. }
  44923. }
  44924. declare module BABYLON {
  44925. /**
  44926. * Button which can be used to enter a different mode of XR
  44927. */
  44928. export class WebXREnterExitUIButton {
  44929. /** button element */
  44930. element: HTMLElement;
  44931. /** XR initialization options for the button */
  44932. sessionMode: XRSessionMode;
  44933. /** Reference space type */
  44934. referenceSpaceType: XRReferenceSpaceType;
  44935. /**
  44936. * Creates a WebXREnterExitUIButton
  44937. * @param element button element
  44938. * @param sessionMode XR initialization session mode
  44939. * @param referenceSpaceType the type of reference space to be used
  44940. */
  44941. constructor(
  44942. /** button element */
  44943. element: HTMLElement,
  44944. /** XR initialization options for the button */
  44945. sessionMode: XRSessionMode,
  44946. /** Reference space type */
  44947. referenceSpaceType: XRReferenceSpaceType);
  44948. /**
  44949. * Extendable function which can be used to update the button's visuals when the state changes
  44950. * @param activeButton the current active button in the UI
  44951. */
  44952. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  44953. }
  44954. /**
  44955. * Options to create the webXR UI
  44956. */
  44957. export class WebXREnterExitUIOptions {
  44958. /**
  44959. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  44960. */
  44961. customButtons?: Array<WebXREnterExitUIButton>;
  44962. /**
  44963. * A reference space type to use when creating the default button.
  44964. * Default is local-floor
  44965. */
  44966. referenceSpaceType?: XRReferenceSpaceType;
  44967. /**
  44968. * Context to enter xr with
  44969. */
  44970. renderTarget?: Nullable<WebXRRenderTarget>;
  44971. /**
  44972. * A session mode to use when creating the default button.
  44973. * Default is immersive-vr
  44974. */
  44975. sessionMode?: XRSessionMode;
  44976. }
  44977. /**
  44978. * UI to allow the user to enter/exit XR mode
  44979. */
  44980. export class WebXREnterExitUI implements IDisposable {
  44981. private scene;
  44982. /** version of the options passed to this UI */
  44983. options: WebXREnterExitUIOptions;
  44984. private _activeButton;
  44985. private _buttons;
  44986. private _overlay;
  44987. /**
  44988. * Fired every time the active button is changed.
  44989. *
  44990. * When xr is entered via a button that launches xr that button will be the callback parameter
  44991. *
  44992. * When exiting xr the callback parameter will be null)
  44993. */
  44994. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  44995. /**
  44996. *
  44997. * @param scene babylon scene object to use
  44998. * @param options (read-only) version of the options passed to this UI
  44999. */
  45000. private constructor();
  45001. /**
  45002. * Creates UI to allow the user to enter/exit XR mode
  45003. * @param scene the scene to add the ui to
  45004. * @param helper the xr experience helper to enter/exit xr with
  45005. * @param options options to configure the UI
  45006. * @returns the created ui
  45007. */
  45008. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  45009. /**
  45010. * Disposes of the XR UI component
  45011. */
  45012. dispose(): void;
  45013. private _updateButtons;
  45014. }
  45015. }
  45016. declare module BABYLON {
  45017. /**
  45018. * Class containing static functions to help procedurally build meshes
  45019. */
  45020. export class LinesBuilder {
  45021. /**
  45022. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45023. * * 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
  45024. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45025. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45026. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45027. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45028. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45029. * * 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
  45030. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45031. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45032. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45033. * @param name defines the name of the new line system
  45034. * @param options defines the options used to create the line system
  45035. * @param scene defines the hosting scene
  45036. * @returns a new line system mesh
  45037. */
  45038. static CreateLineSystem(name: string, options: {
  45039. lines: Vector3[][];
  45040. updatable?: boolean;
  45041. instance?: Nullable<LinesMesh>;
  45042. colors?: Nullable<Color4[][]>;
  45043. useVertexAlpha?: boolean;
  45044. }, scene: Nullable<Scene>): LinesMesh;
  45045. /**
  45046. * Creates a line mesh
  45047. * 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
  45048. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45049. * * The parameter `points` is an array successive Vector3
  45050. * * 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
  45051. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45052. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45053. * * When updating an instance, remember that only point positions can change, not the number of points
  45054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45055. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45056. * @param name defines the name of the new line system
  45057. * @param options defines the options used to create the line system
  45058. * @param scene defines the hosting scene
  45059. * @returns a new line mesh
  45060. */
  45061. static CreateLines(name: string, options: {
  45062. points: Vector3[];
  45063. updatable?: boolean;
  45064. instance?: Nullable<LinesMesh>;
  45065. colors?: Color4[];
  45066. useVertexAlpha?: boolean;
  45067. }, scene?: Nullable<Scene>): LinesMesh;
  45068. /**
  45069. * Creates a dashed line mesh
  45070. * * 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
  45071. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45072. * * The parameter `points` is an array successive Vector3
  45073. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45074. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45075. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45076. * * 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
  45077. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45078. * * When updating an instance, remember that only point positions can change, not the number of points
  45079. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45080. * @param name defines the name of the mesh
  45081. * @param options defines the options used to create the mesh
  45082. * @param scene defines the hosting scene
  45083. * @returns the dashed line mesh
  45084. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45085. */
  45086. static CreateDashedLines(name: string, options: {
  45087. points: Vector3[];
  45088. dashSize?: number;
  45089. gapSize?: number;
  45090. dashNb?: number;
  45091. updatable?: boolean;
  45092. instance?: LinesMesh;
  45093. useVertexAlpha?: boolean;
  45094. }, scene?: Nullable<Scene>): LinesMesh;
  45095. }
  45096. }
  45097. declare module BABYLON {
  45098. /**
  45099. * The options container for the teleportation module
  45100. */
  45101. export interface IWebXRTeleportationOptions {
  45102. /**
  45103. * if provided, this scene will be used to render meshes.
  45104. */
  45105. customUtilityLayerScene?: Scene;
  45106. /**
  45107. * Values to configure the default target mesh
  45108. */
  45109. defaultTargetMeshOptions?: {
  45110. /**
  45111. * Fill color of the teleportation area
  45112. */
  45113. teleportationFillColor?: string;
  45114. /**
  45115. * Border color for the teleportation area
  45116. */
  45117. teleportationBorderColor?: string;
  45118. /**
  45119. * Disable the mesh's animation sequence
  45120. */
  45121. disableAnimation?: boolean;
  45122. /**
  45123. * Disable lighting on the material or the ring and arrow
  45124. */
  45125. disableLighting?: boolean;
  45126. /**
  45127. * Override the default material of the torus and arrow
  45128. */
  45129. torusArrowMaterial?: Material;
  45130. };
  45131. /**
  45132. * A list of meshes to use as floor meshes.
  45133. * Meshes can be added and removed after initializing the feature using the
  45134. * addFloorMesh and removeFloorMesh functions
  45135. * If empty, rotation will still work
  45136. */
  45137. floorMeshes?: AbstractMesh[];
  45138. /**
  45139. * use this rendering group id for the meshes (optional)
  45140. */
  45141. renderingGroupId?: number;
  45142. /**
  45143. * Should teleportation move only to snap points
  45144. */
  45145. snapPointsOnly?: boolean;
  45146. /**
  45147. * An array of points to which the teleportation will snap to.
  45148. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  45149. */
  45150. snapPositions?: Vector3[];
  45151. /**
  45152. * How close should the teleportation ray be in order to snap to position.
  45153. * Default to 0.8 units (meters)
  45154. */
  45155. snapToPositionRadius?: number;
  45156. /**
  45157. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  45158. * If you want to support rotation, make sure your mesh has a direction indicator.
  45159. *
  45160. * When left untouched, the default mesh will be initialized.
  45161. */
  45162. teleportationTargetMesh?: AbstractMesh;
  45163. /**
  45164. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  45165. */
  45166. timeToTeleport?: number;
  45167. /**
  45168. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  45169. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  45170. */
  45171. useMainComponentOnly?: boolean;
  45172. /**
  45173. * Should meshes created here be added to a utility layer or the main scene
  45174. */
  45175. useUtilityLayer?: boolean;
  45176. /**
  45177. * Babylon XR Input class for controller
  45178. */
  45179. xrInput: WebXRInput;
  45180. }
  45181. /**
  45182. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  45183. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  45184. * the input of the attached controllers.
  45185. */
  45186. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  45187. private _options;
  45188. private _controllers;
  45189. private _currentTeleportationControllerId;
  45190. private _floorMeshes;
  45191. private _quadraticBezierCurve;
  45192. private _selectionFeature;
  45193. private _snapToPositions;
  45194. private _snappedToPoint;
  45195. private _teleportationRingMaterial?;
  45196. private _tmpRay;
  45197. private _tmpVector;
  45198. /**
  45199. * The module's name
  45200. */
  45201. static readonly Name: string;
  45202. /**
  45203. * The (Babylon) version of this module.
  45204. * This is an integer representing the implementation version.
  45205. * This number does not correspond to the webxr specs version
  45206. */
  45207. static readonly Version: number;
  45208. /**
  45209. * Is movement backwards enabled
  45210. */
  45211. backwardsMovementEnabled: boolean;
  45212. /**
  45213. * Distance to travel when moving backwards
  45214. */
  45215. backwardsTeleportationDistance: number;
  45216. /**
  45217. * The distance from the user to the inspection point in the direction of the controller
  45218. * A higher number will allow the user to move further
  45219. * defaults to 5 (meters, in xr units)
  45220. */
  45221. parabolicCheckRadius: number;
  45222. /**
  45223. * Should the module support parabolic ray on top of direct ray
  45224. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  45225. * Very helpful when moving between floors / different heights
  45226. */
  45227. parabolicRayEnabled: boolean;
  45228. /**
  45229. * How much rotation should be applied when rotating right and left
  45230. */
  45231. rotationAngle: number;
  45232. /**
  45233. * Is rotation enabled when moving forward?
  45234. * Disabling this feature will prevent the user from deciding the direction when teleporting
  45235. */
  45236. rotationEnabled: boolean;
  45237. /**
  45238. * constructs a new anchor system
  45239. * @param _xrSessionManager an instance of WebXRSessionManager
  45240. * @param _options configuration object for this feature
  45241. */
  45242. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  45243. /**
  45244. * Get the snapPointsOnly flag
  45245. */
  45246. get snapPointsOnly(): boolean;
  45247. /**
  45248. * Sets the snapPointsOnly flag
  45249. * @param snapToPoints should teleportation be exclusively to snap points
  45250. */
  45251. set snapPointsOnly(snapToPoints: boolean);
  45252. /**
  45253. * Add a new mesh to the floor meshes array
  45254. * @param mesh the mesh to use as floor mesh
  45255. */
  45256. addFloorMesh(mesh: AbstractMesh): void;
  45257. /**
  45258. * Add a new snap-to point to fix teleportation to this position
  45259. * @param newSnapPoint The new Snap-To point
  45260. */
  45261. addSnapPoint(newSnapPoint: Vector3): void;
  45262. attach(): boolean;
  45263. detach(): boolean;
  45264. dispose(): void;
  45265. /**
  45266. * Remove a mesh from the floor meshes array
  45267. * @param mesh the mesh to remove
  45268. */
  45269. removeFloorMesh(mesh: AbstractMesh): void;
  45270. /**
  45271. * Remove a mesh from the floor meshes array using its name
  45272. * @param name the mesh name to remove
  45273. */
  45274. removeFloorMeshByName(name: string): void;
  45275. /**
  45276. * 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
  45277. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  45278. * @returns was the point found and removed or not
  45279. */
  45280. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  45281. /**
  45282. * This function sets a selection feature that will be disabled when
  45283. * the forward ray is shown and will be reattached when hidden.
  45284. * This is used to remove the selection rays when moving.
  45285. * @param selectionFeature the feature to disable when forward movement is enabled
  45286. */
  45287. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  45288. protected _onXRFrame(_xrFrame: XRFrame): void;
  45289. private _attachController;
  45290. private _createDefaultTargetMesh;
  45291. private _detachController;
  45292. private _findClosestSnapPointWithRadius;
  45293. private _setTargetMeshPosition;
  45294. private _setTargetMeshVisibility;
  45295. private _showParabolicPath;
  45296. private _teleportForward;
  45297. }
  45298. }
  45299. declare module BABYLON {
  45300. /**
  45301. * Options for the default xr helper
  45302. */
  45303. export class WebXRDefaultExperienceOptions {
  45304. /**
  45305. * Enable or disable default UI to enter XR
  45306. */
  45307. disableDefaultUI?: boolean;
  45308. /**
  45309. * Should teleportation not initialize. defaults to false.
  45310. */
  45311. disableTeleportation?: boolean;
  45312. /**
  45313. * Floor meshes that will be used for teleport
  45314. */
  45315. floorMeshes?: Array<AbstractMesh>;
  45316. /**
  45317. * If set to true, the first frame will not be used to reset position
  45318. * The first frame is mainly used when copying transformation from the old camera
  45319. * Mainly used in AR
  45320. */
  45321. ignoreNativeCameraTransformation?: boolean;
  45322. /**
  45323. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  45324. */
  45325. inputOptions?: IWebXRInputOptions;
  45326. /**
  45327. * optional configuration for the output canvas
  45328. */
  45329. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45330. /**
  45331. * optional UI options. This can be used among other to change session mode and reference space type
  45332. */
  45333. uiOptions?: WebXREnterExitUIOptions;
  45334. /**
  45335. * When loading teleportation and pointer select, use stable versions instead of latest.
  45336. */
  45337. useStablePlugins?: boolean;
  45338. }
  45339. /**
  45340. * Default experience which provides a similar setup to the previous webVRExperience
  45341. */
  45342. export class WebXRDefaultExperience {
  45343. /**
  45344. * Base experience
  45345. */
  45346. baseExperience: WebXRExperienceHelper;
  45347. /**
  45348. * Enables ui for entering/exiting xr
  45349. */
  45350. enterExitUI: WebXREnterExitUI;
  45351. /**
  45352. * Input experience extension
  45353. */
  45354. input: WebXRInput;
  45355. /**
  45356. * Enables laser pointer and selection
  45357. */
  45358. pointerSelection: WebXRControllerPointerSelection;
  45359. /**
  45360. * Default target xr should render to
  45361. */
  45362. renderTarget: WebXRRenderTarget;
  45363. /**
  45364. * Enables teleportation
  45365. */
  45366. teleportation: WebXRMotionControllerTeleportation;
  45367. private constructor();
  45368. /**
  45369. * Creates the default xr experience
  45370. * @param scene scene
  45371. * @param options options for basic configuration
  45372. * @returns resulting WebXRDefaultExperience
  45373. */
  45374. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45375. /**
  45376. * DIsposes of the experience helper
  45377. */
  45378. dispose(): void;
  45379. }
  45380. }
  45381. declare module BABYLON {
  45382. /**
  45383. * Options to modify the vr teleportation behavior.
  45384. */
  45385. export interface VRTeleportationOptions {
  45386. /**
  45387. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45388. */
  45389. floorMeshName?: string;
  45390. /**
  45391. * A list of meshes to be used as the teleportation floor. (default: empty)
  45392. */
  45393. floorMeshes?: Mesh[];
  45394. /**
  45395. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45396. */
  45397. teleportationMode?: number;
  45398. /**
  45399. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45400. */
  45401. teleportationTime?: number;
  45402. /**
  45403. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45404. */
  45405. teleportationSpeed?: number;
  45406. /**
  45407. * The easing function used in the animation or null for Linear. (default CircleEase)
  45408. */
  45409. easingFunction?: EasingFunction;
  45410. }
  45411. /**
  45412. * Options to modify the vr experience helper's behavior.
  45413. */
  45414. export interface VRExperienceHelperOptions extends WebVROptions {
  45415. /**
  45416. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45417. */
  45418. createDeviceOrientationCamera?: boolean;
  45419. /**
  45420. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45421. */
  45422. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45423. /**
  45424. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45425. */
  45426. laserToggle?: boolean;
  45427. /**
  45428. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45429. */
  45430. floorMeshes?: Mesh[];
  45431. /**
  45432. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45433. */
  45434. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45435. /**
  45436. * Defines if WebXR should be used instead of WebVR (if available)
  45437. */
  45438. useXR?: boolean;
  45439. }
  45440. /**
  45441. * Event containing information after VR has been entered
  45442. */
  45443. export class OnAfterEnteringVRObservableEvent {
  45444. /**
  45445. * If entering vr was successful
  45446. */
  45447. success: boolean;
  45448. }
  45449. /**
  45450. * Helps to quickly add VR support to an existing scene.
  45451. * See http://doc.babylonjs.com/how_to/webvr_helper
  45452. */
  45453. export class VRExperienceHelper {
  45454. /** Options to modify the vr experience helper's behavior. */
  45455. webVROptions: VRExperienceHelperOptions;
  45456. private _scene;
  45457. private _position;
  45458. private _btnVR;
  45459. private _btnVRDisplayed;
  45460. private _webVRsupported;
  45461. private _webVRready;
  45462. private _webVRrequesting;
  45463. private _webVRpresenting;
  45464. private _hasEnteredVR;
  45465. private _fullscreenVRpresenting;
  45466. private _inputElement;
  45467. private _webVRCamera;
  45468. private _vrDeviceOrientationCamera;
  45469. private _deviceOrientationCamera;
  45470. private _existingCamera;
  45471. private _onKeyDown;
  45472. private _onVrDisplayPresentChange;
  45473. private _onVRDisplayChanged;
  45474. private _onVRRequestPresentStart;
  45475. private _onVRRequestPresentComplete;
  45476. /**
  45477. * 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)
  45478. */
  45479. enableGazeEvenWhenNoPointerLock: boolean;
  45480. /**
  45481. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45482. */
  45483. exitVROnDoubleTap: boolean;
  45484. /**
  45485. * Observable raised right before entering VR.
  45486. */
  45487. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45488. /**
  45489. * Observable raised when entering VR has completed.
  45490. */
  45491. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45492. /**
  45493. * Observable raised when exiting VR.
  45494. */
  45495. onExitingVRObservable: Observable<VRExperienceHelper>;
  45496. /**
  45497. * Observable raised when controller mesh is loaded.
  45498. */
  45499. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45500. /** Return this.onEnteringVRObservable
  45501. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45502. */
  45503. get onEnteringVR(): Observable<VRExperienceHelper>;
  45504. /** Return this.onExitingVRObservable
  45505. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45506. */
  45507. get onExitingVR(): Observable<VRExperienceHelper>;
  45508. /** Return this.onControllerMeshLoadedObservable
  45509. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45510. */
  45511. get onControllerMeshLoaded(): Observable<WebVRController>;
  45512. private _rayLength;
  45513. private _useCustomVRButton;
  45514. private _teleportationRequested;
  45515. private _teleportActive;
  45516. private _floorMeshName;
  45517. private _floorMeshesCollection;
  45518. private _teleportationMode;
  45519. private _teleportationTime;
  45520. private _teleportationSpeed;
  45521. private _teleportationEasing;
  45522. private _rotationAllowed;
  45523. private _teleportBackwardsVector;
  45524. private _teleportationTarget;
  45525. private _isDefaultTeleportationTarget;
  45526. private _postProcessMove;
  45527. private _teleportationFillColor;
  45528. private _teleportationBorderColor;
  45529. private _rotationAngle;
  45530. private _haloCenter;
  45531. private _cameraGazer;
  45532. private _padSensibilityUp;
  45533. private _padSensibilityDown;
  45534. private _leftController;
  45535. private _rightController;
  45536. private _gazeColor;
  45537. private _laserColor;
  45538. private _pickedLaserColor;
  45539. private _pickedGazeColor;
  45540. /**
  45541. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45542. */
  45543. onNewMeshSelected: Observable<AbstractMesh>;
  45544. /**
  45545. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45546. * This observable will provide the mesh and the controller used to select the mesh
  45547. */
  45548. onMeshSelectedWithController: Observable<{
  45549. mesh: AbstractMesh;
  45550. controller: WebVRController;
  45551. }>;
  45552. /**
  45553. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45554. */
  45555. onNewMeshPicked: Observable<PickingInfo>;
  45556. private _circleEase;
  45557. /**
  45558. * Observable raised before camera teleportation
  45559. */
  45560. onBeforeCameraTeleport: Observable<Vector3>;
  45561. /**
  45562. * Observable raised after camera teleportation
  45563. */
  45564. onAfterCameraTeleport: Observable<Vector3>;
  45565. /**
  45566. * Observable raised when current selected mesh gets unselected
  45567. */
  45568. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45569. private _raySelectionPredicate;
  45570. /**
  45571. * To be optionaly changed by user to define custom ray selection
  45572. */
  45573. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45574. /**
  45575. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45576. */
  45577. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45578. /**
  45579. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45580. */
  45581. teleportationEnabled: boolean;
  45582. private _defaultHeight;
  45583. private _teleportationInitialized;
  45584. private _interactionsEnabled;
  45585. private _interactionsRequested;
  45586. private _displayGaze;
  45587. private _displayLaserPointer;
  45588. /**
  45589. * The mesh used to display where the user is going to teleport.
  45590. */
  45591. get teleportationTarget(): Mesh;
  45592. /**
  45593. * Sets the mesh to be used to display where the user is going to teleport.
  45594. */
  45595. set teleportationTarget(value: Mesh);
  45596. /**
  45597. * 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
  45598. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45599. * See http://doc.babylonjs.com/resources/baking_transformations
  45600. */
  45601. get gazeTrackerMesh(): Mesh;
  45602. set gazeTrackerMesh(value: Mesh);
  45603. /**
  45604. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45605. */
  45606. updateGazeTrackerScale: boolean;
  45607. /**
  45608. * If the gaze trackers color should be updated when selecting meshes
  45609. */
  45610. updateGazeTrackerColor: boolean;
  45611. /**
  45612. * If the controller laser color should be updated when selecting meshes
  45613. */
  45614. updateControllerLaserColor: boolean;
  45615. /**
  45616. * The gaze tracking mesh corresponding to the left controller
  45617. */
  45618. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45619. /**
  45620. * The gaze tracking mesh corresponding to the right controller
  45621. */
  45622. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45623. /**
  45624. * If the ray of the gaze should be displayed.
  45625. */
  45626. get displayGaze(): boolean;
  45627. /**
  45628. * Sets if the ray of the gaze should be displayed.
  45629. */
  45630. set displayGaze(value: boolean);
  45631. /**
  45632. * If the ray of the LaserPointer should be displayed.
  45633. */
  45634. get displayLaserPointer(): boolean;
  45635. /**
  45636. * Sets if the ray of the LaserPointer should be displayed.
  45637. */
  45638. set displayLaserPointer(value: boolean);
  45639. /**
  45640. * The deviceOrientationCamera used as the camera when not in VR.
  45641. */
  45642. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45643. /**
  45644. * Based on the current WebVR support, returns the current VR camera used.
  45645. */
  45646. get currentVRCamera(): Nullable<Camera>;
  45647. /**
  45648. * The webVRCamera which is used when in VR.
  45649. */
  45650. get webVRCamera(): WebVRFreeCamera;
  45651. /**
  45652. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45653. */
  45654. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45655. /**
  45656. * The html button that is used to trigger entering into VR.
  45657. */
  45658. get vrButton(): Nullable<HTMLButtonElement>;
  45659. private get _teleportationRequestInitiated();
  45660. /**
  45661. * Defines whether or not Pointer lock should be requested when switching to
  45662. * full screen.
  45663. */
  45664. requestPointerLockOnFullScreen: boolean;
  45665. /**
  45666. * If asking to force XR, this will be populated with the default xr experience
  45667. */
  45668. xr: WebXRDefaultExperience;
  45669. /**
  45670. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45671. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45672. */
  45673. xrTestDone: boolean;
  45674. /**
  45675. * Instantiates a VRExperienceHelper.
  45676. * Helps to quickly add VR support to an existing scene.
  45677. * @param scene The scene the VRExperienceHelper belongs to.
  45678. * @param webVROptions Options to modify the vr experience helper's behavior.
  45679. */
  45680. constructor(scene: Scene,
  45681. /** Options to modify the vr experience helper's behavior. */
  45682. webVROptions?: VRExperienceHelperOptions);
  45683. private completeVRInit;
  45684. private _onDefaultMeshLoaded;
  45685. private _onResize;
  45686. private _onFullscreenChange;
  45687. /**
  45688. * Gets a value indicating if we are currently in VR mode.
  45689. */
  45690. get isInVRMode(): boolean;
  45691. private onVrDisplayPresentChange;
  45692. private onVRDisplayChanged;
  45693. private moveButtonToBottomRight;
  45694. private displayVRButton;
  45695. private updateButtonVisibility;
  45696. private _cachedAngularSensibility;
  45697. /**
  45698. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45699. * Otherwise, will use the fullscreen API.
  45700. */
  45701. enterVR(): void;
  45702. /**
  45703. * Attempt to exit VR, or fullscreen.
  45704. */
  45705. exitVR(): void;
  45706. /**
  45707. * The position of the vr experience helper.
  45708. */
  45709. get position(): Vector3;
  45710. /**
  45711. * Sets the position of the vr experience helper.
  45712. */
  45713. set position(value: Vector3);
  45714. /**
  45715. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45716. */
  45717. enableInteractions(): void;
  45718. private get _noControllerIsActive();
  45719. private beforeRender;
  45720. private _isTeleportationFloor;
  45721. /**
  45722. * Adds a floor mesh to be used for teleportation.
  45723. * @param floorMesh the mesh to be used for teleportation.
  45724. */
  45725. addFloorMesh(floorMesh: Mesh): void;
  45726. /**
  45727. * Removes a floor mesh from being used for teleportation.
  45728. * @param floorMesh the mesh to be removed.
  45729. */
  45730. removeFloorMesh(floorMesh: Mesh): void;
  45731. /**
  45732. * Enables interactions and teleportation using the VR controllers and gaze.
  45733. * @param vrTeleportationOptions options to modify teleportation behavior.
  45734. */
  45735. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45736. private _onNewGamepadConnected;
  45737. private _tryEnableInteractionOnController;
  45738. private _onNewGamepadDisconnected;
  45739. private _enableInteractionOnController;
  45740. private _checkTeleportWithRay;
  45741. private _checkRotate;
  45742. private _checkTeleportBackwards;
  45743. private _enableTeleportationOnController;
  45744. private _createTeleportationCircles;
  45745. private _displayTeleportationTarget;
  45746. private _hideTeleportationTarget;
  45747. private _rotateCamera;
  45748. private _moveTeleportationSelectorTo;
  45749. private _workingVector;
  45750. private _workingQuaternion;
  45751. private _workingMatrix;
  45752. /**
  45753. * Time Constant Teleportation Mode
  45754. */
  45755. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45756. /**
  45757. * Speed Constant Teleportation Mode
  45758. */
  45759. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45760. /**
  45761. * Teleports the users feet to the desired location
  45762. * @param location The location where the user's feet should be placed
  45763. */
  45764. teleportCamera(location: Vector3): void;
  45765. private _convertNormalToDirectionOfRay;
  45766. private _castRayAndSelectObject;
  45767. private _notifySelectedMeshUnselected;
  45768. /**
  45769. * Permanently set new colors for the laser pointer
  45770. * @param color the new laser color
  45771. * @param pickedColor the new laser color when picked mesh detected
  45772. */
  45773. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45774. /**
  45775. * Set lighting enabled / disabled on the laser pointer of both controllers
  45776. * @param enabled should the lighting be enabled on the laser pointer
  45777. */
  45778. setLaserLightingState(enabled?: boolean): void;
  45779. /**
  45780. * Permanently set new colors for the gaze pointer
  45781. * @param color the new gaze color
  45782. * @param pickedColor the new gaze color when picked mesh detected
  45783. */
  45784. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45785. /**
  45786. * Sets the color of the laser ray from the vr controllers.
  45787. * @param color new color for the ray.
  45788. */
  45789. changeLaserColor(color: Color3): void;
  45790. /**
  45791. * Sets the color of the ray from the vr headsets gaze.
  45792. * @param color new color for the ray.
  45793. */
  45794. changeGazeColor(color: Color3): void;
  45795. /**
  45796. * Exits VR and disposes of the vr experience helper
  45797. */
  45798. dispose(): void;
  45799. /**
  45800. * Gets the name of the VRExperienceHelper class
  45801. * @returns "VRExperienceHelper"
  45802. */
  45803. getClassName(): string;
  45804. }
  45805. }
  45806. declare module BABYLON {
  45807. /**
  45808. * Contains an array of blocks representing the octree
  45809. */
  45810. export interface IOctreeContainer<T> {
  45811. /**
  45812. * Blocks within the octree
  45813. */
  45814. blocks: Array<OctreeBlock<T>>;
  45815. }
  45816. /**
  45817. * Class used to store a cell in an octree
  45818. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45819. */
  45820. export class OctreeBlock<T> {
  45821. /**
  45822. * Gets the content of the current block
  45823. */
  45824. entries: T[];
  45825. /**
  45826. * Gets the list of block children
  45827. */
  45828. blocks: Array<OctreeBlock<T>>;
  45829. private _depth;
  45830. private _maxDepth;
  45831. private _capacity;
  45832. private _minPoint;
  45833. private _maxPoint;
  45834. private _boundingVectors;
  45835. private _creationFunc;
  45836. /**
  45837. * Creates a new block
  45838. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45839. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45840. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45841. * @param depth defines the current depth of this block in the octree
  45842. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45843. * @param creationFunc defines a callback to call when an element is added to the block
  45844. */
  45845. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  45846. /**
  45847. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45848. */
  45849. get capacity(): number;
  45850. /**
  45851. * Gets the minimum vector (in world space) of the block's bounding box
  45852. */
  45853. get minPoint(): Vector3;
  45854. /**
  45855. * Gets the maximum vector (in world space) of the block's bounding box
  45856. */
  45857. get maxPoint(): Vector3;
  45858. /**
  45859. * Add a new element to this block
  45860. * @param entry defines the element to add
  45861. */
  45862. addEntry(entry: T): void;
  45863. /**
  45864. * Remove an element from this block
  45865. * @param entry defines the element to remove
  45866. */
  45867. removeEntry(entry: T): void;
  45868. /**
  45869. * Add an array of elements to this block
  45870. * @param entries defines the array of elements to add
  45871. */
  45872. addEntries(entries: T[]): void;
  45873. /**
  45874. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  45875. * @param frustumPlanes defines the frustum planes to test
  45876. * @param selection defines the array to store current content if selection is positive
  45877. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45878. */
  45879. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45880. /**
  45881. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  45882. * @param sphereCenter defines the bounding sphere center
  45883. * @param sphereRadius defines the bounding sphere radius
  45884. * @param selection defines the array to store current content if selection is positive
  45885. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45886. */
  45887. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45888. /**
  45889. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  45890. * @param ray defines the ray to test with
  45891. * @param selection defines the array to store current content if selection is positive
  45892. */
  45893. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  45894. /**
  45895. * Subdivide the content into child blocks (this block will then be empty)
  45896. */
  45897. createInnerBlocks(): void;
  45898. /**
  45899. * @hidden
  45900. */
  45901. 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;
  45902. }
  45903. }
  45904. declare module BABYLON {
  45905. /**
  45906. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  45907. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45908. */
  45909. export class Octree<T> {
  45910. /** 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.) */
  45911. maxDepth: number;
  45912. /**
  45913. * Blocks within the octree containing objects
  45914. */
  45915. blocks: Array<OctreeBlock<T>>;
  45916. /**
  45917. * Content stored in the octree
  45918. */
  45919. dynamicContent: T[];
  45920. private _maxBlockCapacity;
  45921. private _selectionContent;
  45922. private _creationFunc;
  45923. /**
  45924. * Creates a octree
  45925. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45926. * @param creationFunc function to be used to instatiate the octree
  45927. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  45928. * @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.)
  45929. */
  45930. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  45931. /** 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.) */
  45932. maxDepth?: number);
  45933. /**
  45934. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  45935. * @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);
  45936. * @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);
  45937. * @param entries meshes to be added to the octree blocks
  45938. */
  45939. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  45940. /**
  45941. * Adds a mesh to the octree
  45942. * @param entry Mesh to add to the octree
  45943. */
  45944. addMesh(entry: T): void;
  45945. /**
  45946. * Remove an element from the octree
  45947. * @param entry defines the element to remove
  45948. */
  45949. removeMesh(entry: T): void;
  45950. /**
  45951. * Selects an array of meshes within the frustum
  45952. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  45953. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  45954. * @returns array of meshes within the frustum
  45955. */
  45956. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  45957. /**
  45958. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  45959. * @param sphereCenter defines the bounding sphere center
  45960. * @param sphereRadius defines the bounding sphere radius
  45961. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45962. * @returns an array of objects that intersect the sphere
  45963. */
  45964. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  45965. /**
  45966. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  45967. * @param ray defines the ray to test with
  45968. * @returns array of intersected objects
  45969. */
  45970. intersectsRay(ray: Ray): SmartArray<T>;
  45971. /**
  45972. * Adds a mesh into the octree block if it intersects the block
  45973. */
  45974. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  45975. /**
  45976. * Adds a submesh into the octree block if it intersects the block
  45977. */
  45978. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  45979. }
  45980. }
  45981. declare module BABYLON {
  45982. interface Scene {
  45983. /**
  45984. * @hidden
  45985. * Backing Filed
  45986. */
  45987. _selectionOctree: Octree<AbstractMesh>;
  45988. /**
  45989. * Gets the octree used to boost mesh selection (picking)
  45990. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45991. */
  45992. selectionOctree: Octree<AbstractMesh>;
  45993. /**
  45994. * Creates or updates the octree used to boost selection (picking)
  45995. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45996. * @param maxCapacity defines the maximum capacity per leaf
  45997. * @param maxDepth defines the maximum depth of the octree
  45998. * @returns an octree of AbstractMesh
  45999. */
  46000. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  46001. }
  46002. interface AbstractMesh {
  46003. /**
  46004. * @hidden
  46005. * Backing Field
  46006. */
  46007. _submeshesOctree: Octree<SubMesh>;
  46008. /**
  46009. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  46010. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  46011. * @param maxCapacity defines the maximum size of each block (64 by default)
  46012. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  46013. * @returns the new octree
  46014. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  46015. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46016. */
  46017. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  46018. }
  46019. /**
  46020. * Defines the octree scene component responsible to manage any octrees
  46021. * in a given scene.
  46022. */
  46023. export class OctreeSceneComponent {
  46024. /**
  46025. * The component name help to identify the component in the list of scene components.
  46026. */
  46027. readonly name: string;
  46028. /**
  46029. * The scene the component belongs to.
  46030. */
  46031. scene: Scene;
  46032. /**
  46033. * Indicates if the meshes have been checked to make sure they are isEnabled()
  46034. */
  46035. readonly checksIsEnabled: boolean;
  46036. /**
  46037. * Creates a new instance of the component for the given scene
  46038. * @param scene Defines the scene to register the component in
  46039. */
  46040. constructor(scene: Scene);
  46041. /**
  46042. * Registers the component in a given scene
  46043. */
  46044. register(): void;
  46045. /**
  46046. * Return the list of active meshes
  46047. * @returns the list of active meshes
  46048. */
  46049. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46050. /**
  46051. * Return the list of active sub meshes
  46052. * @param mesh The mesh to get the candidates sub meshes from
  46053. * @returns the list of active sub meshes
  46054. */
  46055. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46056. private _tempRay;
  46057. /**
  46058. * Return the list of sub meshes intersecting with a given local ray
  46059. * @param mesh defines the mesh to find the submesh for
  46060. * @param localRay defines the ray in local space
  46061. * @returns the list of intersecting sub meshes
  46062. */
  46063. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  46064. /**
  46065. * Return the list of sub meshes colliding with a collider
  46066. * @param mesh defines the mesh to find the submesh for
  46067. * @param collider defines the collider to evaluate the collision against
  46068. * @returns the list of colliding sub meshes
  46069. */
  46070. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  46071. /**
  46072. * Rebuilds the elements related to this component in case of
  46073. * context lost for instance.
  46074. */
  46075. rebuild(): void;
  46076. /**
  46077. * Disposes the component and the associated ressources.
  46078. */
  46079. dispose(): void;
  46080. }
  46081. }
  46082. declare module BABYLON {
  46083. /**
  46084. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  46085. */
  46086. export class Gizmo implements IDisposable {
  46087. /** The utility layer the gizmo will be added to */
  46088. gizmoLayer: UtilityLayerRenderer;
  46089. /**
  46090. * The root mesh of the gizmo
  46091. */
  46092. _rootMesh: Mesh;
  46093. private _attachedMesh;
  46094. /**
  46095. * Ratio for the scale of the gizmo (Default: 1)
  46096. */
  46097. scaleRatio: number;
  46098. /**
  46099. * If a custom mesh has been set (Default: false)
  46100. */
  46101. protected _customMeshSet: boolean;
  46102. /**
  46103. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  46104. * * When set, interactions will be enabled
  46105. */
  46106. get attachedMesh(): Nullable<AbstractMesh>;
  46107. set attachedMesh(value: Nullable<AbstractMesh>);
  46108. /**
  46109. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46110. * @param mesh The mesh to replace the default mesh of the gizmo
  46111. */
  46112. setCustomMesh(mesh: Mesh): void;
  46113. /**
  46114. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  46115. */
  46116. updateGizmoRotationToMatchAttachedMesh: boolean;
  46117. /**
  46118. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  46119. */
  46120. updateGizmoPositionToMatchAttachedMesh: boolean;
  46121. /**
  46122. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  46123. */
  46124. updateScale: boolean;
  46125. protected _interactionsEnabled: boolean;
  46126. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46127. private _beforeRenderObserver;
  46128. private _tempVector;
  46129. /**
  46130. * Creates a gizmo
  46131. * @param gizmoLayer The utility layer the gizmo will be added to
  46132. */
  46133. constructor(
  46134. /** The utility layer the gizmo will be added to */
  46135. gizmoLayer?: UtilityLayerRenderer);
  46136. /**
  46137. * Updates the gizmo to match the attached mesh's position/rotation
  46138. */
  46139. protected _update(): void;
  46140. /**
  46141. * Disposes of the gizmo
  46142. */
  46143. dispose(): void;
  46144. }
  46145. }
  46146. declare module BABYLON {
  46147. /**
  46148. * Single plane drag gizmo
  46149. */
  46150. export class PlaneDragGizmo extends Gizmo {
  46151. /**
  46152. * Drag behavior responsible for the gizmos dragging interactions
  46153. */
  46154. dragBehavior: PointerDragBehavior;
  46155. private _pointerObserver;
  46156. /**
  46157. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46158. */
  46159. snapDistance: number;
  46160. /**
  46161. * Event that fires each time the gizmo snaps to a new location.
  46162. * * snapDistance is the the change in distance
  46163. */
  46164. onSnapObservable: Observable<{
  46165. snapDistance: number;
  46166. }>;
  46167. private _plane;
  46168. private _coloredMaterial;
  46169. private _hoverMaterial;
  46170. private _isEnabled;
  46171. private _parent;
  46172. /** @hidden */
  46173. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  46174. /** @hidden */
  46175. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46176. /**
  46177. * Creates a PlaneDragGizmo
  46178. * @param gizmoLayer The utility layer the gizmo will be added to
  46179. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  46180. * @param color The color of the gizmo
  46181. */
  46182. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46183. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46184. /**
  46185. * If the gizmo is enabled
  46186. */
  46187. set isEnabled(value: boolean);
  46188. get isEnabled(): boolean;
  46189. /**
  46190. * Disposes of the gizmo
  46191. */
  46192. dispose(): void;
  46193. }
  46194. }
  46195. declare module BABYLON {
  46196. /**
  46197. * Gizmo that enables dragging a mesh along 3 axis
  46198. */
  46199. export class PositionGizmo extends Gizmo {
  46200. /**
  46201. * Internal gizmo used for interactions on the x axis
  46202. */
  46203. xGizmo: AxisDragGizmo;
  46204. /**
  46205. * Internal gizmo used for interactions on the y axis
  46206. */
  46207. yGizmo: AxisDragGizmo;
  46208. /**
  46209. * Internal gizmo used for interactions on the z axis
  46210. */
  46211. zGizmo: AxisDragGizmo;
  46212. /**
  46213. * Internal gizmo used for interactions on the yz plane
  46214. */
  46215. xPlaneGizmo: PlaneDragGizmo;
  46216. /**
  46217. * Internal gizmo used for interactions on the xz plane
  46218. */
  46219. yPlaneGizmo: PlaneDragGizmo;
  46220. /**
  46221. * Internal gizmo used for interactions on the xy plane
  46222. */
  46223. zPlaneGizmo: PlaneDragGizmo;
  46224. /**
  46225. * private variables
  46226. */
  46227. private _meshAttached;
  46228. private _updateGizmoRotationToMatchAttachedMesh;
  46229. private _snapDistance;
  46230. private _scaleRatio;
  46231. /** Fires an event when any of it's sub gizmos are dragged */
  46232. onDragStartObservable: Observable<unknown>;
  46233. /** Fires an event when any of it's sub gizmos are released from dragging */
  46234. onDragEndObservable: Observable<unknown>;
  46235. /**
  46236. * If set to true, planar drag is enabled
  46237. */
  46238. private _planarGizmoEnabled;
  46239. get attachedMesh(): Nullable<AbstractMesh>;
  46240. set attachedMesh(mesh: Nullable<AbstractMesh>);
  46241. /**
  46242. * Creates a PositionGizmo
  46243. * @param gizmoLayer The utility layer the gizmo will be added to
  46244. */
  46245. constructor(gizmoLayer?: UtilityLayerRenderer);
  46246. /**
  46247. * If the planar drag gizmo is enabled
  46248. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  46249. */
  46250. set planarGizmoEnabled(value: boolean);
  46251. get planarGizmoEnabled(): boolean;
  46252. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  46253. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  46254. /**
  46255. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46256. */
  46257. set snapDistance(value: number);
  46258. get snapDistance(): number;
  46259. /**
  46260. * Ratio for the scale of the gizmo (Default: 1)
  46261. */
  46262. set scaleRatio(value: number);
  46263. get scaleRatio(): number;
  46264. /**
  46265. * Disposes of the gizmo
  46266. */
  46267. dispose(): void;
  46268. /**
  46269. * CustomMeshes are not supported by this gizmo
  46270. * @param mesh The mesh to replace the default mesh of the gizmo
  46271. */
  46272. setCustomMesh(mesh: Mesh): void;
  46273. }
  46274. }
  46275. declare module BABYLON {
  46276. /**
  46277. * Single axis drag gizmo
  46278. */
  46279. export class AxisDragGizmo extends Gizmo {
  46280. /**
  46281. * Drag behavior responsible for the gizmos dragging interactions
  46282. */
  46283. dragBehavior: PointerDragBehavior;
  46284. private _pointerObserver;
  46285. /**
  46286. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46287. */
  46288. snapDistance: number;
  46289. /**
  46290. * Event that fires each time the gizmo snaps to a new location.
  46291. * * snapDistance is the the change in distance
  46292. */
  46293. onSnapObservable: Observable<{
  46294. snapDistance: number;
  46295. }>;
  46296. private _isEnabled;
  46297. private _parent;
  46298. private _arrow;
  46299. private _coloredMaterial;
  46300. private _hoverMaterial;
  46301. /** @hidden */
  46302. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46303. /** @hidden */
  46304. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46305. /**
  46306. * Creates an AxisDragGizmo
  46307. * @param gizmoLayer The utility layer the gizmo will be added to
  46308. * @param dragAxis The axis which the gizmo will be able to drag on
  46309. * @param color The color of the gizmo
  46310. */
  46311. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46312. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46313. /**
  46314. * If the gizmo is enabled
  46315. */
  46316. set isEnabled(value: boolean);
  46317. get isEnabled(): boolean;
  46318. /**
  46319. * Disposes of the gizmo
  46320. */
  46321. dispose(): void;
  46322. }
  46323. }
  46324. declare module BABYLON.Debug {
  46325. /**
  46326. * The Axes viewer will show 3 axes in a specific point in space
  46327. */
  46328. export class AxesViewer {
  46329. private _xAxis;
  46330. private _yAxis;
  46331. private _zAxis;
  46332. private _scaleLinesFactor;
  46333. private _instanced;
  46334. /**
  46335. * Gets the hosting scene
  46336. */
  46337. scene: Scene;
  46338. /**
  46339. * Gets or sets a number used to scale line length
  46340. */
  46341. scaleLines: number;
  46342. /** Gets the node hierarchy used to render x-axis */
  46343. get xAxis(): TransformNode;
  46344. /** Gets the node hierarchy used to render y-axis */
  46345. get yAxis(): TransformNode;
  46346. /** Gets the node hierarchy used to render z-axis */
  46347. get zAxis(): TransformNode;
  46348. /**
  46349. * Creates a new AxesViewer
  46350. * @param scene defines the hosting scene
  46351. * @param scaleLines defines a number used to scale line length (1 by default)
  46352. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46353. * @param xAxis defines the node hierarchy used to render the x-axis
  46354. * @param yAxis defines the node hierarchy used to render the y-axis
  46355. * @param zAxis defines the node hierarchy used to render the z-axis
  46356. */
  46357. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46358. /**
  46359. * Force the viewer to update
  46360. * @param position defines the position of the viewer
  46361. * @param xaxis defines the x axis of the viewer
  46362. * @param yaxis defines the y axis of the viewer
  46363. * @param zaxis defines the z axis of the viewer
  46364. */
  46365. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46366. /**
  46367. * Creates an instance of this axes viewer.
  46368. * @returns a new axes viewer with instanced meshes
  46369. */
  46370. createInstance(): AxesViewer;
  46371. /** Releases resources */
  46372. dispose(): void;
  46373. private static _SetRenderingGroupId;
  46374. }
  46375. }
  46376. declare module BABYLON.Debug {
  46377. /**
  46378. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46379. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46380. */
  46381. export class BoneAxesViewer extends AxesViewer {
  46382. /**
  46383. * Gets or sets the target mesh where to display the axes viewer
  46384. */
  46385. mesh: Nullable<Mesh>;
  46386. /**
  46387. * Gets or sets the target bone where to display the axes viewer
  46388. */
  46389. bone: Nullable<Bone>;
  46390. /** Gets current position */
  46391. pos: Vector3;
  46392. /** Gets direction of X axis */
  46393. xaxis: Vector3;
  46394. /** Gets direction of Y axis */
  46395. yaxis: Vector3;
  46396. /** Gets direction of Z axis */
  46397. zaxis: Vector3;
  46398. /**
  46399. * Creates a new BoneAxesViewer
  46400. * @param scene defines the hosting scene
  46401. * @param bone defines the target bone
  46402. * @param mesh defines the target mesh
  46403. * @param scaleLines defines a scaling factor for line length (1 by default)
  46404. */
  46405. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46406. /**
  46407. * Force the viewer to update
  46408. */
  46409. update(): void;
  46410. /** Releases resources */
  46411. dispose(): void;
  46412. }
  46413. }
  46414. declare module BABYLON {
  46415. /**
  46416. * Interface used to define scene explorer extensibility option
  46417. */
  46418. export interface IExplorerExtensibilityOption {
  46419. /**
  46420. * Define the option label
  46421. */
  46422. label: string;
  46423. /**
  46424. * Defines the action to execute on click
  46425. */
  46426. action: (entity: any) => void;
  46427. }
  46428. /**
  46429. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46430. */
  46431. export interface IExplorerExtensibilityGroup {
  46432. /**
  46433. * Defines a predicate to test if a given type mut be extended
  46434. */
  46435. predicate: (entity: any) => boolean;
  46436. /**
  46437. * Gets the list of options added to a type
  46438. */
  46439. entries: IExplorerExtensibilityOption[];
  46440. }
  46441. /**
  46442. * Interface used to define the options to use to create the Inspector
  46443. */
  46444. export interface IInspectorOptions {
  46445. /**
  46446. * Display in overlay mode (default: false)
  46447. */
  46448. overlay?: boolean;
  46449. /**
  46450. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46451. */
  46452. globalRoot?: HTMLElement;
  46453. /**
  46454. * Display the Scene explorer
  46455. */
  46456. showExplorer?: boolean;
  46457. /**
  46458. * Display the property inspector
  46459. */
  46460. showInspector?: boolean;
  46461. /**
  46462. * Display in embed mode (both panes on the right)
  46463. */
  46464. embedMode?: boolean;
  46465. /**
  46466. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46467. */
  46468. handleResize?: boolean;
  46469. /**
  46470. * Allow the panes to popup (default: true)
  46471. */
  46472. enablePopup?: boolean;
  46473. /**
  46474. * Allow the panes to be closed by users (default: true)
  46475. */
  46476. enableClose?: boolean;
  46477. /**
  46478. * Optional list of extensibility entries
  46479. */
  46480. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46481. /**
  46482. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46483. */
  46484. inspectorURL?: string;
  46485. /**
  46486. * Optional initial tab (default to DebugLayerTab.Properties)
  46487. */
  46488. initialTab?: DebugLayerTab;
  46489. }
  46490. interface Scene {
  46491. /**
  46492. * @hidden
  46493. * Backing field
  46494. */
  46495. _debugLayer: DebugLayer;
  46496. /**
  46497. * Gets the debug layer (aka Inspector) associated with the scene
  46498. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46499. */
  46500. debugLayer: DebugLayer;
  46501. }
  46502. /**
  46503. * Enum of inspector action tab
  46504. */
  46505. export enum DebugLayerTab {
  46506. /**
  46507. * Properties tag (default)
  46508. */
  46509. Properties = 0,
  46510. /**
  46511. * Debug tab
  46512. */
  46513. Debug = 1,
  46514. /**
  46515. * Statistics tab
  46516. */
  46517. Statistics = 2,
  46518. /**
  46519. * Tools tab
  46520. */
  46521. Tools = 3,
  46522. /**
  46523. * Settings tab
  46524. */
  46525. Settings = 4
  46526. }
  46527. /**
  46528. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46529. * what is happening in your scene
  46530. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46531. */
  46532. export class DebugLayer {
  46533. /**
  46534. * Define the url to get the inspector script from.
  46535. * By default it uses the babylonjs CDN.
  46536. * @ignoreNaming
  46537. */
  46538. static InspectorURL: string;
  46539. private _scene;
  46540. private BJSINSPECTOR;
  46541. private _onPropertyChangedObservable?;
  46542. /**
  46543. * Observable triggered when a property is changed through the inspector.
  46544. */
  46545. get onPropertyChangedObservable(): any;
  46546. /**
  46547. * Instantiates a new debug layer.
  46548. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46549. * what is happening in your scene
  46550. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46551. * @param scene Defines the scene to inspect
  46552. */
  46553. constructor(scene: Scene);
  46554. /** Creates the inspector window. */
  46555. private _createInspector;
  46556. /**
  46557. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46558. * @param entity defines the entity to select
  46559. * @param lineContainerTitle defines the specific block to highlight
  46560. */
  46561. select(entity: any, lineContainerTitle?: string): void;
  46562. /** Get the inspector from bundle or global */
  46563. private _getGlobalInspector;
  46564. /**
  46565. * Get if the inspector is visible or not.
  46566. * @returns true if visible otherwise, false
  46567. */
  46568. isVisible(): boolean;
  46569. /**
  46570. * Hide the inspector and close its window.
  46571. */
  46572. hide(): void;
  46573. /**
  46574. * Launch the debugLayer.
  46575. * @param config Define the configuration of the inspector
  46576. * @return a promise fulfilled when the debug layer is visible
  46577. */
  46578. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46579. }
  46580. }
  46581. declare module BABYLON {
  46582. /**
  46583. * Class containing static functions to help procedurally build meshes
  46584. */
  46585. export class BoxBuilder {
  46586. /**
  46587. * Creates a box mesh
  46588. * * The parameter `size` sets the size (float) of each box side (default 1)
  46589. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46590. * * 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)
  46591. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46592. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46593. * * 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
  46594. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46595. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46596. * @param name defines the name of the mesh
  46597. * @param options defines the options used to create the mesh
  46598. * @param scene defines the hosting scene
  46599. * @returns the box mesh
  46600. */
  46601. static CreateBox(name: string, options: {
  46602. size?: number;
  46603. width?: number;
  46604. height?: number;
  46605. depth?: number;
  46606. faceUV?: Vector4[];
  46607. faceColors?: Color4[];
  46608. sideOrientation?: number;
  46609. frontUVs?: Vector4;
  46610. backUVs?: Vector4;
  46611. wrap?: boolean;
  46612. topBaseAt?: number;
  46613. bottomBaseAt?: number;
  46614. updatable?: boolean;
  46615. }, scene?: Nullable<Scene>): Mesh;
  46616. }
  46617. }
  46618. declare module BABYLON.Debug {
  46619. /**
  46620. * Used to show the physics impostor around the specific mesh
  46621. */
  46622. export class PhysicsViewer {
  46623. /** @hidden */
  46624. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46625. /** @hidden */
  46626. protected _meshes: Array<Nullable<AbstractMesh>>;
  46627. /** @hidden */
  46628. protected _scene: Nullable<Scene>;
  46629. /** @hidden */
  46630. protected _numMeshes: number;
  46631. /** @hidden */
  46632. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46633. private _renderFunction;
  46634. private _utilityLayer;
  46635. private _debugBoxMesh;
  46636. private _debugSphereMesh;
  46637. private _debugCylinderMesh;
  46638. private _debugMaterial;
  46639. private _debugMeshMeshes;
  46640. /**
  46641. * Creates a new PhysicsViewer
  46642. * @param scene defines the hosting scene
  46643. */
  46644. constructor(scene: Scene);
  46645. /** @hidden */
  46646. protected _updateDebugMeshes(): void;
  46647. /**
  46648. * Renders a specified physic impostor
  46649. * @param impostor defines the impostor to render
  46650. * @param targetMesh defines the mesh represented by the impostor
  46651. * @returns the new debug mesh used to render the impostor
  46652. */
  46653. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46654. /**
  46655. * Hides a specified physic impostor
  46656. * @param impostor defines the impostor to hide
  46657. */
  46658. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46659. private _getDebugMaterial;
  46660. private _getDebugBoxMesh;
  46661. private _getDebugSphereMesh;
  46662. private _getDebugCylinderMesh;
  46663. private _getDebugMeshMesh;
  46664. private _getDebugMesh;
  46665. /** Releases all resources */
  46666. dispose(): void;
  46667. }
  46668. }
  46669. declare module BABYLON {
  46670. /**
  46671. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46672. * in order to better appreciate the issue one might have.
  46673. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46674. */
  46675. export class RayHelper {
  46676. /**
  46677. * Defines the ray we are currently tryin to visualize.
  46678. */
  46679. ray: Nullable<Ray>;
  46680. private _renderPoints;
  46681. private _renderLine;
  46682. private _renderFunction;
  46683. private _scene;
  46684. private _updateToMeshFunction;
  46685. private _attachedToMesh;
  46686. private _meshSpaceDirection;
  46687. private _meshSpaceOrigin;
  46688. /**
  46689. * Helper function to create a colored helper in a scene in one line.
  46690. * @param ray Defines the ray we are currently tryin to visualize
  46691. * @param scene Defines the scene the ray is used in
  46692. * @param color Defines the color we want to see the ray in
  46693. * @returns The newly created ray helper.
  46694. */
  46695. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46696. /**
  46697. * Instantiate a new ray helper.
  46698. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46699. * in order to better appreciate the issue one might have.
  46700. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46701. * @param ray Defines the ray we are currently tryin to visualize
  46702. */
  46703. constructor(ray: Ray);
  46704. /**
  46705. * Shows the ray we are willing to debug.
  46706. * @param scene Defines the scene the ray needs to be rendered in
  46707. * @param color Defines the color the ray needs to be rendered in
  46708. */
  46709. show(scene: Scene, color?: Color3): void;
  46710. /**
  46711. * Hides the ray we are debugging.
  46712. */
  46713. hide(): void;
  46714. private _render;
  46715. /**
  46716. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46717. * @param mesh Defines the mesh we want the helper attached to
  46718. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46719. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46720. * @param length Defines the length of the ray
  46721. */
  46722. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46723. /**
  46724. * Detach the ray helper from the mesh it has previously been attached to.
  46725. */
  46726. detachFromMesh(): void;
  46727. private _updateToMesh;
  46728. /**
  46729. * Dispose the helper and release its associated resources.
  46730. */
  46731. dispose(): void;
  46732. }
  46733. }
  46734. declare module BABYLON.Debug {
  46735. /**
  46736. * Class used to render a debug view of a given skeleton
  46737. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46738. */
  46739. export class SkeletonViewer {
  46740. /** defines the skeleton to render */
  46741. skeleton: Skeleton;
  46742. /** defines the mesh attached to the skeleton */
  46743. mesh: AbstractMesh;
  46744. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46745. autoUpdateBonesMatrices: boolean;
  46746. /** defines the rendering group id to use with the viewer */
  46747. renderingGroupId: number;
  46748. /** Gets or sets the color used to render the skeleton */
  46749. color: Color3;
  46750. private _scene;
  46751. private _debugLines;
  46752. private _debugMesh;
  46753. private _isEnabled;
  46754. private _renderFunction;
  46755. private _utilityLayer;
  46756. /**
  46757. * Returns the mesh used to render the bones
  46758. */
  46759. get debugMesh(): Nullable<LinesMesh>;
  46760. /**
  46761. * Creates a new SkeletonViewer
  46762. * @param skeleton defines the skeleton to render
  46763. * @param mesh defines the mesh attached to the skeleton
  46764. * @param scene defines the hosting scene
  46765. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46766. * @param renderingGroupId defines the rendering group id to use with the viewer
  46767. */
  46768. constructor(
  46769. /** defines the skeleton to render */
  46770. skeleton: Skeleton,
  46771. /** defines the mesh attached to the skeleton */
  46772. mesh: AbstractMesh, scene: Scene,
  46773. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46774. autoUpdateBonesMatrices?: boolean,
  46775. /** defines the rendering group id to use with the viewer */
  46776. renderingGroupId?: number);
  46777. /** Gets or sets a boolean indicating if the viewer is enabled */
  46778. set isEnabled(value: boolean);
  46779. get isEnabled(): boolean;
  46780. private _getBonePosition;
  46781. private _getLinesForBonesWithLength;
  46782. private _getLinesForBonesNoLength;
  46783. /** Update the viewer to sync with current skeleton state */
  46784. update(): void;
  46785. /** Release associated resources */
  46786. dispose(): void;
  46787. }
  46788. }
  46789. declare module BABYLON {
  46790. /**
  46791. * Options to create the null engine
  46792. */
  46793. export class NullEngineOptions {
  46794. /**
  46795. * Render width (Default: 512)
  46796. */
  46797. renderWidth: number;
  46798. /**
  46799. * Render height (Default: 256)
  46800. */
  46801. renderHeight: number;
  46802. /**
  46803. * Texture size (Default: 512)
  46804. */
  46805. textureSize: number;
  46806. /**
  46807. * If delta time between frames should be constant
  46808. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46809. */
  46810. deterministicLockstep: boolean;
  46811. /**
  46812. * Maximum about of steps between frames (Default: 4)
  46813. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46814. */
  46815. lockstepMaxSteps: number;
  46816. }
  46817. /**
  46818. * The null engine class provides support for headless version of babylon.js.
  46819. * This can be used in server side scenario or for testing purposes
  46820. */
  46821. export class NullEngine extends Engine {
  46822. private _options;
  46823. /**
  46824. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46825. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46826. * @returns true if engine is in deterministic lock step mode
  46827. */
  46828. isDeterministicLockStep(): boolean;
  46829. /**
  46830. * Gets the max steps when engine is running in deterministic lock step
  46831. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46832. * @returns the max steps
  46833. */
  46834. getLockstepMaxSteps(): number;
  46835. /**
  46836. * Gets the current hardware scaling level.
  46837. * By default the hardware scaling level is computed from the window device ratio.
  46838. * 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.
  46839. * @returns a number indicating the current hardware scaling level
  46840. */
  46841. getHardwareScalingLevel(): number;
  46842. constructor(options?: NullEngineOptions);
  46843. /**
  46844. * Creates a vertex buffer
  46845. * @param vertices the data for the vertex buffer
  46846. * @returns the new WebGL static buffer
  46847. */
  46848. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46849. /**
  46850. * Creates a new index buffer
  46851. * @param indices defines the content of the index buffer
  46852. * @param updatable defines if the index buffer must be updatable
  46853. * @returns a new webGL buffer
  46854. */
  46855. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46856. /**
  46857. * Clear the current render buffer or the current render target (if any is set up)
  46858. * @param color defines the color to use
  46859. * @param backBuffer defines if the back buffer must be cleared
  46860. * @param depth defines if the depth buffer must be cleared
  46861. * @param stencil defines if the stencil buffer must be cleared
  46862. */
  46863. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46864. /**
  46865. * Gets the current render width
  46866. * @param useScreen defines if screen size must be used (or the current render target if any)
  46867. * @returns a number defining the current render width
  46868. */
  46869. getRenderWidth(useScreen?: boolean): number;
  46870. /**
  46871. * Gets the current render height
  46872. * @param useScreen defines if screen size must be used (or the current render target if any)
  46873. * @returns a number defining the current render height
  46874. */
  46875. getRenderHeight(useScreen?: boolean): number;
  46876. /**
  46877. * Set the WebGL's viewport
  46878. * @param viewport defines the viewport element to be used
  46879. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46880. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46881. */
  46882. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46883. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46884. /**
  46885. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46886. * @param pipelineContext defines the pipeline context to use
  46887. * @param uniformsNames defines the list of uniform names
  46888. * @returns an array of webGL uniform locations
  46889. */
  46890. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46891. /**
  46892. * Gets the lsit of active attributes for a given webGL program
  46893. * @param pipelineContext defines the pipeline context to use
  46894. * @param attributesNames defines the list of attribute names to get
  46895. * @returns an array of indices indicating the offset of each attribute
  46896. */
  46897. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46898. /**
  46899. * Binds an effect to the webGL context
  46900. * @param effect defines the effect to bind
  46901. */
  46902. bindSamplers(effect: Effect): void;
  46903. /**
  46904. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46905. * @param effect defines the effect to activate
  46906. */
  46907. enableEffect(effect: Effect): void;
  46908. /**
  46909. * Set various states to the webGL context
  46910. * @param culling defines backface culling state
  46911. * @param zOffset defines the value to apply to zOffset (0 by default)
  46912. * @param force defines if states must be applied even if cache is up to date
  46913. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46914. */
  46915. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46916. /**
  46917. * Set the value of an uniform to an array of int32
  46918. * @param uniform defines the webGL uniform location where to store the value
  46919. * @param array defines the array of int32 to store
  46920. */
  46921. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46922. /**
  46923. * Set the value of an uniform to an array of int32 (stored as vec2)
  46924. * @param uniform defines the webGL uniform location where to store the value
  46925. * @param array defines the array of int32 to store
  46926. */
  46927. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46928. /**
  46929. * Set the value of an uniform to an array of int32 (stored as vec3)
  46930. * @param uniform defines the webGL uniform location where to store the value
  46931. * @param array defines the array of int32 to store
  46932. */
  46933. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46934. /**
  46935. * Set the value of an uniform to an array of int32 (stored as vec4)
  46936. * @param uniform defines the webGL uniform location where to store the value
  46937. * @param array defines the array of int32 to store
  46938. */
  46939. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46940. /**
  46941. * Set the value of an uniform to an array of float32
  46942. * @param uniform defines the webGL uniform location where to store the value
  46943. * @param array defines the array of float32 to store
  46944. */
  46945. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46946. /**
  46947. * Set the value of an uniform to an array of float32 (stored as vec2)
  46948. * @param uniform defines the webGL uniform location where to store the value
  46949. * @param array defines the array of float32 to store
  46950. */
  46951. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46952. /**
  46953. * Set the value of an uniform to an array of float32 (stored as vec3)
  46954. * @param uniform defines the webGL uniform location where to store the value
  46955. * @param array defines the array of float32 to store
  46956. */
  46957. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46958. /**
  46959. * Set the value of an uniform to an array of float32 (stored as vec4)
  46960. * @param uniform defines the webGL uniform location where to store the value
  46961. * @param array defines the array of float32 to store
  46962. */
  46963. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46964. /**
  46965. * Set the value of an uniform to an array of number
  46966. * @param uniform defines the webGL uniform location where to store the value
  46967. * @param array defines the array of number to store
  46968. */
  46969. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46970. /**
  46971. * Set the value of an uniform to an array of number (stored as vec2)
  46972. * @param uniform defines the webGL uniform location where to store the value
  46973. * @param array defines the array of number to store
  46974. */
  46975. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46976. /**
  46977. * Set the value of an uniform to an array of number (stored as vec3)
  46978. * @param uniform defines the webGL uniform location where to store the value
  46979. * @param array defines the array of number to store
  46980. */
  46981. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46982. /**
  46983. * Set the value of an uniform to an array of number (stored as vec4)
  46984. * @param uniform defines the webGL uniform location where to store the value
  46985. * @param array defines the array of number to store
  46986. */
  46987. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46988. /**
  46989. * Set the value of an uniform to an array of float32 (stored as matrices)
  46990. * @param uniform defines the webGL uniform location where to store the value
  46991. * @param matrices defines the array of float32 to store
  46992. */
  46993. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46994. /**
  46995. * Set the value of an uniform to a matrix (3x3)
  46996. * @param uniform defines the webGL uniform location where to store the value
  46997. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  46998. */
  46999. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47000. /**
  47001. * Set the value of an uniform to a matrix (2x2)
  47002. * @param uniform defines the webGL uniform location where to store the value
  47003. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  47004. */
  47005. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47006. /**
  47007. * Set the value of an uniform to a number (float)
  47008. * @param uniform defines the webGL uniform location where to store the value
  47009. * @param value defines the float number to store
  47010. */
  47011. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47012. /**
  47013. * Set the value of an uniform to a vec2
  47014. * @param uniform defines the webGL uniform location where to store the value
  47015. * @param x defines the 1st component of the value
  47016. * @param y defines the 2nd component of the value
  47017. */
  47018. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47019. /**
  47020. * Set the value of an uniform to a vec3
  47021. * @param uniform defines the webGL uniform location where to store the value
  47022. * @param x defines the 1st component of the value
  47023. * @param y defines the 2nd component of the value
  47024. * @param z defines the 3rd component of the value
  47025. */
  47026. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47027. /**
  47028. * Set the value of an uniform to a boolean
  47029. * @param uniform defines the webGL uniform location where to store the value
  47030. * @param bool defines the boolean to store
  47031. */
  47032. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47033. /**
  47034. * Set the value of an uniform to a vec4
  47035. * @param uniform defines the webGL uniform location where to store the value
  47036. * @param x defines the 1st component of the value
  47037. * @param y defines the 2nd component of the value
  47038. * @param z defines the 3rd component of the value
  47039. * @param w defines the 4th component of the value
  47040. */
  47041. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47042. /**
  47043. * Sets the current alpha mode
  47044. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  47045. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47046. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47047. */
  47048. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47049. /**
  47050. * Bind webGl buffers directly to the webGL context
  47051. * @param vertexBuffers defines the vertex buffer to bind
  47052. * @param indexBuffer defines the index buffer to bind
  47053. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  47054. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  47055. * @param effect defines the effect associated with the vertex buffer
  47056. */
  47057. bindBuffers(vertexBuffers: {
  47058. [key: string]: VertexBuffer;
  47059. }, indexBuffer: DataBuffer, effect: Effect): void;
  47060. /**
  47061. * Force the entire cache to be cleared
  47062. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  47063. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  47064. */
  47065. wipeCaches(bruteForce?: boolean): void;
  47066. /**
  47067. * Send a draw order
  47068. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  47069. * @param indexStart defines the starting index
  47070. * @param indexCount defines the number of index to draw
  47071. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47072. */
  47073. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  47074. /**
  47075. * Draw a list of indexed primitives
  47076. * @param fillMode defines the primitive to use
  47077. * @param indexStart defines the starting index
  47078. * @param indexCount defines the number of index to draw
  47079. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47080. */
  47081. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47082. /**
  47083. * Draw a list of unindexed primitives
  47084. * @param fillMode defines the primitive to use
  47085. * @param verticesStart defines the index of first vertex to draw
  47086. * @param verticesCount defines the count of vertices to draw
  47087. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47088. */
  47089. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47090. /** @hidden */
  47091. _createTexture(): WebGLTexture;
  47092. /** @hidden */
  47093. _releaseTexture(texture: InternalTexture): void;
  47094. /**
  47095. * Usually called from Texture.ts.
  47096. * Passed information to create a WebGLTexture
  47097. * @param urlArg defines a value which contains one of the following:
  47098. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47099. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47100. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47101. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47102. * @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)
  47103. * @param scene needed for loading to the correct scene
  47104. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47105. * @param onLoad optional callback to be called upon successful completion
  47106. * @param onError optional callback to be called upon failure
  47107. * @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
  47108. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47109. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47110. * @param forcedExtension defines the extension to use to pick the right loader
  47111. * @param mimeType defines an optional mime type
  47112. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47113. */
  47114. 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;
  47115. /**
  47116. * Creates a new render target texture
  47117. * @param size defines the size of the texture
  47118. * @param options defines the options used to create the texture
  47119. * @returns a new render target texture stored in an InternalTexture
  47120. */
  47121. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  47122. /**
  47123. * Update the sampling mode of a given texture
  47124. * @param samplingMode defines the required sampling mode
  47125. * @param texture defines the texture to update
  47126. */
  47127. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47128. /**
  47129. * Binds the frame buffer to the specified texture.
  47130. * @param texture The texture to render to or null for the default canvas
  47131. * @param faceIndex The face of the texture to render to in case of cube texture
  47132. * @param requiredWidth The width of the target to render to
  47133. * @param requiredHeight The height of the target to render to
  47134. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  47135. * @param lodLevel defines le lod level to bind to the frame buffer
  47136. */
  47137. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47138. /**
  47139. * Unbind the current render target texture from the webGL context
  47140. * @param texture defines the render target texture to unbind
  47141. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47142. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47143. */
  47144. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47145. /**
  47146. * Creates a dynamic vertex buffer
  47147. * @param vertices the data for the dynamic vertex buffer
  47148. * @returns the new WebGL dynamic buffer
  47149. */
  47150. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  47151. /**
  47152. * Update the content of a dynamic texture
  47153. * @param texture defines the texture to update
  47154. * @param canvas defines the canvas containing the source
  47155. * @param invertY defines if data must be stored with Y axis inverted
  47156. * @param premulAlpha defines if alpha is stored as premultiplied
  47157. * @param format defines the format of the data
  47158. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  47159. */
  47160. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  47161. /**
  47162. * Gets a boolean indicating if all created effects are ready
  47163. * @returns true if all effects are ready
  47164. */
  47165. areAllEffectsReady(): boolean;
  47166. /**
  47167. * @hidden
  47168. * Get the current error code of the webGL context
  47169. * @returns the error code
  47170. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  47171. */
  47172. getError(): number;
  47173. /** @hidden */
  47174. _getUnpackAlignement(): number;
  47175. /** @hidden */
  47176. _unpackFlipY(value: boolean): void;
  47177. /**
  47178. * Update a dynamic index buffer
  47179. * @param indexBuffer defines the target index buffer
  47180. * @param indices defines the data to update
  47181. * @param offset defines the offset in the target index buffer where update should start
  47182. */
  47183. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  47184. /**
  47185. * Updates a dynamic vertex buffer.
  47186. * @param vertexBuffer the vertex buffer to update
  47187. * @param vertices the data used to update the vertex buffer
  47188. * @param byteOffset the byte offset of the data (optional)
  47189. * @param byteLength the byte length of the data (optional)
  47190. */
  47191. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  47192. /** @hidden */
  47193. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  47194. /** @hidden */
  47195. _bindTexture(channel: number, texture: InternalTexture): void;
  47196. protected _deleteBuffer(buffer: WebGLBuffer): void;
  47197. /**
  47198. * 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
  47199. */
  47200. releaseEffects(): void;
  47201. displayLoadingUI(): void;
  47202. hideLoadingUI(): void;
  47203. /** @hidden */
  47204. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47205. /** @hidden */
  47206. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47207. /** @hidden */
  47208. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47209. /** @hidden */
  47210. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47211. }
  47212. }
  47213. declare module BABYLON {
  47214. /**
  47215. * @hidden
  47216. **/
  47217. export class _TimeToken {
  47218. _startTimeQuery: Nullable<WebGLQuery>;
  47219. _endTimeQuery: Nullable<WebGLQuery>;
  47220. _timeElapsedQuery: Nullable<WebGLQuery>;
  47221. _timeElapsedQueryEnded: boolean;
  47222. }
  47223. }
  47224. declare module BABYLON {
  47225. /** @hidden */
  47226. export class _OcclusionDataStorage {
  47227. /** @hidden */
  47228. occlusionInternalRetryCounter: number;
  47229. /** @hidden */
  47230. isOcclusionQueryInProgress: boolean;
  47231. /** @hidden */
  47232. isOccluded: boolean;
  47233. /** @hidden */
  47234. occlusionRetryCount: number;
  47235. /** @hidden */
  47236. occlusionType: number;
  47237. /** @hidden */
  47238. occlusionQueryAlgorithmType: number;
  47239. }
  47240. interface Engine {
  47241. /**
  47242. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  47243. * @return the new query
  47244. */
  47245. createQuery(): WebGLQuery;
  47246. /**
  47247. * Delete and release a webGL query
  47248. * @param query defines the query to delete
  47249. * @return the current engine
  47250. */
  47251. deleteQuery(query: WebGLQuery): Engine;
  47252. /**
  47253. * Check if a given query has resolved and got its value
  47254. * @param query defines the query to check
  47255. * @returns true if the query got its value
  47256. */
  47257. isQueryResultAvailable(query: WebGLQuery): boolean;
  47258. /**
  47259. * Gets the value of a given query
  47260. * @param query defines the query to check
  47261. * @returns the value of the query
  47262. */
  47263. getQueryResult(query: WebGLQuery): number;
  47264. /**
  47265. * Initiates an occlusion query
  47266. * @param algorithmType defines the algorithm to use
  47267. * @param query defines the query to use
  47268. * @returns the current engine
  47269. * @see http://doc.babylonjs.com/features/occlusionquery
  47270. */
  47271. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  47272. /**
  47273. * Ends an occlusion query
  47274. * @see http://doc.babylonjs.com/features/occlusionquery
  47275. * @param algorithmType defines the algorithm to use
  47276. * @returns the current engine
  47277. */
  47278. endOcclusionQuery(algorithmType: number): Engine;
  47279. /**
  47280. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  47281. * Please note that only one query can be issued at a time
  47282. * @returns a time token used to track the time span
  47283. */
  47284. startTimeQuery(): Nullable<_TimeToken>;
  47285. /**
  47286. * Ends a time query
  47287. * @param token defines the token used to measure the time span
  47288. * @returns the time spent (in ns)
  47289. */
  47290. endTimeQuery(token: _TimeToken): int;
  47291. /** @hidden */
  47292. _currentNonTimestampToken: Nullable<_TimeToken>;
  47293. /** @hidden */
  47294. _createTimeQuery(): WebGLQuery;
  47295. /** @hidden */
  47296. _deleteTimeQuery(query: WebGLQuery): void;
  47297. /** @hidden */
  47298. _getGlAlgorithmType(algorithmType: number): number;
  47299. /** @hidden */
  47300. _getTimeQueryResult(query: WebGLQuery): any;
  47301. /** @hidden */
  47302. _getTimeQueryAvailability(query: WebGLQuery): any;
  47303. }
  47304. interface AbstractMesh {
  47305. /**
  47306. * Backing filed
  47307. * @hidden
  47308. */
  47309. __occlusionDataStorage: _OcclusionDataStorage;
  47310. /**
  47311. * Access property
  47312. * @hidden
  47313. */
  47314. _occlusionDataStorage: _OcclusionDataStorage;
  47315. /**
  47316. * 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.
  47317. * The default value is -1 which means don't break the query and wait till the result
  47318. * @see http://doc.babylonjs.com/features/occlusionquery
  47319. */
  47320. occlusionRetryCount: number;
  47321. /**
  47322. * 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:
  47323. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  47324. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  47325. * * 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.
  47326. * @see http://doc.babylonjs.com/features/occlusionquery
  47327. */
  47328. occlusionType: number;
  47329. /**
  47330. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  47331. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  47332. * * 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.
  47333. * @see http://doc.babylonjs.com/features/occlusionquery
  47334. */
  47335. occlusionQueryAlgorithmType: number;
  47336. /**
  47337. * 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
  47338. * @see http://doc.babylonjs.com/features/occlusionquery
  47339. */
  47340. isOccluded: boolean;
  47341. /**
  47342. * Flag to check the progress status of the query
  47343. * @see http://doc.babylonjs.com/features/occlusionquery
  47344. */
  47345. isOcclusionQueryInProgress: boolean;
  47346. }
  47347. }
  47348. declare module BABYLON {
  47349. /** @hidden */
  47350. export var _forceTransformFeedbackToBundle: boolean;
  47351. interface Engine {
  47352. /**
  47353. * Creates a webGL transform feedback object
  47354. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47355. * @returns the webGL transform feedback object
  47356. */
  47357. createTransformFeedback(): WebGLTransformFeedback;
  47358. /**
  47359. * Delete a webGL transform feedback object
  47360. * @param value defines the webGL transform feedback object to delete
  47361. */
  47362. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47363. /**
  47364. * Bind a webGL transform feedback object to the webgl context
  47365. * @param value defines the webGL transform feedback object to bind
  47366. */
  47367. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47368. /**
  47369. * Begins a transform feedback operation
  47370. * @param usePoints defines if points or triangles must be used
  47371. */
  47372. beginTransformFeedback(usePoints: boolean): void;
  47373. /**
  47374. * Ends a transform feedback operation
  47375. */
  47376. endTransformFeedback(): void;
  47377. /**
  47378. * Specify the varyings to use with transform feedback
  47379. * @param program defines the associated webGL program
  47380. * @param value defines the list of strings representing the varying names
  47381. */
  47382. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47383. /**
  47384. * Bind a webGL buffer for a transform feedback operation
  47385. * @param value defines the webGL buffer to bind
  47386. */
  47387. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47388. }
  47389. }
  47390. declare module BABYLON {
  47391. /**
  47392. * Creation options of the multi render target texture.
  47393. */
  47394. export interface IMultiRenderTargetOptions {
  47395. /**
  47396. * Define if the texture needs to create mip maps after render.
  47397. */
  47398. generateMipMaps?: boolean;
  47399. /**
  47400. * Define the types of all the draw buffers we want to create
  47401. */
  47402. types?: number[];
  47403. /**
  47404. * Define the sampling modes of all the draw buffers we want to create
  47405. */
  47406. samplingModes?: number[];
  47407. /**
  47408. * Define if a depth buffer is required
  47409. */
  47410. generateDepthBuffer?: boolean;
  47411. /**
  47412. * Define if a stencil buffer is required
  47413. */
  47414. generateStencilBuffer?: boolean;
  47415. /**
  47416. * Define if a depth texture is required instead of a depth buffer
  47417. */
  47418. generateDepthTexture?: boolean;
  47419. /**
  47420. * Define the number of desired draw buffers
  47421. */
  47422. textureCount?: number;
  47423. /**
  47424. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47425. */
  47426. doNotChangeAspectRatio?: boolean;
  47427. /**
  47428. * Define the default type of the buffers we are creating
  47429. */
  47430. defaultType?: number;
  47431. }
  47432. /**
  47433. * A multi render target, like a render target provides the ability to render to a texture.
  47434. * Unlike the render target, it can render to several draw buffers in one draw.
  47435. * This is specially interesting in deferred rendering or for any effects requiring more than
  47436. * just one color from a single pass.
  47437. */
  47438. export class MultiRenderTarget extends RenderTargetTexture {
  47439. private _internalTextures;
  47440. private _textures;
  47441. private _multiRenderTargetOptions;
  47442. /**
  47443. * Get if draw buffers are currently supported by the used hardware and browser.
  47444. */
  47445. get isSupported(): boolean;
  47446. /**
  47447. * Get the list of textures generated by the multi render target.
  47448. */
  47449. get textures(): Texture[];
  47450. /**
  47451. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47452. */
  47453. get depthTexture(): Texture;
  47454. /**
  47455. * Set the wrapping mode on U of all the textures we are rendering to.
  47456. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47457. */
  47458. set wrapU(wrap: number);
  47459. /**
  47460. * Set the wrapping mode on V of all the textures we are rendering to.
  47461. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47462. */
  47463. set wrapV(wrap: number);
  47464. /**
  47465. * Instantiate a new multi render target texture.
  47466. * A multi render target, like a render target provides the ability to render to a texture.
  47467. * Unlike the render target, it can render to several draw buffers in one draw.
  47468. * This is specially interesting in deferred rendering or for any effects requiring more than
  47469. * just one color from a single pass.
  47470. * @param name Define the name of the texture
  47471. * @param size Define the size of the buffers to render to
  47472. * @param count Define the number of target we are rendering into
  47473. * @param scene Define the scene the texture belongs to
  47474. * @param options Define the options used to create the multi render target
  47475. */
  47476. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47477. /** @hidden */
  47478. _rebuild(): void;
  47479. private _createInternalTextures;
  47480. private _createTextures;
  47481. /**
  47482. * Define the number of samples used if MSAA is enabled.
  47483. */
  47484. get samples(): number;
  47485. set samples(value: number);
  47486. /**
  47487. * Resize all the textures in the multi render target.
  47488. * Be carrefull as it will recreate all the data in the new texture.
  47489. * @param size Define the new size
  47490. */
  47491. resize(size: any): void;
  47492. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47493. /**
  47494. * Dispose the render targets and their associated resources
  47495. */
  47496. dispose(): void;
  47497. /**
  47498. * Release all the underlying texture used as draw buffers.
  47499. */
  47500. releaseInternalTextures(): void;
  47501. }
  47502. }
  47503. declare module BABYLON {
  47504. interface ThinEngine {
  47505. /**
  47506. * Unbind a list of render target textures from the webGL context
  47507. * This is used only when drawBuffer extension or webGL2 are active
  47508. * @param textures defines the render target textures to unbind
  47509. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47510. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47511. */
  47512. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47513. /**
  47514. * Create a multi render target texture
  47515. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47516. * @param size defines the size of the texture
  47517. * @param options defines the creation options
  47518. * @returns the cube texture as an InternalTexture
  47519. */
  47520. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47521. /**
  47522. * Update the sample count for a given multiple render target texture
  47523. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47524. * @param textures defines the textures to update
  47525. * @param samples defines the sample count to set
  47526. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47527. */
  47528. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47529. }
  47530. }
  47531. declare module BABYLON {
  47532. /**
  47533. * Class used to define an additional view for the engine
  47534. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47535. */
  47536. export class EngineView {
  47537. /** Defines the canvas where to render the view */
  47538. target: HTMLCanvasElement;
  47539. /** Defines an optional camera used to render the view (will use active camera else) */
  47540. camera?: Camera;
  47541. }
  47542. interface Engine {
  47543. /**
  47544. * Gets or sets the HTML element to use for attaching events
  47545. */
  47546. inputElement: Nullable<HTMLElement>;
  47547. /**
  47548. * Gets the current engine view
  47549. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47550. */
  47551. activeView: Nullable<EngineView>;
  47552. /** Gets or sets the list of views */
  47553. views: EngineView[];
  47554. /**
  47555. * Register a new child canvas
  47556. * @param canvas defines the canvas to register
  47557. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47558. * @returns the associated view
  47559. */
  47560. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47561. /**
  47562. * Remove a registered child canvas
  47563. * @param canvas defines the canvas to remove
  47564. * @returns the current engine
  47565. */
  47566. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47567. }
  47568. }
  47569. declare module BABYLON {
  47570. interface Engine {
  47571. /** @hidden */
  47572. _excludedCompressedTextures: string[];
  47573. /** @hidden */
  47574. _textureFormatInUse: string;
  47575. /**
  47576. * Gets the list of texture formats supported
  47577. */
  47578. readonly texturesSupported: Array<string>;
  47579. /**
  47580. * Gets the texture format in use
  47581. */
  47582. readonly textureFormatInUse: Nullable<string>;
  47583. /**
  47584. * Set the compressed texture extensions or file names to skip.
  47585. *
  47586. * @param skippedFiles defines the list of those texture files you want to skip
  47587. * Example: [".dds", ".env", "myfile.png"]
  47588. */
  47589. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  47590. /**
  47591. * Set the compressed texture format to use, based on the formats you have, and the formats
  47592. * supported by the hardware / browser.
  47593. *
  47594. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  47595. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  47596. * to API arguments needed to compressed textures. This puts the burden on the container
  47597. * generator to house the arcane code for determining these for current & future formats.
  47598. *
  47599. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47600. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47601. *
  47602. * Note: The result of this call is not taken into account when a texture is base64.
  47603. *
  47604. * @param formatsAvailable defines the list of those format families you have created
  47605. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  47606. *
  47607. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  47608. * @returns The extension selected.
  47609. */
  47610. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  47611. }
  47612. }
  47613. declare module BABYLON {
  47614. /**
  47615. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47616. */
  47617. export interface CubeMapInfo {
  47618. /**
  47619. * The pixel array for the front face.
  47620. * This is stored in format, left to right, up to down format.
  47621. */
  47622. front: Nullable<ArrayBufferView>;
  47623. /**
  47624. * The pixel array for the back face.
  47625. * This is stored in format, left to right, up to down format.
  47626. */
  47627. back: Nullable<ArrayBufferView>;
  47628. /**
  47629. * The pixel array for the left face.
  47630. * This is stored in format, left to right, up to down format.
  47631. */
  47632. left: Nullable<ArrayBufferView>;
  47633. /**
  47634. * The pixel array for the right face.
  47635. * This is stored in format, left to right, up to down format.
  47636. */
  47637. right: Nullable<ArrayBufferView>;
  47638. /**
  47639. * The pixel array for the up face.
  47640. * This is stored in format, left to right, up to down format.
  47641. */
  47642. up: Nullable<ArrayBufferView>;
  47643. /**
  47644. * The pixel array for the down face.
  47645. * This is stored in format, left to right, up to down format.
  47646. */
  47647. down: Nullable<ArrayBufferView>;
  47648. /**
  47649. * The size of the cubemap stored.
  47650. *
  47651. * Each faces will be size * size pixels.
  47652. */
  47653. size: number;
  47654. /**
  47655. * The format of the texture.
  47656. *
  47657. * RGBA, RGB.
  47658. */
  47659. format: number;
  47660. /**
  47661. * The type of the texture data.
  47662. *
  47663. * UNSIGNED_INT, FLOAT.
  47664. */
  47665. type: number;
  47666. /**
  47667. * Specifies whether the texture is in gamma space.
  47668. */
  47669. gammaSpace: boolean;
  47670. }
  47671. /**
  47672. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47673. */
  47674. export class PanoramaToCubeMapTools {
  47675. private static FACE_FRONT;
  47676. private static FACE_BACK;
  47677. private static FACE_RIGHT;
  47678. private static FACE_LEFT;
  47679. private static FACE_DOWN;
  47680. private static FACE_UP;
  47681. /**
  47682. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47683. *
  47684. * @param float32Array The source data.
  47685. * @param inputWidth The width of the input panorama.
  47686. * @param inputHeight The height of the input panorama.
  47687. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47688. * @return The cubemap data
  47689. */
  47690. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47691. private static CreateCubemapTexture;
  47692. private static CalcProjectionSpherical;
  47693. }
  47694. }
  47695. declare module BABYLON {
  47696. /**
  47697. * Helper class dealing with the extraction of spherical polynomial dataArray
  47698. * from a cube map.
  47699. */
  47700. export class CubeMapToSphericalPolynomialTools {
  47701. private static FileFaces;
  47702. /**
  47703. * Converts a texture to the according Spherical Polynomial data.
  47704. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47705. *
  47706. * @param texture The texture to extract the information from.
  47707. * @return The Spherical Polynomial data.
  47708. */
  47709. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47710. /**
  47711. * Converts a cubemap to the according Spherical Polynomial data.
  47712. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47713. *
  47714. * @param cubeInfo The Cube map to extract the information from.
  47715. * @return The Spherical Polynomial data.
  47716. */
  47717. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47718. }
  47719. }
  47720. declare module BABYLON {
  47721. interface BaseTexture {
  47722. /**
  47723. * Get the polynomial representation of the texture data.
  47724. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47725. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47726. */
  47727. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47728. }
  47729. }
  47730. declare module BABYLON {
  47731. /** @hidden */
  47732. export var rgbdEncodePixelShader: {
  47733. name: string;
  47734. shader: string;
  47735. };
  47736. }
  47737. declare module BABYLON {
  47738. /** @hidden */
  47739. export var rgbdDecodePixelShader: {
  47740. name: string;
  47741. shader: string;
  47742. };
  47743. }
  47744. declare module BABYLON {
  47745. /**
  47746. * Raw texture data and descriptor sufficient for WebGL texture upload
  47747. */
  47748. export interface EnvironmentTextureInfo {
  47749. /**
  47750. * Version of the environment map
  47751. */
  47752. version: number;
  47753. /**
  47754. * Width of image
  47755. */
  47756. width: number;
  47757. /**
  47758. * Irradiance information stored in the file.
  47759. */
  47760. irradiance: any;
  47761. /**
  47762. * Specular information stored in the file.
  47763. */
  47764. specular: any;
  47765. }
  47766. /**
  47767. * Defines One Image in the file. It requires only the position in the file
  47768. * as well as the length.
  47769. */
  47770. interface BufferImageData {
  47771. /**
  47772. * Length of the image data.
  47773. */
  47774. length: number;
  47775. /**
  47776. * Position of the data from the null terminator delimiting the end of the JSON.
  47777. */
  47778. position: number;
  47779. }
  47780. /**
  47781. * Defines the specular data enclosed in the file.
  47782. * This corresponds to the version 1 of the data.
  47783. */
  47784. export interface EnvironmentTextureSpecularInfoV1 {
  47785. /**
  47786. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47787. */
  47788. specularDataPosition?: number;
  47789. /**
  47790. * This contains all the images data needed to reconstruct the cubemap.
  47791. */
  47792. mipmaps: Array<BufferImageData>;
  47793. /**
  47794. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47795. */
  47796. lodGenerationScale: number;
  47797. }
  47798. /**
  47799. * Sets of helpers addressing the serialization and deserialization of environment texture
  47800. * stored in a BabylonJS env file.
  47801. * Those files are usually stored as .env files.
  47802. */
  47803. export class EnvironmentTextureTools {
  47804. /**
  47805. * Magic number identifying the env file.
  47806. */
  47807. private static _MagicBytes;
  47808. /**
  47809. * Gets the environment info from an env file.
  47810. * @param data The array buffer containing the .env bytes.
  47811. * @returns the environment file info (the json header) if successfully parsed.
  47812. */
  47813. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  47814. /**
  47815. * Creates an environment texture from a loaded cube texture.
  47816. * @param texture defines the cube texture to convert in env file
  47817. * @return a promise containing the environment data if succesfull.
  47818. */
  47819. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47820. /**
  47821. * Creates a JSON representation of the spherical data.
  47822. * @param texture defines the texture containing the polynomials
  47823. * @return the JSON representation of the spherical info
  47824. */
  47825. private static _CreateEnvTextureIrradiance;
  47826. /**
  47827. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47828. * @param data the image data
  47829. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47830. * @return the views described by info providing access to the underlying buffer
  47831. */
  47832. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47833. /**
  47834. * Uploads the texture info contained in the env file to the GPU.
  47835. * @param texture defines the internal texture to upload to
  47836. * @param data defines the data to load
  47837. * @param info defines the texture info retrieved through the GetEnvInfo method
  47838. * @returns a promise
  47839. */
  47840. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  47841. private static _OnImageReadyAsync;
  47842. /**
  47843. * Uploads the levels of image data to the GPU.
  47844. * @param texture defines the internal texture to upload to
  47845. * @param imageData defines the array buffer views of image data [mipmap][face]
  47846. * @returns a promise
  47847. */
  47848. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47849. /**
  47850. * Uploads spherical polynomials information to the texture.
  47851. * @param texture defines the texture we are trying to upload the information to
  47852. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47853. */
  47854. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47855. /** @hidden */
  47856. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47857. }
  47858. }
  47859. declare module BABYLON {
  47860. /**
  47861. * Contains position and normal vectors for a vertex
  47862. */
  47863. export class PositionNormalVertex {
  47864. /** the position of the vertex (defaut: 0,0,0) */
  47865. position: Vector3;
  47866. /** the normal of the vertex (defaut: 0,1,0) */
  47867. normal: Vector3;
  47868. /**
  47869. * Creates a PositionNormalVertex
  47870. * @param position the position of the vertex (defaut: 0,0,0)
  47871. * @param normal the normal of the vertex (defaut: 0,1,0)
  47872. */
  47873. constructor(
  47874. /** the position of the vertex (defaut: 0,0,0) */
  47875. position?: Vector3,
  47876. /** the normal of the vertex (defaut: 0,1,0) */
  47877. normal?: Vector3);
  47878. /**
  47879. * Clones the PositionNormalVertex
  47880. * @returns the cloned PositionNormalVertex
  47881. */
  47882. clone(): PositionNormalVertex;
  47883. }
  47884. /**
  47885. * Contains position, normal and uv vectors for a vertex
  47886. */
  47887. export class PositionNormalTextureVertex {
  47888. /** the position of the vertex (defaut: 0,0,0) */
  47889. position: Vector3;
  47890. /** the normal of the vertex (defaut: 0,1,0) */
  47891. normal: Vector3;
  47892. /** the uv of the vertex (default: 0,0) */
  47893. uv: Vector2;
  47894. /**
  47895. * Creates a PositionNormalTextureVertex
  47896. * @param position the position of the vertex (defaut: 0,0,0)
  47897. * @param normal the normal of the vertex (defaut: 0,1,0)
  47898. * @param uv the uv of the vertex (default: 0,0)
  47899. */
  47900. constructor(
  47901. /** the position of the vertex (defaut: 0,0,0) */
  47902. position?: Vector3,
  47903. /** the normal of the vertex (defaut: 0,1,0) */
  47904. normal?: Vector3,
  47905. /** the uv of the vertex (default: 0,0) */
  47906. uv?: Vector2);
  47907. /**
  47908. * Clones the PositionNormalTextureVertex
  47909. * @returns the cloned PositionNormalTextureVertex
  47910. */
  47911. clone(): PositionNormalTextureVertex;
  47912. }
  47913. }
  47914. declare module BABYLON {
  47915. /** @hidden */
  47916. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47917. private _genericAttributeLocation;
  47918. private _varyingLocationCount;
  47919. private _varyingLocationMap;
  47920. private _replacements;
  47921. private _textureCount;
  47922. private _uniforms;
  47923. lineProcessor(line: string): string;
  47924. attributeProcessor(attribute: string): string;
  47925. varyingProcessor(varying: string, isFragment: boolean): string;
  47926. uniformProcessor(uniform: string): string;
  47927. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47928. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47929. }
  47930. }
  47931. declare module BABYLON {
  47932. /**
  47933. * Container for accessors for natively-stored mesh data buffers.
  47934. */
  47935. class NativeDataBuffer extends DataBuffer {
  47936. /**
  47937. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47938. */
  47939. nativeIndexBuffer?: any;
  47940. /**
  47941. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47942. */
  47943. nativeVertexBuffer?: any;
  47944. }
  47945. /** @hidden */
  47946. class NativeTexture extends InternalTexture {
  47947. getInternalTexture(): InternalTexture;
  47948. getViewCount(): number;
  47949. }
  47950. /** @hidden */
  47951. export class NativeEngine extends Engine {
  47952. private readonly _native;
  47953. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47954. private readonly INVALID_HANDLE;
  47955. getHardwareScalingLevel(): number;
  47956. constructor();
  47957. /**
  47958. * Can be used to override the current requestAnimationFrame requester.
  47959. * @hidden
  47960. */
  47961. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47962. /**
  47963. * Override default engine behavior.
  47964. * @param color
  47965. * @param backBuffer
  47966. * @param depth
  47967. * @param stencil
  47968. */
  47969. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  47970. /**
  47971. * Gets host document
  47972. * @returns the host document object
  47973. */
  47974. getHostDocument(): Nullable<Document>;
  47975. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47976. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  47977. createVertexBuffer(data: DataArray): NativeDataBuffer;
  47978. recordVertexArrayObject(vertexBuffers: {
  47979. [key: string]: VertexBuffer;
  47980. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  47981. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47982. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47983. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47984. /**
  47985. * Draw a list of indexed primitives
  47986. * @param fillMode defines the primitive to use
  47987. * @param indexStart defines the starting index
  47988. * @param indexCount defines the number of index to draw
  47989. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47990. */
  47991. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47992. /**
  47993. * Draw a list of unindexed primitives
  47994. * @param fillMode defines the primitive to use
  47995. * @param verticesStart defines the index of first vertex to draw
  47996. * @param verticesCount defines the count of vertices to draw
  47997. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47998. */
  47999. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48000. createPipelineContext(): IPipelineContext;
  48001. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  48002. /** @hidden */
  48003. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  48004. /** @hidden */
  48005. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  48006. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48007. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48008. protected _setProgram(program: WebGLProgram): void;
  48009. _releaseEffect(effect: Effect): void;
  48010. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  48011. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  48012. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  48013. bindSamplers(effect: Effect): void;
  48014. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  48015. getRenderWidth(useScreen?: boolean): number;
  48016. getRenderHeight(useScreen?: boolean): number;
  48017. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  48018. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48019. /**
  48020. * Set the z offset to apply to current rendering
  48021. * @param value defines the offset to apply
  48022. */
  48023. setZOffset(value: number): void;
  48024. /**
  48025. * Gets the current value of the zOffset
  48026. * @returns the current zOffset state
  48027. */
  48028. getZOffset(): number;
  48029. /**
  48030. * Enable or disable depth buffering
  48031. * @param enable defines the state to set
  48032. */
  48033. setDepthBuffer(enable: boolean): void;
  48034. /**
  48035. * Gets a boolean indicating if depth writing is enabled
  48036. * @returns the current depth writing state
  48037. */
  48038. getDepthWrite(): boolean;
  48039. /**
  48040. * Enable or disable depth writing
  48041. * @param enable defines the state to set
  48042. */
  48043. setDepthWrite(enable: boolean): void;
  48044. /**
  48045. * Enable or disable color writing
  48046. * @param enable defines the state to set
  48047. */
  48048. setColorWrite(enable: boolean): void;
  48049. /**
  48050. * Gets a boolean indicating if color writing is enabled
  48051. * @returns the current color writing state
  48052. */
  48053. getColorWrite(): boolean;
  48054. /**
  48055. * Sets alpha constants used by some alpha blending modes
  48056. * @param r defines the red component
  48057. * @param g defines the green component
  48058. * @param b defines the blue component
  48059. * @param a defines the alpha component
  48060. */
  48061. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  48062. /**
  48063. * Sets the current alpha mode
  48064. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  48065. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48066. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48067. */
  48068. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48069. /**
  48070. * Gets the current alpha mode
  48071. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48072. * @returns the current alpha mode
  48073. */
  48074. getAlphaMode(): number;
  48075. setInt(uniform: WebGLUniformLocation, int: number): void;
  48076. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48077. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48078. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48079. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48080. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48081. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48082. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48083. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48084. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48085. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48086. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48087. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48088. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48089. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48090. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48091. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48092. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48093. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48094. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48095. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  48096. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  48097. wipeCaches(bruteForce?: boolean): void;
  48098. _createTexture(): WebGLTexture;
  48099. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  48100. /**
  48101. * Usually called from Texture.ts.
  48102. * Passed information to create a WebGLTexture
  48103. * @param urlArg defines a value which contains one of the following:
  48104. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48105. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48106. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48107. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48108. * @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)
  48109. * @param scene needed for loading to the correct scene
  48110. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48111. * @param onLoad optional callback to be called upon successful completion
  48112. * @param onError optional callback to be called upon failure
  48113. * @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
  48114. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48115. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48116. * @param forcedExtension defines the extension to use to pick the right loader
  48117. * @param mimeType defines an optional mime type
  48118. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48119. */
  48120. 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;
  48121. /**
  48122. * Creates a cube texture
  48123. * @param rootUrl defines the url where the files to load is located
  48124. * @param scene defines the current scene
  48125. * @param files defines the list of files to load (1 per face)
  48126. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  48127. * @param onLoad defines an optional callback raised when the texture is loaded
  48128. * @param onError defines an optional callback raised if there is an issue to load the texture
  48129. * @param format defines the format of the data
  48130. * @param forcedExtension defines the extension to use to pick the right loader
  48131. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  48132. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48133. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48134. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  48135. * @returns the cube texture as an InternalTexture
  48136. */
  48137. 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;
  48138. private _getSamplingFilter;
  48139. private static _GetNativeTextureFormat;
  48140. createRenderTargetTexture(size: number | {
  48141. width: number;
  48142. height: number;
  48143. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  48144. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48145. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48146. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48147. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  48148. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  48149. /**
  48150. * Updates a dynamic vertex buffer.
  48151. * @param vertexBuffer the vertex buffer to update
  48152. * @param data the data used to update the vertex buffer
  48153. * @param byteOffset the byte offset of the data (optional)
  48154. * @param byteLength the byte length of the data (optional)
  48155. */
  48156. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  48157. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  48158. private _updateAnisotropicLevel;
  48159. private _getAddressMode;
  48160. /** @hidden */
  48161. _bindTexture(channel: number, texture: InternalTexture): void;
  48162. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  48163. releaseEffects(): void;
  48164. /** @hidden */
  48165. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48166. /** @hidden */
  48167. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48168. /** @hidden */
  48169. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48170. /** @hidden */
  48171. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48172. }
  48173. }
  48174. declare module BABYLON {
  48175. /**
  48176. * Gather the list of clipboard event types as constants.
  48177. */
  48178. export class ClipboardEventTypes {
  48179. /**
  48180. * The clipboard event is fired when a copy command is active (pressed).
  48181. */
  48182. static readonly COPY: number;
  48183. /**
  48184. * The clipboard event is fired when a cut command is active (pressed).
  48185. */
  48186. static readonly CUT: number;
  48187. /**
  48188. * The clipboard event is fired when a paste command is active (pressed).
  48189. */
  48190. static readonly PASTE: number;
  48191. }
  48192. /**
  48193. * This class is used to store clipboard related info for the onClipboardObservable event.
  48194. */
  48195. export class ClipboardInfo {
  48196. /**
  48197. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48198. */
  48199. type: number;
  48200. /**
  48201. * Defines the related dom event
  48202. */
  48203. event: ClipboardEvent;
  48204. /**
  48205. *Creates an instance of ClipboardInfo.
  48206. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  48207. * @param event Defines the related dom event
  48208. */
  48209. constructor(
  48210. /**
  48211. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48212. */
  48213. type: number,
  48214. /**
  48215. * Defines the related dom event
  48216. */
  48217. event: ClipboardEvent);
  48218. /**
  48219. * Get the clipboard event's type from the keycode.
  48220. * @param keyCode Defines the keyCode for the current keyboard event.
  48221. * @return {number}
  48222. */
  48223. static GetTypeFromCharacter(keyCode: number): number;
  48224. }
  48225. }
  48226. declare module BABYLON {
  48227. /**
  48228. * Google Daydream controller
  48229. */
  48230. export class DaydreamController extends WebVRController {
  48231. /**
  48232. * Base Url for the controller model.
  48233. */
  48234. static MODEL_BASE_URL: string;
  48235. /**
  48236. * File name for the controller model.
  48237. */
  48238. static MODEL_FILENAME: string;
  48239. /**
  48240. * Gamepad Id prefix used to identify Daydream Controller.
  48241. */
  48242. static readonly GAMEPAD_ID_PREFIX: string;
  48243. /**
  48244. * Creates a new DaydreamController from a gamepad
  48245. * @param vrGamepad the gamepad that the controller should be created from
  48246. */
  48247. constructor(vrGamepad: any);
  48248. /**
  48249. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48250. * @param scene scene in which to add meshes
  48251. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48252. */
  48253. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48254. /**
  48255. * Called once for each button that changed state since the last frame
  48256. * @param buttonIdx Which button index changed
  48257. * @param state New state of the button
  48258. * @param changes Which properties on the state changed since last frame
  48259. */
  48260. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48261. }
  48262. }
  48263. declare module BABYLON {
  48264. /**
  48265. * Gear VR Controller
  48266. */
  48267. export class GearVRController extends WebVRController {
  48268. /**
  48269. * Base Url for the controller model.
  48270. */
  48271. static MODEL_BASE_URL: string;
  48272. /**
  48273. * File name for the controller model.
  48274. */
  48275. static MODEL_FILENAME: string;
  48276. /**
  48277. * Gamepad Id prefix used to identify this controller.
  48278. */
  48279. static readonly GAMEPAD_ID_PREFIX: string;
  48280. private readonly _buttonIndexToObservableNameMap;
  48281. /**
  48282. * Creates a new GearVRController from a gamepad
  48283. * @param vrGamepad the gamepad that the controller should be created from
  48284. */
  48285. constructor(vrGamepad: any);
  48286. /**
  48287. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48288. * @param scene scene in which to add meshes
  48289. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48290. */
  48291. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48292. /**
  48293. * Called once for each button that changed state since the last frame
  48294. * @param buttonIdx Which button index changed
  48295. * @param state New state of the button
  48296. * @param changes Which properties on the state changed since last frame
  48297. */
  48298. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48299. }
  48300. }
  48301. declare module BABYLON {
  48302. /**
  48303. * Generic Controller
  48304. */
  48305. export class GenericController extends WebVRController {
  48306. /**
  48307. * Base Url for the controller model.
  48308. */
  48309. static readonly MODEL_BASE_URL: string;
  48310. /**
  48311. * File name for the controller model.
  48312. */
  48313. static readonly MODEL_FILENAME: string;
  48314. /**
  48315. * Creates a new GenericController from a gamepad
  48316. * @param vrGamepad the gamepad that the controller should be created from
  48317. */
  48318. constructor(vrGamepad: any);
  48319. /**
  48320. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48321. * @param scene scene in which to add meshes
  48322. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48323. */
  48324. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48325. /**
  48326. * Called once for each button that changed state since the last frame
  48327. * @param buttonIdx Which button index changed
  48328. * @param state New state of the button
  48329. * @param changes Which properties on the state changed since last frame
  48330. */
  48331. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48332. }
  48333. }
  48334. declare module BABYLON {
  48335. /**
  48336. * Oculus Touch Controller
  48337. */
  48338. export class OculusTouchController extends WebVRController {
  48339. /**
  48340. * Base Url for the controller model.
  48341. */
  48342. static MODEL_BASE_URL: string;
  48343. /**
  48344. * File name for the left controller model.
  48345. */
  48346. static MODEL_LEFT_FILENAME: string;
  48347. /**
  48348. * File name for the right controller model.
  48349. */
  48350. static MODEL_RIGHT_FILENAME: string;
  48351. /**
  48352. * Base Url for the Quest controller model.
  48353. */
  48354. static QUEST_MODEL_BASE_URL: string;
  48355. /**
  48356. * @hidden
  48357. * If the controllers are running on a device that needs the updated Quest controller models
  48358. */
  48359. static _IsQuest: boolean;
  48360. /**
  48361. * Fired when the secondary trigger on this controller is modified
  48362. */
  48363. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  48364. /**
  48365. * Fired when the thumb rest on this controller is modified
  48366. */
  48367. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  48368. /**
  48369. * Creates a new OculusTouchController from a gamepad
  48370. * @param vrGamepad the gamepad that the controller should be created from
  48371. */
  48372. constructor(vrGamepad: any);
  48373. /**
  48374. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48375. * @param scene scene in which to add meshes
  48376. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48377. */
  48378. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48379. /**
  48380. * Fired when the A button on this controller is modified
  48381. */
  48382. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48383. /**
  48384. * Fired when the B button on this controller is modified
  48385. */
  48386. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48387. /**
  48388. * Fired when the X button on this controller is modified
  48389. */
  48390. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48391. /**
  48392. * Fired when the Y button on this controller is modified
  48393. */
  48394. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48395. /**
  48396. * Called once for each button that changed state since the last frame
  48397. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  48398. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  48399. * 2) secondary trigger (same)
  48400. * 3) A (right) X (left), touch, pressed = value
  48401. * 4) B / Y
  48402. * 5) thumb rest
  48403. * @param buttonIdx Which button index changed
  48404. * @param state New state of the button
  48405. * @param changes Which properties on the state changed since last frame
  48406. */
  48407. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48408. }
  48409. }
  48410. declare module BABYLON {
  48411. /**
  48412. * Vive Controller
  48413. */
  48414. export class ViveController extends WebVRController {
  48415. /**
  48416. * Base Url for the controller model.
  48417. */
  48418. static MODEL_BASE_URL: string;
  48419. /**
  48420. * File name for the controller model.
  48421. */
  48422. static MODEL_FILENAME: string;
  48423. /**
  48424. * Creates a new ViveController from a gamepad
  48425. * @param vrGamepad the gamepad that the controller should be created from
  48426. */
  48427. constructor(vrGamepad: any);
  48428. /**
  48429. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48430. * @param scene scene in which to add meshes
  48431. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48432. */
  48433. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48434. /**
  48435. * Fired when the left button on this controller is modified
  48436. */
  48437. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48438. /**
  48439. * Fired when the right button on this controller is modified
  48440. */
  48441. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48442. /**
  48443. * Fired when the menu button on this controller is modified
  48444. */
  48445. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48446. /**
  48447. * Called once for each button that changed state since the last frame
  48448. * Vive mapping:
  48449. * 0: touchpad
  48450. * 1: trigger
  48451. * 2: left AND right buttons
  48452. * 3: menu button
  48453. * @param buttonIdx Which button index changed
  48454. * @param state New state of the button
  48455. * @param changes Which properties on the state changed since last frame
  48456. */
  48457. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48458. }
  48459. }
  48460. declare module BABYLON {
  48461. /**
  48462. * Defines the WindowsMotionController object that the state of the windows motion controller
  48463. */
  48464. export class WindowsMotionController extends WebVRController {
  48465. /**
  48466. * The base url used to load the left and right controller models
  48467. */
  48468. static MODEL_BASE_URL: string;
  48469. /**
  48470. * The name of the left controller model file
  48471. */
  48472. static MODEL_LEFT_FILENAME: string;
  48473. /**
  48474. * The name of the right controller model file
  48475. */
  48476. static MODEL_RIGHT_FILENAME: string;
  48477. /**
  48478. * The controller name prefix for this controller type
  48479. */
  48480. static readonly GAMEPAD_ID_PREFIX: string;
  48481. /**
  48482. * The controller id pattern for this controller type
  48483. */
  48484. private static readonly GAMEPAD_ID_PATTERN;
  48485. private _loadedMeshInfo;
  48486. protected readonly _mapping: {
  48487. buttons: string[];
  48488. buttonMeshNames: {
  48489. 'trigger': string;
  48490. 'menu': string;
  48491. 'grip': string;
  48492. 'thumbstick': string;
  48493. 'trackpad': string;
  48494. };
  48495. buttonObservableNames: {
  48496. 'trigger': string;
  48497. 'menu': string;
  48498. 'grip': string;
  48499. 'thumbstick': string;
  48500. 'trackpad': string;
  48501. };
  48502. axisMeshNames: string[];
  48503. pointingPoseMeshName: string;
  48504. };
  48505. /**
  48506. * Fired when the trackpad on this controller is clicked
  48507. */
  48508. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48509. /**
  48510. * Fired when the trackpad on this controller is modified
  48511. */
  48512. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48513. /**
  48514. * The current x and y values of this controller's trackpad
  48515. */
  48516. trackpad: StickValues;
  48517. /**
  48518. * Creates a new WindowsMotionController from a gamepad
  48519. * @param vrGamepad the gamepad that the controller should be created from
  48520. */
  48521. constructor(vrGamepad: any);
  48522. /**
  48523. * Fired when the trigger on this controller is modified
  48524. */
  48525. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48526. /**
  48527. * Fired when the menu button on this controller is modified
  48528. */
  48529. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48530. /**
  48531. * Fired when the grip button on this controller is modified
  48532. */
  48533. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48534. /**
  48535. * Fired when the thumbstick button on this controller is modified
  48536. */
  48537. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48538. /**
  48539. * Fired when the touchpad button on this controller is modified
  48540. */
  48541. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48542. /**
  48543. * Fired when the touchpad values on this controller are modified
  48544. */
  48545. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48546. protected _updateTrackpad(): void;
  48547. /**
  48548. * Called once per frame by the engine.
  48549. */
  48550. update(): void;
  48551. /**
  48552. * Called once for each button that changed state since the last frame
  48553. * @param buttonIdx Which button index changed
  48554. * @param state New state of the button
  48555. * @param changes Which properties on the state changed since last frame
  48556. */
  48557. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48558. /**
  48559. * Moves the buttons on the controller mesh based on their current state
  48560. * @param buttonName the name of the button to move
  48561. * @param buttonValue the value of the button which determines the buttons new position
  48562. */
  48563. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48564. /**
  48565. * Moves the axis on the controller mesh based on its current state
  48566. * @param axis the index of the axis
  48567. * @param axisValue the value of the axis which determines the meshes new position
  48568. * @hidden
  48569. */
  48570. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48571. /**
  48572. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48573. * @param scene scene in which to add meshes
  48574. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48575. */
  48576. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48577. /**
  48578. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48579. * can be transformed by button presses and axes values, based on this._mapping.
  48580. *
  48581. * @param scene scene in which the meshes exist
  48582. * @param meshes list of meshes that make up the controller model to process
  48583. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48584. */
  48585. private processModel;
  48586. private createMeshInfo;
  48587. /**
  48588. * Gets the ray of the controller in the direction the controller is pointing
  48589. * @param length the length the resulting ray should be
  48590. * @returns a ray in the direction the controller is pointing
  48591. */
  48592. getForwardRay(length?: number): Ray;
  48593. /**
  48594. * Disposes of the controller
  48595. */
  48596. dispose(): void;
  48597. }
  48598. /**
  48599. * This class represents a new windows motion controller in XR.
  48600. */
  48601. export class XRWindowsMotionController extends WindowsMotionController {
  48602. /**
  48603. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48604. */
  48605. protected readonly _mapping: {
  48606. buttons: string[];
  48607. buttonMeshNames: {
  48608. 'trigger': string;
  48609. 'menu': string;
  48610. 'grip': string;
  48611. 'thumbstick': string;
  48612. 'trackpad': string;
  48613. };
  48614. buttonObservableNames: {
  48615. 'trigger': string;
  48616. 'menu': string;
  48617. 'grip': string;
  48618. 'thumbstick': string;
  48619. 'trackpad': string;
  48620. };
  48621. axisMeshNames: string[];
  48622. pointingPoseMeshName: string;
  48623. };
  48624. /**
  48625. * Construct a new XR-Based windows motion controller
  48626. *
  48627. * @param gamepadInfo the gamepad object from the browser
  48628. */
  48629. constructor(gamepadInfo: any);
  48630. /**
  48631. * holds the thumbstick values (X,Y)
  48632. */
  48633. thumbstickValues: StickValues;
  48634. /**
  48635. * Fired when the thumbstick on this controller is clicked
  48636. */
  48637. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48638. /**
  48639. * Fired when the thumbstick on this controller is modified
  48640. */
  48641. onThumbstickValuesChangedObservable: Observable<StickValues>;
  48642. /**
  48643. * Fired when the touchpad button on this controller is modified
  48644. */
  48645. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48646. /**
  48647. * Fired when the touchpad values on this controller are modified
  48648. */
  48649. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48650. /**
  48651. * Fired when the thumbstick button on this controller is modified
  48652. * here to prevent breaking changes
  48653. */
  48654. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48655. /**
  48656. * updating the thumbstick(!) and not the trackpad.
  48657. * This is named this way due to the difference between WebVR and XR and to avoid
  48658. * changing the parent class.
  48659. */
  48660. protected _updateTrackpad(): void;
  48661. /**
  48662. * Disposes the class with joy
  48663. */
  48664. dispose(): void;
  48665. }
  48666. }
  48667. declare module BABYLON {
  48668. /**
  48669. * Class containing static functions to help procedurally build meshes
  48670. */
  48671. export class PolyhedronBuilder {
  48672. /**
  48673. * Creates a polyhedron mesh
  48674. * * 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
  48675. * * The parameter `size` (positive float, default 1) sets the polygon size
  48676. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48677. * * 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`
  48678. * * 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
  48679. * * 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)`)
  48680. * * 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
  48681. * * 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
  48682. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48683. * * 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
  48684. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48685. * @param name defines the name of the mesh
  48686. * @param options defines the options used to create the mesh
  48687. * @param scene defines the hosting scene
  48688. * @returns the polyhedron mesh
  48689. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48690. */
  48691. static CreatePolyhedron(name: string, options: {
  48692. type?: number;
  48693. size?: number;
  48694. sizeX?: number;
  48695. sizeY?: number;
  48696. sizeZ?: number;
  48697. custom?: any;
  48698. faceUV?: Vector4[];
  48699. faceColors?: Color4[];
  48700. flat?: boolean;
  48701. updatable?: boolean;
  48702. sideOrientation?: number;
  48703. frontUVs?: Vector4;
  48704. backUVs?: Vector4;
  48705. }, scene?: Nullable<Scene>): Mesh;
  48706. }
  48707. }
  48708. declare module BABYLON {
  48709. /**
  48710. * Gizmo that enables scaling a mesh along 3 axis
  48711. */
  48712. export class ScaleGizmo extends Gizmo {
  48713. /**
  48714. * Internal gizmo used for interactions on the x axis
  48715. */
  48716. xGizmo: AxisScaleGizmo;
  48717. /**
  48718. * Internal gizmo used for interactions on the y axis
  48719. */
  48720. yGizmo: AxisScaleGizmo;
  48721. /**
  48722. * Internal gizmo used for interactions on the z axis
  48723. */
  48724. zGizmo: AxisScaleGizmo;
  48725. /**
  48726. * Internal gizmo used to scale all axis equally
  48727. */
  48728. uniformScaleGizmo: AxisScaleGizmo;
  48729. private _meshAttached;
  48730. private _updateGizmoRotationToMatchAttachedMesh;
  48731. private _snapDistance;
  48732. private _scaleRatio;
  48733. private _uniformScalingMesh;
  48734. private _octahedron;
  48735. private _sensitivity;
  48736. /** Fires an event when any of it's sub gizmos are dragged */
  48737. onDragStartObservable: Observable<unknown>;
  48738. /** Fires an event when any of it's sub gizmos are released from dragging */
  48739. onDragEndObservable: Observable<unknown>;
  48740. get attachedMesh(): Nullable<AbstractMesh>;
  48741. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48742. /**
  48743. * Creates a ScaleGizmo
  48744. * @param gizmoLayer The utility layer the gizmo will be added to
  48745. */
  48746. constructor(gizmoLayer?: UtilityLayerRenderer);
  48747. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48748. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48749. /**
  48750. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48751. */
  48752. set snapDistance(value: number);
  48753. get snapDistance(): number;
  48754. /**
  48755. * Ratio for the scale of the gizmo (Default: 1)
  48756. */
  48757. set scaleRatio(value: number);
  48758. get scaleRatio(): number;
  48759. /**
  48760. * Sensitivity factor for dragging (Default: 1)
  48761. */
  48762. set sensitivity(value: number);
  48763. get sensitivity(): number;
  48764. /**
  48765. * Disposes of the gizmo
  48766. */
  48767. dispose(): void;
  48768. }
  48769. }
  48770. declare module BABYLON {
  48771. /**
  48772. * Single axis scale gizmo
  48773. */
  48774. export class AxisScaleGizmo extends Gizmo {
  48775. /**
  48776. * Drag behavior responsible for the gizmos dragging interactions
  48777. */
  48778. dragBehavior: PointerDragBehavior;
  48779. private _pointerObserver;
  48780. /**
  48781. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48782. */
  48783. snapDistance: number;
  48784. /**
  48785. * Event that fires each time the gizmo snaps to a new location.
  48786. * * snapDistance is the the change in distance
  48787. */
  48788. onSnapObservable: Observable<{
  48789. snapDistance: number;
  48790. }>;
  48791. /**
  48792. * If the scaling operation should be done on all axis (default: false)
  48793. */
  48794. uniformScaling: boolean;
  48795. /**
  48796. * Custom sensitivity value for the drag strength
  48797. */
  48798. sensitivity: number;
  48799. private _isEnabled;
  48800. private _parent;
  48801. private _arrow;
  48802. private _coloredMaterial;
  48803. private _hoverMaterial;
  48804. /**
  48805. * Creates an AxisScaleGizmo
  48806. * @param gizmoLayer The utility layer the gizmo will be added to
  48807. * @param dragAxis The axis which the gizmo will be able to scale on
  48808. * @param color The color of the gizmo
  48809. */
  48810. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48811. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48812. /**
  48813. * If the gizmo is enabled
  48814. */
  48815. set isEnabled(value: boolean);
  48816. get isEnabled(): boolean;
  48817. /**
  48818. * Disposes of the gizmo
  48819. */
  48820. dispose(): void;
  48821. /**
  48822. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48823. * @param mesh The mesh to replace the default mesh of the gizmo
  48824. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48825. */
  48826. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48827. }
  48828. }
  48829. declare module BABYLON {
  48830. /**
  48831. * Bounding box gizmo
  48832. */
  48833. export class BoundingBoxGizmo extends Gizmo {
  48834. private _lineBoundingBox;
  48835. private _rotateSpheresParent;
  48836. private _scaleBoxesParent;
  48837. private _boundingDimensions;
  48838. private _renderObserver;
  48839. private _pointerObserver;
  48840. private _scaleDragSpeed;
  48841. private _tmpQuaternion;
  48842. private _tmpVector;
  48843. private _tmpRotationMatrix;
  48844. /**
  48845. * 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)
  48846. */
  48847. ignoreChildren: boolean;
  48848. /**
  48849. * 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)
  48850. */
  48851. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  48852. /**
  48853. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  48854. */
  48855. rotationSphereSize: number;
  48856. /**
  48857. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  48858. */
  48859. scaleBoxSize: number;
  48860. /**
  48861. * 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)
  48862. */
  48863. fixedDragMeshScreenSize: boolean;
  48864. /**
  48865. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  48866. */
  48867. fixedDragMeshScreenSizeDistanceFactor: number;
  48868. /**
  48869. * Fired when a rotation sphere or scale box is dragged
  48870. */
  48871. onDragStartObservable: Observable<{}>;
  48872. /**
  48873. * Fired when a scale box is dragged
  48874. */
  48875. onScaleBoxDragObservable: Observable<{}>;
  48876. /**
  48877. * Fired when a scale box drag is ended
  48878. */
  48879. onScaleBoxDragEndObservable: Observable<{}>;
  48880. /**
  48881. * Fired when a rotation sphere is dragged
  48882. */
  48883. onRotationSphereDragObservable: Observable<{}>;
  48884. /**
  48885. * Fired when a rotation sphere drag is ended
  48886. */
  48887. onRotationSphereDragEndObservable: Observable<{}>;
  48888. /**
  48889. * 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)
  48890. */
  48891. scalePivot: Nullable<Vector3>;
  48892. /**
  48893. * Mesh used as a pivot to rotate the attached mesh
  48894. */
  48895. private _anchorMesh;
  48896. private _existingMeshScale;
  48897. private _dragMesh;
  48898. private pointerDragBehavior;
  48899. private coloredMaterial;
  48900. private hoverColoredMaterial;
  48901. /**
  48902. * Sets the color of the bounding box gizmo
  48903. * @param color the color to set
  48904. */
  48905. setColor(color: Color3): void;
  48906. /**
  48907. * Creates an BoundingBoxGizmo
  48908. * @param gizmoLayer The utility layer the gizmo will be added to
  48909. * @param color The color of the gizmo
  48910. */
  48911. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  48912. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48913. private _selectNode;
  48914. /**
  48915. * Updates the bounding box information for the Gizmo
  48916. */
  48917. updateBoundingBox(): void;
  48918. private _updateRotationSpheres;
  48919. private _updateScaleBoxes;
  48920. /**
  48921. * Enables rotation on the specified axis and disables rotation on the others
  48922. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  48923. */
  48924. setEnabledRotationAxis(axis: string): void;
  48925. /**
  48926. * Enables/disables scaling
  48927. * @param enable if scaling should be enabled
  48928. * @param homogeneousScaling defines if scaling should only be homogeneous
  48929. */
  48930. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  48931. private _updateDummy;
  48932. /**
  48933. * Enables a pointer drag behavior on the bounding box of the gizmo
  48934. */
  48935. enableDragBehavior(): void;
  48936. /**
  48937. * Disposes of the gizmo
  48938. */
  48939. dispose(): void;
  48940. /**
  48941. * 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)
  48942. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  48943. * @returns the bounding box mesh with the passed in mesh as a child
  48944. */
  48945. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  48946. /**
  48947. * CustomMeshes are not supported by this gizmo
  48948. * @param mesh The mesh to replace the default mesh of the gizmo
  48949. */
  48950. setCustomMesh(mesh: Mesh): void;
  48951. }
  48952. }
  48953. declare module BABYLON {
  48954. /**
  48955. * Single plane rotation gizmo
  48956. */
  48957. export class PlaneRotationGizmo extends Gizmo {
  48958. /**
  48959. * Drag behavior responsible for the gizmos dragging interactions
  48960. */
  48961. dragBehavior: PointerDragBehavior;
  48962. private _pointerObserver;
  48963. /**
  48964. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  48965. */
  48966. snapDistance: number;
  48967. /**
  48968. * Event that fires each time the gizmo snaps to a new location.
  48969. * * snapDistance is the the change in distance
  48970. */
  48971. onSnapObservable: Observable<{
  48972. snapDistance: number;
  48973. }>;
  48974. private _isEnabled;
  48975. private _parent;
  48976. /**
  48977. * Creates a PlaneRotationGizmo
  48978. * @param gizmoLayer The utility layer the gizmo will be added to
  48979. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  48980. * @param color The color of the gizmo
  48981. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48982. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48983. */
  48984. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  48985. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48986. /**
  48987. * If the gizmo is enabled
  48988. */
  48989. set isEnabled(value: boolean);
  48990. get isEnabled(): boolean;
  48991. /**
  48992. * Disposes of the gizmo
  48993. */
  48994. dispose(): void;
  48995. }
  48996. }
  48997. declare module BABYLON {
  48998. /**
  48999. * Gizmo that enables rotating a mesh along 3 axis
  49000. */
  49001. export class RotationGizmo extends Gizmo {
  49002. /**
  49003. * Internal gizmo used for interactions on the x axis
  49004. */
  49005. xGizmo: PlaneRotationGizmo;
  49006. /**
  49007. * Internal gizmo used for interactions on the y axis
  49008. */
  49009. yGizmo: PlaneRotationGizmo;
  49010. /**
  49011. * Internal gizmo used for interactions on the z axis
  49012. */
  49013. zGizmo: PlaneRotationGizmo;
  49014. /** Fires an event when any of it's sub gizmos are dragged */
  49015. onDragStartObservable: Observable<unknown>;
  49016. /** Fires an event when any of it's sub gizmos are released from dragging */
  49017. onDragEndObservable: Observable<unknown>;
  49018. private _meshAttached;
  49019. get attachedMesh(): Nullable<AbstractMesh>;
  49020. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49021. /**
  49022. * Creates a RotationGizmo
  49023. * @param gizmoLayer The utility layer the gizmo will be added to
  49024. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49025. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49026. */
  49027. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  49028. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49029. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49030. /**
  49031. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49032. */
  49033. set snapDistance(value: number);
  49034. get snapDistance(): number;
  49035. /**
  49036. * Ratio for the scale of the gizmo (Default: 1)
  49037. */
  49038. set scaleRatio(value: number);
  49039. get scaleRatio(): number;
  49040. /**
  49041. * Disposes of the gizmo
  49042. */
  49043. dispose(): void;
  49044. /**
  49045. * CustomMeshes are not supported by this gizmo
  49046. * @param mesh The mesh to replace the default mesh of the gizmo
  49047. */
  49048. setCustomMesh(mesh: Mesh): void;
  49049. }
  49050. }
  49051. declare module BABYLON {
  49052. /**
  49053. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  49054. */
  49055. export class GizmoManager implements IDisposable {
  49056. private scene;
  49057. /**
  49058. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  49059. */
  49060. gizmos: {
  49061. positionGizmo: Nullable<PositionGizmo>;
  49062. rotationGizmo: Nullable<RotationGizmo>;
  49063. scaleGizmo: Nullable<ScaleGizmo>;
  49064. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  49065. };
  49066. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  49067. clearGizmoOnEmptyPointerEvent: boolean;
  49068. /** Fires an event when the manager is attached to a mesh */
  49069. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  49070. private _gizmosEnabled;
  49071. private _pointerObserver;
  49072. private _attachedMesh;
  49073. private _boundingBoxColor;
  49074. private _defaultUtilityLayer;
  49075. private _defaultKeepDepthUtilityLayer;
  49076. /**
  49077. * When bounding box gizmo is enabled, this can be used to track drag/end events
  49078. */
  49079. boundingBoxDragBehavior: SixDofDragBehavior;
  49080. /**
  49081. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  49082. */
  49083. attachableMeshes: Nullable<Array<AbstractMesh>>;
  49084. /**
  49085. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  49086. */
  49087. usePointerToAttachGizmos: boolean;
  49088. /**
  49089. * Utility layer that the bounding box gizmo belongs to
  49090. */
  49091. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  49092. /**
  49093. * Utility layer that all gizmos besides bounding box belong to
  49094. */
  49095. get utilityLayer(): UtilityLayerRenderer;
  49096. /**
  49097. * Instatiates a gizmo manager
  49098. * @param scene the scene to overlay the gizmos on top of
  49099. */
  49100. constructor(scene: Scene);
  49101. /**
  49102. * Attaches a set of gizmos to the specified mesh
  49103. * @param mesh The mesh the gizmo's should be attached to
  49104. */
  49105. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49106. /**
  49107. * If the position gizmo is enabled
  49108. */
  49109. set positionGizmoEnabled(value: boolean);
  49110. get positionGizmoEnabled(): boolean;
  49111. /**
  49112. * If the rotation gizmo is enabled
  49113. */
  49114. set rotationGizmoEnabled(value: boolean);
  49115. get rotationGizmoEnabled(): boolean;
  49116. /**
  49117. * If the scale gizmo is enabled
  49118. */
  49119. set scaleGizmoEnabled(value: boolean);
  49120. get scaleGizmoEnabled(): boolean;
  49121. /**
  49122. * If the boundingBox gizmo is enabled
  49123. */
  49124. set boundingBoxGizmoEnabled(value: boolean);
  49125. get boundingBoxGizmoEnabled(): boolean;
  49126. /**
  49127. * Disposes of the gizmo manager
  49128. */
  49129. dispose(): void;
  49130. }
  49131. }
  49132. declare module BABYLON {
  49133. /**
  49134. * A directional light is defined by a direction (what a surprise!).
  49135. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  49136. * 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.
  49137. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49138. */
  49139. export class DirectionalLight extends ShadowLight {
  49140. private _shadowFrustumSize;
  49141. /**
  49142. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  49143. */
  49144. get shadowFrustumSize(): number;
  49145. /**
  49146. * Specifies a fix frustum size for the shadow generation.
  49147. */
  49148. set shadowFrustumSize(value: number);
  49149. private _shadowOrthoScale;
  49150. /**
  49151. * Gets the shadow projection scale against the optimal computed one.
  49152. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49153. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49154. */
  49155. get shadowOrthoScale(): number;
  49156. /**
  49157. * Sets the shadow projection scale against the optimal computed one.
  49158. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49159. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49160. */
  49161. set shadowOrthoScale(value: number);
  49162. /**
  49163. * Automatically compute the projection matrix to best fit (including all the casters)
  49164. * on each frame.
  49165. */
  49166. autoUpdateExtends: boolean;
  49167. /**
  49168. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  49169. * on each frame. autoUpdateExtends must be set to true for this to work
  49170. */
  49171. autoCalcShadowZBounds: boolean;
  49172. private _orthoLeft;
  49173. private _orthoRight;
  49174. private _orthoTop;
  49175. private _orthoBottom;
  49176. /**
  49177. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  49178. * The directional light is emitted from everywhere in the given direction.
  49179. * It can cast shadows.
  49180. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49181. * @param name The friendly name of the light
  49182. * @param direction The direction of the light
  49183. * @param scene The scene the light belongs to
  49184. */
  49185. constructor(name: string, direction: Vector3, scene: Scene);
  49186. /**
  49187. * Returns the string "DirectionalLight".
  49188. * @return The class name
  49189. */
  49190. getClassName(): string;
  49191. /**
  49192. * Returns the integer 1.
  49193. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49194. */
  49195. getTypeID(): number;
  49196. /**
  49197. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  49198. * Returns the DirectionalLight Shadow projection matrix.
  49199. */
  49200. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49201. /**
  49202. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  49203. * Returns the DirectionalLight Shadow projection matrix.
  49204. */
  49205. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  49206. /**
  49207. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  49208. * Returns the DirectionalLight Shadow projection matrix.
  49209. */
  49210. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49211. protected _buildUniformLayout(): void;
  49212. /**
  49213. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  49214. * @param effect The effect to update
  49215. * @param lightIndex The index of the light in the effect to update
  49216. * @returns The directional light
  49217. */
  49218. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  49219. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  49220. /**
  49221. * Gets the minZ used for shadow according to both the scene and the light.
  49222. *
  49223. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49224. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49225. * @param activeCamera The camera we are returning the min for
  49226. * @returns the depth min z
  49227. */
  49228. getDepthMinZ(activeCamera: Camera): number;
  49229. /**
  49230. * Gets the maxZ used for shadow according to both the scene and the light.
  49231. *
  49232. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49233. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49234. * @param activeCamera The camera we are returning the max for
  49235. * @returns the depth max z
  49236. */
  49237. getDepthMaxZ(activeCamera: Camera): number;
  49238. /**
  49239. * Prepares the list of defines specific to the light type.
  49240. * @param defines the list of defines
  49241. * @param lightIndex defines the index of the light for the effect
  49242. */
  49243. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49244. }
  49245. }
  49246. declare module BABYLON {
  49247. /**
  49248. * Class containing static functions to help procedurally build meshes
  49249. */
  49250. export class HemisphereBuilder {
  49251. /**
  49252. * Creates a hemisphere mesh
  49253. * @param name defines the name of the mesh
  49254. * @param options defines the options used to create the mesh
  49255. * @param scene defines the hosting scene
  49256. * @returns the hemisphere mesh
  49257. */
  49258. static CreateHemisphere(name: string, options: {
  49259. segments?: number;
  49260. diameter?: number;
  49261. sideOrientation?: number;
  49262. }, scene: any): Mesh;
  49263. }
  49264. }
  49265. declare module BABYLON {
  49266. /**
  49267. * A spot light is defined by a position, a direction, an angle, and an exponent.
  49268. * These values define a cone of light starting from the position, emitting toward the direction.
  49269. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  49270. * and the exponent defines the speed of the decay of the light with distance (reach).
  49271. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49272. */
  49273. export class SpotLight extends ShadowLight {
  49274. private _angle;
  49275. private _innerAngle;
  49276. private _cosHalfAngle;
  49277. private _lightAngleScale;
  49278. private _lightAngleOffset;
  49279. /**
  49280. * Gets the cone angle of the spot light in Radians.
  49281. */
  49282. get angle(): number;
  49283. /**
  49284. * Sets the cone angle of the spot light in Radians.
  49285. */
  49286. set angle(value: number);
  49287. /**
  49288. * Only used in gltf falloff mode, this defines the angle where
  49289. * the directional falloff will start before cutting at angle which could be seen
  49290. * as outer angle.
  49291. */
  49292. get innerAngle(): number;
  49293. /**
  49294. * Only used in gltf falloff mode, this defines the angle where
  49295. * the directional falloff will start before cutting at angle which could be seen
  49296. * as outer angle.
  49297. */
  49298. set innerAngle(value: number);
  49299. private _shadowAngleScale;
  49300. /**
  49301. * Allows scaling the angle of the light for shadow generation only.
  49302. */
  49303. get shadowAngleScale(): number;
  49304. /**
  49305. * Allows scaling the angle of the light for shadow generation only.
  49306. */
  49307. set shadowAngleScale(value: number);
  49308. /**
  49309. * The light decay speed with the distance from the emission spot.
  49310. */
  49311. exponent: number;
  49312. private _projectionTextureMatrix;
  49313. /**
  49314. * Allows reading the projecton texture
  49315. */
  49316. get projectionTextureMatrix(): Matrix;
  49317. protected _projectionTextureLightNear: number;
  49318. /**
  49319. * Gets the near clip of the Spotlight for texture projection.
  49320. */
  49321. get projectionTextureLightNear(): number;
  49322. /**
  49323. * Sets the near clip of the Spotlight for texture projection.
  49324. */
  49325. set projectionTextureLightNear(value: number);
  49326. protected _projectionTextureLightFar: number;
  49327. /**
  49328. * Gets the far clip of the Spotlight for texture projection.
  49329. */
  49330. get projectionTextureLightFar(): number;
  49331. /**
  49332. * Sets the far clip of the Spotlight for texture projection.
  49333. */
  49334. set projectionTextureLightFar(value: number);
  49335. protected _projectionTextureUpDirection: Vector3;
  49336. /**
  49337. * Gets the Up vector of the Spotlight for texture projection.
  49338. */
  49339. get projectionTextureUpDirection(): Vector3;
  49340. /**
  49341. * Sets the Up vector of the Spotlight for texture projection.
  49342. */
  49343. set projectionTextureUpDirection(value: Vector3);
  49344. private _projectionTexture;
  49345. /**
  49346. * Gets the projection texture of the light.
  49347. */
  49348. get projectionTexture(): Nullable<BaseTexture>;
  49349. /**
  49350. * Sets the projection texture of the light.
  49351. */
  49352. set projectionTexture(value: Nullable<BaseTexture>);
  49353. private _projectionTextureViewLightDirty;
  49354. private _projectionTextureProjectionLightDirty;
  49355. private _projectionTextureDirty;
  49356. private _projectionTextureViewTargetVector;
  49357. private _projectionTextureViewLightMatrix;
  49358. private _projectionTextureProjectionLightMatrix;
  49359. private _projectionTextureScalingMatrix;
  49360. /**
  49361. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49362. * It can cast shadows.
  49363. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49364. * @param name The light friendly name
  49365. * @param position The position of the spot light in the scene
  49366. * @param direction The direction of the light in the scene
  49367. * @param angle The cone angle of the light in Radians
  49368. * @param exponent The light decay speed with the distance from the emission spot
  49369. * @param scene The scene the lights belongs to
  49370. */
  49371. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49372. /**
  49373. * Returns the string "SpotLight".
  49374. * @returns the class name
  49375. */
  49376. getClassName(): string;
  49377. /**
  49378. * Returns the integer 2.
  49379. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49380. */
  49381. getTypeID(): number;
  49382. /**
  49383. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49384. */
  49385. protected _setDirection(value: Vector3): void;
  49386. /**
  49387. * Overrides the position setter to recompute the projection texture view light Matrix.
  49388. */
  49389. protected _setPosition(value: Vector3): void;
  49390. /**
  49391. * 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.
  49392. * Returns the SpotLight.
  49393. */
  49394. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49395. protected _computeProjectionTextureViewLightMatrix(): void;
  49396. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49397. /**
  49398. * Main function for light texture projection matrix computing.
  49399. */
  49400. protected _computeProjectionTextureMatrix(): void;
  49401. protected _buildUniformLayout(): void;
  49402. private _computeAngleValues;
  49403. /**
  49404. * Sets the passed Effect "effect" with the Light textures.
  49405. * @param effect The effect to update
  49406. * @param lightIndex The index of the light in the effect to update
  49407. * @returns The light
  49408. */
  49409. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49410. /**
  49411. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49412. * @param effect The effect to update
  49413. * @param lightIndex The index of the light in the effect to update
  49414. * @returns The spot light
  49415. */
  49416. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49417. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49418. /**
  49419. * Disposes the light and the associated resources.
  49420. */
  49421. dispose(): void;
  49422. /**
  49423. * Prepares the list of defines specific to the light type.
  49424. * @param defines the list of defines
  49425. * @param lightIndex defines the index of the light for the effect
  49426. */
  49427. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49428. }
  49429. }
  49430. declare module BABYLON {
  49431. /**
  49432. * Gizmo that enables viewing a light
  49433. */
  49434. export class LightGizmo extends Gizmo {
  49435. private _lightMesh;
  49436. private _material;
  49437. private _cachedPosition;
  49438. private _cachedForward;
  49439. private _attachedMeshParent;
  49440. /**
  49441. * Creates a LightGizmo
  49442. * @param gizmoLayer The utility layer the gizmo will be added to
  49443. */
  49444. constructor(gizmoLayer?: UtilityLayerRenderer);
  49445. private _light;
  49446. /**
  49447. * The light that the gizmo is attached to
  49448. */
  49449. set light(light: Nullable<Light>);
  49450. get light(): Nullable<Light>;
  49451. /**
  49452. * Gets the material used to render the light gizmo
  49453. */
  49454. get material(): StandardMaterial;
  49455. /**
  49456. * @hidden
  49457. * Updates the gizmo to match the attached mesh's position/rotation
  49458. */
  49459. protected _update(): void;
  49460. private static _Scale;
  49461. /**
  49462. * Creates the lines for a light mesh
  49463. */
  49464. private static _CreateLightLines;
  49465. /**
  49466. * Disposes of the light gizmo
  49467. */
  49468. dispose(): void;
  49469. private static _CreateHemisphericLightMesh;
  49470. private static _CreatePointLightMesh;
  49471. private static _CreateSpotLightMesh;
  49472. private static _CreateDirectionalLightMesh;
  49473. }
  49474. }
  49475. declare module BABYLON {
  49476. /** @hidden */
  49477. export var backgroundFragmentDeclaration: {
  49478. name: string;
  49479. shader: string;
  49480. };
  49481. }
  49482. declare module BABYLON {
  49483. /** @hidden */
  49484. export var backgroundUboDeclaration: {
  49485. name: string;
  49486. shader: string;
  49487. };
  49488. }
  49489. declare module BABYLON {
  49490. /** @hidden */
  49491. export var backgroundPixelShader: {
  49492. name: string;
  49493. shader: string;
  49494. };
  49495. }
  49496. declare module BABYLON {
  49497. /** @hidden */
  49498. export var backgroundVertexDeclaration: {
  49499. name: string;
  49500. shader: string;
  49501. };
  49502. }
  49503. declare module BABYLON {
  49504. /** @hidden */
  49505. export var backgroundVertexShader: {
  49506. name: string;
  49507. shader: string;
  49508. };
  49509. }
  49510. declare module BABYLON {
  49511. /**
  49512. * Background material used to create an efficient environement around your scene.
  49513. */
  49514. export class BackgroundMaterial extends PushMaterial {
  49515. /**
  49516. * Standard reflectance value at parallel view angle.
  49517. */
  49518. static StandardReflectance0: number;
  49519. /**
  49520. * Standard reflectance value at grazing angle.
  49521. */
  49522. static StandardReflectance90: number;
  49523. protected _primaryColor: Color3;
  49524. /**
  49525. * Key light Color (multiply against the environement texture)
  49526. */
  49527. primaryColor: Color3;
  49528. protected __perceptualColor: Nullable<Color3>;
  49529. /**
  49530. * Experimental Internal Use Only.
  49531. *
  49532. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49533. * This acts as a helper to set the primary color to a more "human friendly" value.
  49534. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49535. * output color as close as possible from the chosen value.
  49536. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49537. * part of lighting setup.)
  49538. */
  49539. get _perceptualColor(): Nullable<Color3>;
  49540. set _perceptualColor(value: Nullable<Color3>);
  49541. protected _primaryColorShadowLevel: float;
  49542. /**
  49543. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49544. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49545. */
  49546. get primaryColorShadowLevel(): float;
  49547. set primaryColorShadowLevel(value: float);
  49548. protected _primaryColorHighlightLevel: float;
  49549. /**
  49550. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49551. * The primary color is used at the level chosen to define what the white area would look.
  49552. */
  49553. get primaryColorHighlightLevel(): float;
  49554. set primaryColorHighlightLevel(value: float);
  49555. protected _reflectionTexture: Nullable<BaseTexture>;
  49556. /**
  49557. * Reflection Texture used in the material.
  49558. * Should be author in a specific way for the best result (refer to the documentation).
  49559. */
  49560. reflectionTexture: Nullable<BaseTexture>;
  49561. protected _reflectionBlur: float;
  49562. /**
  49563. * Reflection Texture level of blur.
  49564. *
  49565. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49566. * texture twice.
  49567. */
  49568. reflectionBlur: float;
  49569. protected _diffuseTexture: Nullable<BaseTexture>;
  49570. /**
  49571. * Diffuse Texture used in the material.
  49572. * Should be author in a specific way for the best result (refer to the documentation).
  49573. */
  49574. diffuseTexture: Nullable<BaseTexture>;
  49575. protected _shadowLights: Nullable<IShadowLight[]>;
  49576. /**
  49577. * Specify the list of lights casting shadow on the material.
  49578. * All scene shadow lights will be included if null.
  49579. */
  49580. shadowLights: Nullable<IShadowLight[]>;
  49581. protected _shadowLevel: float;
  49582. /**
  49583. * Helps adjusting the shadow to a softer level if required.
  49584. * 0 means black shadows and 1 means no shadows.
  49585. */
  49586. shadowLevel: float;
  49587. protected _sceneCenter: Vector3;
  49588. /**
  49589. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49590. * It is usually zero but might be interesting to modify according to your setup.
  49591. */
  49592. sceneCenter: Vector3;
  49593. protected _opacityFresnel: boolean;
  49594. /**
  49595. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49596. * This helps ensuring a nice transition when the camera goes under the ground.
  49597. */
  49598. opacityFresnel: boolean;
  49599. protected _reflectionFresnel: boolean;
  49600. /**
  49601. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49602. * This helps adding a mirror texture on the ground.
  49603. */
  49604. reflectionFresnel: boolean;
  49605. protected _reflectionFalloffDistance: number;
  49606. /**
  49607. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49608. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49609. */
  49610. reflectionFalloffDistance: number;
  49611. protected _reflectionAmount: number;
  49612. /**
  49613. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49614. */
  49615. reflectionAmount: number;
  49616. protected _reflectionReflectance0: number;
  49617. /**
  49618. * This specifies the weight of the reflection at grazing angle.
  49619. */
  49620. reflectionReflectance0: number;
  49621. protected _reflectionReflectance90: number;
  49622. /**
  49623. * This specifies the weight of the reflection at a perpendicular point of view.
  49624. */
  49625. reflectionReflectance90: number;
  49626. /**
  49627. * Sets the reflection reflectance fresnel values according to the default standard
  49628. * empirically know to work well :-)
  49629. */
  49630. set reflectionStandardFresnelWeight(value: number);
  49631. protected _useRGBColor: boolean;
  49632. /**
  49633. * Helps to directly use the maps channels instead of their level.
  49634. */
  49635. useRGBColor: boolean;
  49636. protected _enableNoise: boolean;
  49637. /**
  49638. * This helps reducing the banding effect that could occur on the background.
  49639. */
  49640. enableNoise: boolean;
  49641. /**
  49642. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49643. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49644. * Recommended to be keep at 1.0 except for special cases.
  49645. */
  49646. get fovMultiplier(): number;
  49647. set fovMultiplier(value: number);
  49648. private _fovMultiplier;
  49649. /**
  49650. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49651. */
  49652. useEquirectangularFOV: boolean;
  49653. private _maxSimultaneousLights;
  49654. /**
  49655. * Number of Simultaneous lights allowed on the material.
  49656. */
  49657. maxSimultaneousLights: int;
  49658. /**
  49659. * Default configuration related to image processing available in the Background Material.
  49660. */
  49661. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49662. /**
  49663. * Keep track of the image processing observer to allow dispose and replace.
  49664. */
  49665. private _imageProcessingObserver;
  49666. /**
  49667. * Attaches a new image processing configuration to the PBR Material.
  49668. * @param configuration (if null the scene configuration will be use)
  49669. */
  49670. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49671. /**
  49672. * Gets the image processing configuration used either in this material.
  49673. */
  49674. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  49675. /**
  49676. * Sets the Default image processing configuration used either in the this material.
  49677. *
  49678. * If sets to null, the scene one is in use.
  49679. */
  49680. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  49681. /**
  49682. * Gets wether the color curves effect is enabled.
  49683. */
  49684. get cameraColorCurvesEnabled(): boolean;
  49685. /**
  49686. * Sets wether the color curves effect is enabled.
  49687. */
  49688. set cameraColorCurvesEnabled(value: boolean);
  49689. /**
  49690. * Gets wether the color grading effect is enabled.
  49691. */
  49692. get cameraColorGradingEnabled(): boolean;
  49693. /**
  49694. * Gets wether the color grading effect is enabled.
  49695. */
  49696. set cameraColorGradingEnabled(value: boolean);
  49697. /**
  49698. * Gets wether tonemapping is enabled or not.
  49699. */
  49700. get cameraToneMappingEnabled(): boolean;
  49701. /**
  49702. * Sets wether tonemapping is enabled or not
  49703. */
  49704. set cameraToneMappingEnabled(value: boolean);
  49705. /**
  49706. * The camera exposure used on this material.
  49707. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49708. * This corresponds to a photographic exposure.
  49709. */
  49710. get cameraExposure(): float;
  49711. /**
  49712. * The camera exposure used on this material.
  49713. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49714. * This corresponds to a photographic exposure.
  49715. */
  49716. set cameraExposure(value: float);
  49717. /**
  49718. * Gets The camera contrast used on this material.
  49719. */
  49720. get cameraContrast(): float;
  49721. /**
  49722. * Sets The camera contrast used on this material.
  49723. */
  49724. set cameraContrast(value: float);
  49725. /**
  49726. * Gets the Color Grading 2D Lookup Texture.
  49727. */
  49728. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  49729. /**
  49730. * Sets the Color Grading 2D Lookup Texture.
  49731. */
  49732. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  49733. /**
  49734. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49735. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49736. * 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;
  49737. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49738. */
  49739. get cameraColorCurves(): Nullable<ColorCurves>;
  49740. /**
  49741. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49742. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49743. * 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;
  49744. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49745. */
  49746. set cameraColorCurves(value: Nullable<ColorCurves>);
  49747. /**
  49748. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49749. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49750. */
  49751. switchToBGR: boolean;
  49752. private _renderTargets;
  49753. private _reflectionControls;
  49754. private _white;
  49755. private _primaryShadowColor;
  49756. private _primaryHighlightColor;
  49757. /**
  49758. * Instantiates a Background Material in the given scene
  49759. * @param name The friendly name of the material
  49760. * @param scene The scene to add the material to
  49761. */
  49762. constructor(name: string, scene: Scene);
  49763. /**
  49764. * Gets a boolean indicating that current material needs to register RTT
  49765. */
  49766. get hasRenderTargetTextures(): boolean;
  49767. /**
  49768. * The entire material has been created in order to prevent overdraw.
  49769. * @returns false
  49770. */
  49771. needAlphaTesting(): boolean;
  49772. /**
  49773. * The entire material has been created in order to prevent overdraw.
  49774. * @returns true if blending is enable
  49775. */
  49776. needAlphaBlending(): boolean;
  49777. /**
  49778. * Checks wether the material is ready to be rendered for a given mesh.
  49779. * @param mesh The mesh to render
  49780. * @param subMesh The submesh to check against
  49781. * @param useInstances Specify wether or not the material is used with instances
  49782. * @returns true if all the dependencies are ready (Textures, Effects...)
  49783. */
  49784. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49785. /**
  49786. * Compute the primary color according to the chosen perceptual color.
  49787. */
  49788. private _computePrimaryColorFromPerceptualColor;
  49789. /**
  49790. * Compute the highlights and shadow colors according to their chosen levels.
  49791. */
  49792. private _computePrimaryColors;
  49793. /**
  49794. * Build the uniform buffer used in the material.
  49795. */
  49796. buildUniformLayout(): void;
  49797. /**
  49798. * Unbind the material.
  49799. */
  49800. unbind(): void;
  49801. /**
  49802. * Bind only the world matrix to the material.
  49803. * @param world The world matrix to bind.
  49804. */
  49805. bindOnlyWorldMatrix(world: Matrix): void;
  49806. /**
  49807. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49808. * @param world The world matrix to bind.
  49809. * @param subMesh The submesh to bind for.
  49810. */
  49811. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49812. /**
  49813. * Checks to see if a texture is used in the material.
  49814. * @param texture - Base texture to use.
  49815. * @returns - Boolean specifying if a texture is used in the material.
  49816. */
  49817. hasTexture(texture: BaseTexture): boolean;
  49818. /**
  49819. * Dispose the material.
  49820. * @param forceDisposeEffect Force disposal of the associated effect.
  49821. * @param forceDisposeTextures Force disposal of the associated textures.
  49822. */
  49823. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49824. /**
  49825. * Clones the material.
  49826. * @param name The cloned name.
  49827. * @returns The cloned material.
  49828. */
  49829. clone(name: string): BackgroundMaterial;
  49830. /**
  49831. * Serializes the current material to its JSON representation.
  49832. * @returns The JSON representation.
  49833. */
  49834. serialize(): any;
  49835. /**
  49836. * Gets the class name of the material
  49837. * @returns "BackgroundMaterial"
  49838. */
  49839. getClassName(): string;
  49840. /**
  49841. * Parse a JSON input to create back a background material.
  49842. * @param source The JSON data to parse
  49843. * @param scene The scene to create the parsed material in
  49844. * @param rootUrl The root url of the assets the material depends upon
  49845. * @returns the instantiated BackgroundMaterial.
  49846. */
  49847. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  49848. }
  49849. }
  49850. declare module BABYLON {
  49851. /**
  49852. * Represents the different options available during the creation of
  49853. * a Environment helper.
  49854. *
  49855. * This can control the default ground, skybox and image processing setup of your scene.
  49856. */
  49857. export interface IEnvironmentHelperOptions {
  49858. /**
  49859. * Specifies whether or not to create a ground.
  49860. * True by default.
  49861. */
  49862. createGround: boolean;
  49863. /**
  49864. * Specifies the ground size.
  49865. * 15 by default.
  49866. */
  49867. groundSize: number;
  49868. /**
  49869. * The texture used on the ground for the main color.
  49870. * Comes from the BabylonJS CDN by default.
  49871. *
  49872. * Remarks: Can be either a texture or a url.
  49873. */
  49874. groundTexture: string | BaseTexture;
  49875. /**
  49876. * The color mixed in the ground texture by default.
  49877. * BabylonJS clearColor by default.
  49878. */
  49879. groundColor: Color3;
  49880. /**
  49881. * Specifies the ground opacity.
  49882. * 1 by default.
  49883. */
  49884. groundOpacity: number;
  49885. /**
  49886. * Enables the ground to receive shadows.
  49887. * True by default.
  49888. */
  49889. enableGroundShadow: boolean;
  49890. /**
  49891. * Helps preventing the shadow to be fully black on the ground.
  49892. * 0.5 by default.
  49893. */
  49894. groundShadowLevel: number;
  49895. /**
  49896. * Creates a mirror texture attach to the ground.
  49897. * false by default.
  49898. */
  49899. enableGroundMirror: boolean;
  49900. /**
  49901. * Specifies the ground mirror size ratio.
  49902. * 0.3 by default as the default kernel is 64.
  49903. */
  49904. groundMirrorSizeRatio: number;
  49905. /**
  49906. * Specifies the ground mirror blur kernel size.
  49907. * 64 by default.
  49908. */
  49909. groundMirrorBlurKernel: number;
  49910. /**
  49911. * Specifies the ground mirror visibility amount.
  49912. * 1 by default
  49913. */
  49914. groundMirrorAmount: number;
  49915. /**
  49916. * Specifies the ground mirror reflectance weight.
  49917. * This uses the standard weight of the background material to setup the fresnel effect
  49918. * of the mirror.
  49919. * 1 by default.
  49920. */
  49921. groundMirrorFresnelWeight: number;
  49922. /**
  49923. * Specifies the ground mirror Falloff distance.
  49924. * This can helps reducing the size of the reflection.
  49925. * 0 by Default.
  49926. */
  49927. groundMirrorFallOffDistance: number;
  49928. /**
  49929. * Specifies the ground mirror texture type.
  49930. * Unsigned Int by Default.
  49931. */
  49932. groundMirrorTextureType: number;
  49933. /**
  49934. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  49935. * the shown objects.
  49936. */
  49937. groundYBias: number;
  49938. /**
  49939. * Specifies whether or not to create a skybox.
  49940. * True by default.
  49941. */
  49942. createSkybox: boolean;
  49943. /**
  49944. * Specifies the skybox size.
  49945. * 20 by default.
  49946. */
  49947. skyboxSize: number;
  49948. /**
  49949. * The texture used on the skybox for the main color.
  49950. * Comes from the BabylonJS CDN by default.
  49951. *
  49952. * Remarks: Can be either a texture or a url.
  49953. */
  49954. skyboxTexture: string | BaseTexture;
  49955. /**
  49956. * The color mixed in the skybox texture by default.
  49957. * BabylonJS clearColor by default.
  49958. */
  49959. skyboxColor: Color3;
  49960. /**
  49961. * The background rotation around the Y axis of the scene.
  49962. * This helps aligning the key lights of your scene with the background.
  49963. * 0 by default.
  49964. */
  49965. backgroundYRotation: number;
  49966. /**
  49967. * Compute automatically the size of the elements to best fit with the scene.
  49968. */
  49969. sizeAuto: boolean;
  49970. /**
  49971. * Default position of the rootMesh if autoSize is not true.
  49972. */
  49973. rootPosition: Vector3;
  49974. /**
  49975. * Sets up the image processing in the scene.
  49976. * true by default.
  49977. */
  49978. setupImageProcessing: boolean;
  49979. /**
  49980. * The texture used as your environment texture in the scene.
  49981. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  49982. *
  49983. * Remarks: Can be either a texture or a url.
  49984. */
  49985. environmentTexture: string | BaseTexture;
  49986. /**
  49987. * The value of the exposure to apply to the scene.
  49988. * 0.6 by default if setupImageProcessing is true.
  49989. */
  49990. cameraExposure: number;
  49991. /**
  49992. * The value of the contrast to apply to the scene.
  49993. * 1.6 by default if setupImageProcessing is true.
  49994. */
  49995. cameraContrast: number;
  49996. /**
  49997. * Specifies whether or not tonemapping should be enabled in the scene.
  49998. * true by default if setupImageProcessing is true.
  49999. */
  50000. toneMappingEnabled: boolean;
  50001. }
  50002. /**
  50003. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  50004. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  50005. * It also helps with the default setup of your imageProcessing configuration.
  50006. */
  50007. export class EnvironmentHelper {
  50008. /**
  50009. * Default ground texture URL.
  50010. */
  50011. private static _groundTextureCDNUrl;
  50012. /**
  50013. * Default skybox texture URL.
  50014. */
  50015. private static _skyboxTextureCDNUrl;
  50016. /**
  50017. * Default environment texture URL.
  50018. */
  50019. private static _environmentTextureCDNUrl;
  50020. /**
  50021. * Creates the default options for the helper.
  50022. */
  50023. private static _getDefaultOptions;
  50024. private _rootMesh;
  50025. /**
  50026. * Gets the root mesh created by the helper.
  50027. */
  50028. get rootMesh(): Mesh;
  50029. private _skybox;
  50030. /**
  50031. * Gets the skybox created by the helper.
  50032. */
  50033. get skybox(): Nullable<Mesh>;
  50034. private _skyboxTexture;
  50035. /**
  50036. * Gets the skybox texture created by the helper.
  50037. */
  50038. get skyboxTexture(): Nullable<BaseTexture>;
  50039. private _skyboxMaterial;
  50040. /**
  50041. * Gets the skybox material created by the helper.
  50042. */
  50043. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  50044. private _ground;
  50045. /**
  50046. * Gets the ground mesh created by the helper.
  50047. */
  50048. get ground(): Nullable<Mesh>;
  50049. private _groundTexture;
  50050. /**
  50051. * Gets the ground texture created by the helper.
  50052. */
  50053. get groundTexture(): Nullable<BaseTexture>;
  50054. private _groundMirror;
  50055. /**
  50056. * Gets the ground mirror created by the helper.
  50057. */
  50058. get groundMirror(): Nullable<MirrorTexture>;
  50059. /**
  50060. * Gets the ground mirror render list to helps pushing the meshes
  50061. * you wish in the ground reflection.
  50062. */
  50063. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  50064. private _groundMaterial;
  50065. /**
  50066. * Gets the ground material created by the helper.
  50067. */
  50068. get groundMaterial(): Nullable<BackgroundMaterial>;
  50069. /**
  50070. * Stores the creation options.
  50071. */
  50072. private readonly _scene;
  50073. private _options;
  50074. /**
  50075. * This observable will be notified with any error during the creation of the environment,
  50076. * mainly texture creation errors.
  50077. */
  50078. onErrorObservable: Observable<{
  50079. message?: string;
  50080. exception?: any;
  50081. }>;
  50082. /**
  50083. * constructor
  50084. * @param options Defines the options we want to customize the helper
  50085. * @param scene The scene to add the material to
  50086. */
  50087. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  50088. /**
  50089. * Updates the background according to the new options
  50090. * @param options
  50091. */
  50092. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  50093. /**
  50094. * Sets the primary color of all the available elements.
  50095. * @param color the main color to affect to the ground and the background
  50096. */
  50097. setMainColor(color: Color3): void;
  50098. /**
  50099. * Setup the image processing according to the specified options.
  50100. */
  50101. private _setupImageProcessing;
  50102. /**
  50103. * Setup the environment texture according to the specified options.
  50104. */
  50105. private _setupEnvironmentTexture;
  50106. /**
  50107. * Setup the background according to the specified options.
  50108. */
  50109. private _setupBackground;
  50110. /**
  50111. * Get the scene sizes according to the setup.
  50112. */
  50113. private _getSceneSize;
  50114. /**
  50115. * Setup the ground according to the specified options.
  50116. */
  50117. private _setupGround;
  50118. /**
  50119. * Setup the ground material according to the specified options.
  50120. */
  50121. private _setupGroundMaterial;
  50122. /**
  50123. * Setup the ground diffuse texture according to the specified options.
  50124. */
  50125. private _setupGroundDiffuseTexture;
  50126. /**
  50127. * Setup the ground mirror texture according to the specified options.
  50128. */
  50129. private _setupGroundMirrorTexture;
  50130. /**
  50131. * Setup the ground to receive the mirror texture.
  50132. */
  50133. private _setupMirrorInGroundMaterial;
  50134. /**
  50135. * Setup the skybox according to the specified options.
  50136. */
  50137. private _setupSkybox;
  50138. /**
  50139. * Setup the skybox material according to the specified options.
  50140. */
  50141. private _setupSkyboxMaterial;
  50142. /**
  50143. * Setup the skybox reflection texture according to the specified options.
  50144. */
  50145. private _setupSkyboxReflectionTexture;
  50146. private _errorHandler;
  50147. /**
  50148. * Dispose all the elements created by the Helper.
  50149. */
  50150. dispose(): void;
  50151. }
  50152. }
  50153. declare module BABYLON {
  50154. /**
  50155. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  50156. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  50157. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  50158. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50159. */
  50160. export class PhotoDome extends TransformNode {
  50161. /**
  50162. * Define the image as a Monoscopic panoramic 360 image.
  50163. */
  50164. static readonly MODE_MONOSCOPIC: number;
  50165. /**
  50166. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50167. */
  50168. static readonly MODE_TOPBOTTOM: number;
  50169. /**
  50170. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50171. */
  50172. static readonly MODE_SIDEBYSIDE: number;
  50173. private _useDirectMapping;
  50174. /**
  50175. * The texture being displayed on the sphere
  50176. */
  50177. protected _photoTexture: Texture;
  50178. /**
  50179. * Gets or sets the texture being displayed on the sphere
  50180. */
  50181. get photoTexture(): Texture;
  50182. set photoTexture(value: Texture);
  50183. /**
  50184. * Observable raised when an error occured while loading the 360 image
  50185. */
  50186. onLoadErrorObservable: Observable<string>;
  50187. /**
  50188. * The skybox material
  50189. */
  50190. protected _material: BackgroundMaterial;
  50191. /**
  50192. * The surface used for the skybox
  50193. */
  50194. protected _mesh: Mesh;
  50195. /**
  50196. * Gets the mesh used for the skybox.
  50197. */
  50198. get mesh(): Mesh;
  50199. /**
  50200. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50201. * Also see the options.resolution property.
  50202. */
  50203. get fovMultiplier(): number;
  50204. set fovMultiplier(value: number);
  50205. private _imageMode;
  50206. /**
  50207. * Gets or set the current video mode for the video. It can be:
  50208. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  50209. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50210. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50211. */
  50212. get imageMode(): number;
  50213. set imageMode(value: number);
  50214. /**
  50215. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  50216. * @param name Element's name, child elements will append suffixes for their own names.
  50217. * @param urlsOfPhoto defines the url of the photo to display
  50218. * @param options defines an object containing optional or exposed sub element properties
  50219. * @param onError defines a callback called when an error occured while loading the texture
  50220. */
  50221. constructor(name: string, urlOfPhoto: string, options: {
  50222. resolution?: number;
  50223. size?: number;
  50224. useDirectMapping?: boolean;
  50225. faceForward?: boolean;
  50226. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  50227. private _onBeforeCameraRenderObserver;
  50228. private _changeImageMode;
  50229. /**
  50230. * Releases resources associated with this node.
  50231. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50232. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50233. */
  50234. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50235. }
  50236. }
  50237. declare module BABYLON {
  50238. /**
  50239. * Class used to host RGBD texture specific utilities
  50240. */
  50241. export class RGBDTextureTools {
  50242. /**
  50243. * Expand the RGBD Texture from RGBD to Half Float if possible.
  50244. * @param texture the texture to expand.
  50245. */
  50246. static ExpandRGBDTexture(texture: Texture): void;
  50247. }
  50248. }
  50249. declare module BABYLON {
  50250. /**
  50251. * Class used to host texture specific utilities
  50252. */
  50253. export class BRDFTextureTools {
  50254. /**
  50255. * Prevents texture cache collision
  50256. */
  50257. private static _instanceNumber;
  50258. /**
  50259. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  50260. * @param scene defines the hosting scene
  50261. * @returns the environment BRDF texture
  50262. */
  50263. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  50264. private static _environmentBRDFBase64Texture;
  50265. }
  50266. }
  50267. declare module BABYLON {
  50268. /**
  50269. * @hidden
  50270. */
  50271. export interface IMaterialClearCoatDefines {
  50272. CLEARCOAT: boolean;
  50273. CLEARCOAT_DEFAULTIOR: boolean;
  50274. CLEARCOAT_TEXTURE: boolean;
  50275. CLEARCOAT_TEXTUREDIRECTUV: number;
  50276. CLEARCOAT_BUMP: boolean;
  50277. CLEARCOAT_BUMPDIRECTUV: number;
  50278. CLEARCOAT_TINT: boolean;
  50279. CLEARCOAT_TINT_TEXTURE: boolean;
  50280. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50281. /** @hidden */
  50282. _areTexturesDirty: boolean;
  50283. }
  50284. /**
  50285. * Define the code related to the clear coat parameters of the pbr material.
  50286. */
  50287. export class PBRClearCoatConfiguration {
  50288. /**
  50289. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50290. * The default fits with a polyurethane material.
  50291. */
  50292. private static readonly _DefaultIndexOfRefraction;
  50293. private _isEnabled;
  50294. /**
  50295. * Defines if the clear coat is enabled in the material.
  50296. */
  50297. isEnabled: boolean;
  50298. /**
  50299. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  50300. */
  50301. intensity: number;
  50302. /**
  50303. * Defines the clear coat layer roughness.
  50304. */
  50305. roughness: number;
  50306. private _indexOfRefraction;
  50307. /**
  50308. * Defines the index of refraction of the clear coat.
  50309. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50310. * The default fits with a polyurethane material.
  50311. * Changing the default value is more performance intensive.
  50312. */
  50313. indexOfRefraction: number;
  50314. private _texture;
  50315. /**
  50316. * Stores the clear coat values in a texture.
  50317. */
  50318. texture: Nullable<BaseTexture>;
  50319. private _bumpTexture;
  50320. /**
  50321. * Define the clear coat specific bump texture.
  50322. */
  50323. bumpTexture: Nullable<BaseTexture>;
  50324. private _isTintEnabled;
  50325. /**
  50326. * Defines if the clear coat tint is enabled in the material.
  50327. */
  50328. isTintEnabled: boolean;
  50329. /**
  50330. * Defines the clear coat tint of the material.
  50331. * This is only use if tint is enabled
  50332. */
  50333. tintColor: Color3;
  50334. /**
  50335. * Defines the distance at which the tint color should be found in the
  50336. * clear coat media.
  50337. * This is only use if tint is enabled
  50338. */
  50339. tintColorAtDistance: number;
  50340. /**
  50341. * Defines the clear coat layer thickness.
  50342. * This is only use if tint is enabled
  50343. */
  50344. tintThickness: number;
  50345. private _tintTexture;
  50346. /**
  50347. * Stores the clear tint values in a texture.
  50348. * rgb is tint
  50349. * a is a thickness factor
  50350. */
  50351. tintTexture: Nullable<BaseTexture>;
  50352. /** @hidden */
  50353. private _internalMarkAllSubMeshesAsTexturesDirty;
  50354. /** @hidden */
  50355. _markAllSubMeshesAsTexturesDirty(): void;
  50356. /**
  50357. * Instantiate a new istance of clear coat configuration.
  50358. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50359. */
  50360. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50361. /**
  50362. * Gets wehter the submesh is ready to be used or not.
  50363. * @param defines the list of "defines" to update.
  50364. * @param scene defines the scene the material belongs to.
  50365. * @param engine defines the engine the material belongs to.
  50366. * @param disableBumpMap defines wether the material disables bump or not.
  50367. * @returns - boolean indicating that the submesh is ready or not.
  50368. */
  50369. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  50370. /**
  50371. * Checks to see if a texture is used in the material.
  50372. * @param defines the list of "defines" to update.
  50373. * @param scene defines the scene to the material belongs to.
  50374. */
  50375. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  50376. /**
  50377. * Binds the material data.
  50378. * @param uniformBuffer defines the Uniform buffer to fill in.
  50379. * @param scene defines the scene the material belongs to.
  50380. * @param engine defines the engine the material belongs to.
  50381. * @param disableBumpMap defines wether the material disables bump or not.
  50382. * @param isFrozen defines wether the material is frozen or not.
  50383. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50384. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50385. */
  50386. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  50387. /**
  50388. * Checks to see if a texture is used in the material.
  50389. * @param texture - Base texture to use.
  50390. * @returns - Boolean specifying if a texture is used in the material.
  50391. */
  50392. hasTexture(texture: BaseTexture): boolean;
  50393. /**
  50394. * Returns an array of the actively used textures.
  50395. * @param activeTextures Array of BaseTextures
  50396. */
  50397. getActiveTextures(activeTextures: BaseTexture[]): void;
  50398. /**
  50399. * Returns the animatable textures.
  50400. * @param animatables Array of animatable textures.
  50401. */
  50402. getAnimatables(animatables: IAnimatable[]): void;
  50403. /**
  50404. * Disposes the resources of the material.
  50405. * @param forceDisposeTextures - Forces the disposal of all textures.
  50406. */
  50407. dispose(forceDisposeTextures?: boolean): void;
  50408. /**
  50409. * Get the current class name of the texture useful for serialization or dynamic coding.
  50410. * @returns "PBRClearCoatConfiguration"
  50411. */
  50412. getClassName(): string;
  50413. /**
  50414. * Add fallbacks to the effect fallbacks list.
  50415. * @param defines defines the Base texture to use.
  50416. * @param fallbacks defines the current fallback list.
  50417. * @param currentRank defines the current fallback rank.
  50418. * @returns the new fallback rank.
  50419. */
  50420. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50421. /**
  50422. * Add the required uniforms to the current list.
  50423. * @param uniforms defines the current uniform list.
  50424. */
  50425. static AddUniforms(uniforms: string[]): void;
  50426. /**
  50427. * Add the required samplers to the current list.
  50428. * @param samplers defines the current sampler list.
  50429. */
  50430. static AddSamplers(samplers: string[]): void;
  50431. /**
  50432. * Add the required uniforms to the current buffer.
  50433. * @param uniformBuffer defines the current uniform buffer.
  50434. */
  50435. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50436. /**
  50437. * Makes a duplicate of the current configuration into another one.
  50438. * @param clearCoatConfiguration define the config where to copy the info
  50439. */
  50440. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  50441. /**
  50442. * Serializes this clear coat configuration.
  50443. * @returns - An object with the serialized config.
  50444. */
  50445. serialize(): any;
  50446. /**
  50447. * Parses a anisotropy Configuration from a serialized object.
  50448. * @param source - Serialized object.
  50449. * @param scene Defines the scene we are parsing for
  50450. * @param rootUrl Defines the rootUrl to load from
  50451. */
  50452. parse(source: any, scene: Scene, rootUrl: string): void;
  50453. }
  50454. }
  50455. declare module BABYLON {
  50456. /**
  50457. * @hidden
  50458. */
  50459. export interface IMaterialAnisotropicDefines {
  50460. ANISOTROPIC: boolean;
  50461. ANISOTROPIC_TEXTURE: boolean;
  50462. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50463. MAINUV1: boolean;
  50464. _areTexturesDirty: boolean;
  50465. _needUVs: boolean;
  50466. }
  50467. /**
  50468. * Define the code related to the anisotropic parameters of the pbr material.
  50469. */
  50470. export class PBRAnisotropicConfiguration {
  50471. private _isEnabled;
  50472. /**
  50473. * Defines if the anisotropy is enabled in the material.
  50474. */
  50475. isEnabled: boolean;
  50476. /**
  50477. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50478. */
  50479. intensity: number;
  50480. /**
  50481. * Defines if the effect is along the tangents, bitangents or in between.
  50482. * By default, the effect is "strectching" the highlights along the tangents.
  50483. */
  50484. direction: Vector2;
  50485. private _texture;
  50486. /**
  50487. * Stores the anisotropy values in a texture.
  50488. * rg is direction (like normal from -1 to 1)
  50489. * b is a intensity
  50490. */
  50491. texture: Nullable<BaseTexture>;
  50492. /** @hidden */
  50493. private _internalMarkAllSubMeshesAsTexturesDirty;
  50494. /** @hidden */
  50495. _markAllSubMeshesAsTexturesDirty(): void;
  50496. /**
  50497. * Instantiate a new istance of anisotropy configuration.
  50498. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50499. */
  50500. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50501. /**
  50502. * Specifies that the submesh is ready to be used.
  50503. * @param defines the list of "defines" to update.
  50504. * @param scene defines the scene the material belongs to.
  50505. * @returns - boolean indicating that the submesh is ready or not.
  50506. */
  50507. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50508. /**
  50509. * Checks to see if a texture is used in the material.
  50510. * @param defines the list of "defines" to update.
  50511. * @param mesh the mesh we are preparing the defines for.
  50512. * @param scene defines the scene the material belongs to.
  50513. */
  50514. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50515. /**
  50516. * Binds the material data.
  50517. * @param uniformBuffer defines the Uniform buffer to fill in.
  50518. * @param scene defines the scene the material belongs to.
  50519. * @param isFrozen defines wether the material is frozen or not.
  50520. */
  50521. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50522. /**
  50523. * Checks to see if a texture is used in the material.
  50524. * @param texture - Base texture to use.
  50525. * @returns - Boolean specifying if a texture is used in the material.
  50526. */
  50527. hasTexture(texture: BaseTexture): boolean;
  50528. /**
  50529. * Returns an array of the actively used textures.
  50530. * @param activeTextures Array of BaseTextures
  50531. */
  50532. getActiveTextures(activeTextures: BaseTexture[]): void;
  50533. /**
  50534. * Returns the animatable textures.
  50535. * @param animatables Array of animatable textures.
  50536. */
  50537. getAnimatables(animatables: IAnimatable[]): void;
  50538. /**
  50539. * Disposes the resources of the material.
  50540. * @param forceDisposeTextures - Forces the disposal of all textures.
  50541. */
  50542. dispose(forceDisposeTextures?: boolean): void;
  50543. /**
  50544. * Get the current class name of the texture useful for serialization or dynamic coding.
  50545. * @returns "PBRAnisotropicConfiguration"
  50546. */
  50547. getClassName(): string;
  50548. /**
  50549. * Add fallbacks to the effect fallbacks list.
  50550. * @param defines defines the Base texture to use.
  50551. * @param fallbacks defines the current fallback list.
  50552. * @param currentRank defines the current fallback rank.
  50553. * @returns the new fallback rank.
  50554. */
  50555. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50556. /**
  50557. * Add the required uniforms to the current list.
  50558. * @param uniforms defines the current uniform list.
  50559. */
  50560. static AddUniforms(uniforms: string[]): void;
  50561. /**
  50562. * Add the required uniforms to the current buffer.
  50563. * @param uniformBuffer defines the current uniform buffer.
  50564. */
  50565. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50566. /**
  50567. * Add the required samplers to the current list.
  50568. * @param samplers defines the current sampler list.
  50569. */
  50570. static AddSamplers(samplers: string[]): void;
  50571. /**
  50572. * Makes a duplicate of the current configuration into another one.
  50573. * @param anisotropicConfiguration define the config where to copy the info
  50574. */
  50575. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50576. /**
  50577. * Serializes this anisotropy configuration.
  50578. * @returns - An object with the serialized config.
  50579. */
  50580. serialize(): any;
  50581. /**
  50582. * Parses a anisotropy Configuration from a serialized object.
  50583. * @param source - Serialized object.
  50584. * @param scene Defines the scene we are parsing for
  50585. * @param rootUrl Defines the rootUrl to load from
  50586. */
  50587. parse(source: any, scene: Scene, rootUrl: string): void;
  50588. }
  50589. }
  50590. declare module BABYLON {
  50591. /**
  50592. * @hidden
  50593. */
  50594. export interface IMaterialBRDFDefines {
  50595. BRDF_V_HEIGHT_CORRELATED: boolean;
  50596. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50597. SPHERICAL_HARMONICS: boolean;
  50598. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50599. /** @hidden */
  50600. _areMiscDirty: boolean;
  50601. }
  50602. /**
  50603. * Define the code related to the BRDF parameters of the pbr material.
  50604. */
  50605. export class PBRBRDFConfiguration {
  50606. /**
  50607. * Default value used for the energy conservation.
  50608. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50609. */
  50610. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50611. /**
  50612. * Default value used for the Smith Visibility Height Correlated mode.
  50613. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50614. */
  50615. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50616. /**
  50617. * Default value used for the IBL diffuse part.
  50618. * This can help switching back to the polynomials mode globally which is a tiny bit
  50619. * less GPU intensive at the drawback of a lower quality.
  50620. */
  50621. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50622. /**
  50623. * Default value used for activating energy conservation for the specular workflow.
  50624. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50625. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50626. */
  50627. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50628. private _useEnergyConservation;
  50629. /**
  50630. * Defines if the material uses energy conservation.
  50631. */
  50632. useEnergyConservation: boolean;
  50633. private _useSmithVisibilityHeightCorrelated;
  50634. /**
  50635. * LEGACY Mode set to false
  50636. * Defines if the material uses height smith correlated visibility term.
  50637. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50638. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50639. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50640. * Not relying on height correlated will also disable energy conservation.
  50641. */
  50642. useSmithVisibilityHeightCorrelated: boolean;
  50643. private _useSphericalHarmonics;
  50644. /**
  50645. * LEGACY Mode set to false
  50646. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50647. * diffuse part of the IBL.
  50648. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50649. * to the ground truth.
  50650. */
  50651. useSphericalHarmonics: boolean;
  50652. private _useSpecularGlossinessInputEnergyConservation;
  50653. /**
  50654. * Defines if the material uses energy conservation, when the specular workflow is active.
  50655. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50656. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50657. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50658. */
  50659. useSpecularGlossinessInputEnergyConservation: boolean;
  50660. /** @hidden */
  50661. private _internalMarkAllSubMeshesAsMiscDirty;
  50662. /** @hidden */
  50663. _markAllSubMeshesAsMiscDirty(): void;
  50664. /**
  50665. * Instantiate a new istance of clear coat configuration.
  50666. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50667. */
  50668. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50669. /**
  50670. * Checks to see if a texture is used in the material.
  50671. * @param defines the list of "defines" to update.
  50672. */
  50673. prepareDefines(defines: IMaterialBRDFDefines): void;
  50674. /**
  50675. * Get the current class name of the texture useful for serialization or dynamic coding.
  50676. * @returns "PBRClearCoatConfiguration"
  50677. */
  50678. getClassName(): string;
  50679. /**
  50680. * Makes a duplicate of the current configuration into another one.
  50681. * @param brdfConfiguration define the config where to copy the info
  50682. */
  50683. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50684. /**
  50685. * Serializes this BRDF configuration.
  50686. * @returns - An object with the serialized config.
  50687. */
  50688. serialize(): any;
  50689. /**
  50690. * Parses a anisotropy Configuration from a serialized object.
  50691. * @param source - Serialized object.
  50692. * @param scene Defines the scene we are parsing for
  50693. * @param rootUrl Defines the rootUrl to load from
  50694. */
  50695. parse(source: any, scene: Scene, rootUrl: string): void;
  50696. }
  50697. }
  50698. declare module BABYLON {
  50699. /**
  50700. * @hidden
  50701. */
  50702. export interface IMaterialSheenDefines {
  50703. SHEEN: boolean;
  50704. SHEEN_TEXTURE: boolean;
  50705. SHEEN_TEXTUREDIRECTUV: number;
  50706. SHEEN_LINKWITHALBEDO: boolean;
  50707. SHEEN_ROUGHNESS: boolean;
  50708. SHEEN_ALBEDOSCALING: boolean;
  50709. /** @hidden */
  50710. _areTexturesDirty: boolean;
  50711. }
  50712. /**
  50713. * Define the code related to the Sheen parameters of the pbr material.
  50714. */
  50715. export class PBRSheenConfiguration {
  50716. private _isEnabled;
  50717. /**
  50718. * Defines if the material uses sheen.
  50719. */
  50720. isEnabled: boolean;
  50721. private _linkSheenWithAlbedo;
  50722. /**
  50723. * Defines if the sheen is linked to the sheen color.
  50724. */
  50725. linkSheenWithAlbedo: boolean;
  50726. /**
  50727. * Defines the sheen intensity.
  50728. */
  50729. intensity: number;
  50730. /**
  50731. * Defines the sheen color.
  50732. */
  50733. color: Color3;
  50734. private _texture;
  50735. /**
  50736. * Stores the sheen tint values in a texture.
  50737. * rgb is tint
  50738. * a is a intensity
  50739. */
  50740. texture: Nullable<BaseTexture>;
  50741. private _roughness;
  50742. /**
  50743. * Defines the sheen roughness.
  50744. * It is not taken into account if linkSheenWithAlbedo is true.
  50745. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  50746. */
  50747. roughness: Nullable<number>;
  50748. private _albedoScaling;
  50749. /**
  50750. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  50751. * It allows the strength of the sheen effect to not depend on the base color of the material,
  50752. * making it easier to setup and tweak the effect
  50753. */
  50754. albedoScaling: boolean;
  50755. /** @hidden */
  50756. private _internalMarkAllSubMeshesAsTexturesDirty;
  50757. /** @hidden */
  50758. _markAllSubMeshesAsTexturesDirty(): void;
  50759. /**
  50760. * Instantiate a new istance of clear coat configuration.
  50761. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50762. */
  50763. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50764. /**
  50765. * Specifies that the submesh is ready to be used.
  50766. * @param defines the list of "defines" to update.
  50767. * @param scene defines the scene the material belongs to.
  50768. * @returns - boolean indicating that the submesh is ready or not.
  50769. */
  50770. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50771. /**
  50772. * Checks to see if a texture is used in the material.
  50773. * @param defines the list of "defines" to update.
  50774. * @param scene defines the scene the material belongs to.
  50775. */
  50776. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50777. /**
  50778. * Binds the material data.
  50779. * @param uniformBuffer defines the Uniform buffer to fill in.
  50780. * @param scene defines the scene the material belongs to.
  50781. * @param isFrozen defines wether the material is frozen or not.
  50782. */
  50783. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50784. /**
  50785. * Checks to see if a texture is used in the material.
  50786. * @param texture - Base texture to use.
  50787. * @returns - Boolean specifying if a texture is used in the material.
  50788. */
  50789. hasTexture(texture: BaseTexture): boolean;
  50790. /**
  50791. * Returns an array of the actively used textures.
  50792. * @param activeTextures Array of BaseTextures
  50793. */
  50794. getActiveTextures(activeTextures: BaseTexture[]): void;
  50795. /**
  50796. * Returns the animatable textures.
  50797. * @param animatables Array of animatable textures.
  50798. */
  50799. getAnimatables(animatables: IAnimatable[]): void;
  50800. /**
  50801. * Disposes the resources of the material.
  50802. * @param forceDisposeTextures - Forces the disposal of all textures.
  50803. */
  50804. dispose(forceDisposeTextures?: boolean): void;
  50805. /**
  50806. * Get the current class name of the texture useful for serialization or dynamic coding.
  50807. * @returns "PBRSheenConfiguration"
  50808. */
  50809. getClassName(): string;
  50810. /**
  50811. * Add fallbacks to the effect fallbacks list.
  50812. * @param defines defines the Base texture to use.
  50813. * @param fallbacks defines the current fallback list.
  50814. * @param currentRank defines the current fallback rank.
  50815. * @returns the new fallback rank.
  50816. */
  50817. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50818. /**
  50819. * Add the required uniforms to the current list.
  50820. * @param uniforms defines the current uniform list.
  50821. */
  50822. static AddUniforms(uniforms: string[]): void;
  50823. /**
  50824. * Add the required uniforms to the current buffer.
  50825. * @param uniformBuffer defines the current uniform buffer.
  50826. */
  50827. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50828. /**
  50829. * Add the required samplers to the current list.
  50830. * @param samplers defines the current sampler list.
  50831. */
  50832. static AddSamplers(samplers: string[]): void;
  50833. /**
  50834. * Makes a duplicate of the current configuration into another one.
  50835. * @param sheenConfiguration define the config where to copy the info
  50836. */
  50837. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  50838. /**
  50839. * Serializes this BRDF configuration.
  50840. * @returns - An object with the serialized config.
  50841. */
  50842. serialize(): any;
  50843. /**
  50844. * Parses a anisotropy Configuration from a serialized object.
  50845. * @param source - Serialized object.
  50846. * @param scene Defines the scene we are parsing for
  50847. * @param rootUrl Defines the rootUrl to load from
  50848. */
  50849. parse(source: any, scene: Scene, rootUrl: string): void;
  50850. }
  50851. }
  50852. declare module BABYLON {
  50853. /**
  50854. * @hidden
  50855. */
  50856. export interface IMaterialSubSurfaceDefines {
  50857. SUBSURFACE: boolean;
  50858. SS_REFRACTION: boolean;
  50859. SS_TRANSLUCENCY: boolean;
  50860. SS_SCATERRING: boolean;
  50861. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50862. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50863. SS_REFRACTIONMAP_3D: boolean;
  50864. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50865. SS_LODINREFRACTIONALPHA: boolean;
  50866. SS_GAMMAREFRACTION: boolean;
  50867. SS_RGBDREFRACTION: boolean;
  50868. SS_LINEARSPECULARREFRACTION: boolean;
  50869. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50870. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50871. /** @hidden */
  50872. _areTexturesDirty: boolean;
  50873. }
  50874. /**
  50875. * Define the code related to the sub surface parameters of the pbr material.
  50876. */
  50877. export class PBRSubSurfaceConfiguration {
  50878. private _isRefractionEnabled;
  50879. /**
  50880. * Defines if the refraction is enabled in the material.
  50881. */
  50882. isRefractionEnabled: boolean;
  50883. private _isTranslucencyEnabled;
  50884. /**
  50885. * Defines if the translucency is enabled in the material.
  50886. */
  50887. isTranslucencyEnabled: boolean;
  50888. private _isScatteringEnabled;
  50889. /**
  50890. * Defines the refraction intensity of the material.
  50891. * The refraction when enabled replaces the Diffuse part of the material.
  50892. * The intensity helps transitionning between diffuse and refraction.
  50893. */
  50894. refractionIntensity: number;
  50895. /**
  50896. * Defines the translucency intensity of the material.
  50897. * When translucency has been enabled, this defines how much of the "translucency"
  50898. * is addded to the diffuse part of the material.
  50899. */
  50900. translucencyIntensity: number;
  50901. /**
  50902. * Defines the scattering intensity of the material.
  50903. * When scattering has been enabled, this defines how much of the "scattered light"
  50904. * is addded to the diffuse part of the material.
  50905. */
  50906. scatteringIntensity: number;
  50907. private _thicknessTexture;
  50908. /**
  50909. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50910. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50911. * 0 would mean minimumThickness
  50912. * 1 would mean maximumThickness
  50913. * The other channels might be use as a mask to vary the different effects intensity.
  50914. */
  50915. thicknessTexture: Nullable<BaseTexture>;
  50916. private _refractionTexture;
  50917. /**
  50918. * Defines the texture to use for refraction.
  50919. */
  50920. refractionTexture: Nullable<BaseTexture>;
  50921. private _indexOfRefraction;
  50922. /**
  50923. * Defines the index of refraction used in the material.
  50924. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50925. */
  50926. indexOfRefraction: number;
  50927. private _invertRefractionY;
  50928. /**
  50929. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50930. */
  50931. invertRefractionY: boolean;
  50932. private _linkRefractionWithTransparency;
  50933. /**
  50934. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50935. * Materials half opaque for instance using refraction could benefit from this control.
  50936. */
  50937. linkRefractionWithTransparency: boolean;
  50938. /**
  50939. * Defines the minimum thickness stored in the thickness map.
  50940. * If no thickness map is defined, this value will be used to simulate thickness.
  50941. */
  50942. minimumThickness: number;
  50943. /**
  50944. * Defines the maximum thickness stored in the thickness map.
  50945. */
  50946. maximumThickness: number;
  50947. /**
  50948. * Defines the volume tint of the material.
  50949. * This is used for both translucency and scattering.
  50950. */
  50951. tintColor: Color3;
  50952. /**
  50953. * Defines the distance at which the tint color should be found in the media.
  50954. * This is used for refraction only.
  50955. */
  50956. tintColorAtDistance: number;
  50957. /**
  50958. * Defines how far each channel transmit through the media.
  50959. * It is defined as a color to simplify it selection.
  50960. */
  50961. diffusionDistance: Color3;
  50962. private _useMaskFromThicknessTexture;
  50963. /**
  50964. * Stores the intensity of the different subsurface effects in the thickness texture.
  50965. * * the green channel is the translucency intensity.
  50966. * * the blue channel is the scattering intensity.
  50967. * * the alpha channel is the refraction intensity.
  50968. */
  50969. useMaskFromThicknessTexture: boolean;
  50970. /** @hidden */
  50971. private _internalMarkAllSubMeshesAsTexturesDirty;
  50972. /** @hidden */
  50973. _markAllSubMeshesAsTexturesDirty(): void;
  50974. /**
  50975. * Instantiate a new istance of sub surface configuration.
  50976. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50977. */
  50978. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50979. /**
  50980. * Gets wehter the submesh is ready to be used or not.
  50981. * @param defines the list of "defines" to update.
  50982. * @param scene defines the scene the material belongs to.
  50983. * @returns - boolean indicating that the submesh is ready or not.
  50984. */
  50985. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  50986. /**
  50987. * Checks to see if a texture is used in the material.
  50988. * @param defines the list of "defines" to update.
  50989. * @param scene defines the scene to the material belongs to.
  50990. */
  50991. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  50992. /**
  50993. * Binds the material data.
  50994. * @param uniformBuffer defines the Uniform buffer to fill in.
  50995. * @param scene defines the scene the material belongs to.
  50996. * @param engine defines the engine the material belongs to.
  50997. * @param isFrozen defines wether the material is frozen or not.
  50998. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  50999. */
  51000. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  51001. /**
  51002. * Unbinds the material from the mesh.
  51003. * @param activeEffect defines the effect that should be unbound from.
  51004. * @returns true if unbound, otherwise false
  51005. */
  51006. unbind(activeEffect: Effect): boolean;
  51007. /**
  51008. * Returns the texture used for refraction or null if none is used.
  51009. * @param scene defines the scene the material belongs to.
  51010. * @returns - Refraction texture if present. If no refraction texture and refraction
  51011. * is linked with transparency, returns environment texture. Otherwise, returns null.
  51012. */
  51013. private _getRefractionTexture;
  51014. /**
  51015. * Returns true if alpha blending should be disabled.
  51016. */
  51017. get disableAlphaBlending(): boolean;
  51018. /**
  51019. * Fills the list of render target textures.
  51020. * @param renderTargets the list of render targets to update
  51021. */
  51022. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  51023. /**
  51024. * Checks to see if a texture is used in the material.
  51025. * @param texture - Base texture to use.
  51026. * @returns - Boolean specifying if a texture is used in the material.
  51027. */
  51028. hasTexture(texture: BaseTexture): boolean;
  51029. /**
  51030. * Gets a boolean indicating that current material needs to register RTT
  51031. * @returns true if this uses a render target otherwise false.
  51032. */
  51033. hasRenderTargetTextures(): boolean;
  51034. /**
  51035. * Returns an array of the actively used textures.
  51036. * @param activeTextures Array of BaseTextures
  51037. */
  51038. getActiveTextures(activeTextures: BaseTexture[]): void;
  51039. /**
  51040. * Returns the animatable textures.
  51041. * @param animatables Array of animatable textures.
  51042. */
  51043. getAnimatables(animatables: IAnimatable[]): void;
  51044. /**
  51045. * Disposes the resources of the material.
  51046. * @param forceDisposeTextures - Forces the disposal of all textures.
  51047. */
  51048. dispose(forceDisposeTextures?: boolean): void;
  51049. /**
  51050. * Get the current class name of the texture useful for serialization or dynamic coding.
  51051. * @returns "PBRSubSurfaceConfiguration"
  51052. */
  51053. getClassName(): string;
  51054. /**
  51055. * Add fallbacks to the effect fallbacks list.
  51056. * @param defines defines the Base texture to use.
  51057. * @param fallbacks defines the current fallback list.
  51058. * @param currentRank defines the current fallback rank.
  51059. * @returns the new fallback rank.
  51060. */
  51061. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51062. /**
  51063. * Add the required uniforms to the current list.
  51064. * @param uniforms defines the current uniform list.
  51065. */
  51066. static AddUniforms(uniforms: string[]): void;
  51067. /**
  51068. * Add the required samplers to the current list.
  51069. * @param samplers defines the current sampler list.
  51070. */
  51071. static AddSamplers(samplers: string[]): void;
  51072. /**
  51073. * Add the required uniforms to the current buffer.
  51074. * @param uniformBuffer defines the current uniform buffer.
  51075. */
  51076. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51077. /**
  51078. * Makes a duplicate of the current configuration into another one.
  51079. * @param configuration define the config where to copy the info
  51080. */
  51081. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  51082. /**
  51083. * Serializes this Sub Surface configuration.
  51084. * @returns - An object with the serialized config.
  51085. */
  51086. serialize(): any;
  51087. /**
  51088. * Parses a anisotropy Configuration from a serialized object.
  51089. * @param source - Serialized object.
  51090. * @param scene Defines the scene we are parsing for
  51091. * @param rootUrl Defines the rootUrl to load from
  51092. */
  51093. parse(source: any, scene: Scene, rootUrl: string): void;
  51094. }
  51095. }
  51096. declare module BABYLON {
  51097. /** @hidden */
  51098. export var pbrFragmentDeclaration: {
  51099. name: string;
  51100. shader: string;
  51101. };
  51102. }
  51103. declare module BABYLON {
  51104. /** @hidden */
  51105. export var pbrUboDeclaration: {
  51106. name: string;
  51107. shader: string;
  51108. };
  51109. }
  51110. declare module BABYLON {
  51111. /** @hidden */
  51112. export var pbrFragmentExtraDeclaration: {
  51113. name: string;
  51114. shader: string;
  51115. };
  51116. }
  51117. declare module BABYLON {
  51118. /** @hidden */
  51119. export var pbrFragmentSamplersDeclaration: {
  51120. name: string;
  51121. shader: string;
  51122. };
  51123. }
  51124. declare module BABYLON {
  51125. /** @hidden */
  51126. export var pbrHelperFunctions: {
  51127. name: string;
  51128. shader: string;
  51129. };
  51130. }
  51131. declare module BABYLON {
  51132. /** @hidden */
  51133. export var harmonicsFunctions: {
  51134. name: string;
  51135. shader: string;
  51136. };
  51137. }
  51138. declare module BABYLON {
  51139. /** @hidden */
  51140. export var pbrDirectLightingSetupFunctions: {
  51141. name: string;
  51142. shader: string;
  51143. };
  51144. }
  51145. declare module BABYLON {
  51146. /** @hidden */
  51147. export var pbrDirectLightingFalloffFunctions: {
  51148. name: string;
  51149. shader: string;
  51150. };
  51151. }
  51152. declare module BABYLON {
  51153. /** @hidden */
  51154. export var pbrBRDFFunctions: {
  51155. name: string;
  51156. shader: string;
  51157. };
  51158. }
  51159. declare module BABYLON {
  51160. /** @hidden */
  51161. export var pbrDirectLightingFunctions: {
  51162. name: string;
  51163. shader: string;
  51164. };
  51165. }
  51166. declare module BABYLON {
  51167. /** @hidden */
  51168. export var pbrIBLFunctions: {
  51169. name: string;
  51170. shader: string;
  51171. };
  51172. }
  51173. declare module BABYLON {
  51174. /** @hidden */
  51175. export var pbrDebug: {
  51176. name: string;
  51177. shader: string;
  51178. };
  51179. }
  51180. declare module BABYLON {
  51181. /** @hidden */
  51182. export var pbrPixelShader: {
  51183. name: string;
  51184. shader: string;
  51185. };
  51186. }
  51187. declare module BABYLON {
  51188. /** @hidden */
  51189. export var pbrVertexDeclaration: {
  51190. name: string;
  51191. shader: string;
  51192. };
  51193. }
  51194. declare module BABYLON {
  51195. /** @hidden */
  51196. export var pbrVertexShader: {
  51197. name: string;
  51198. shader: string;
  51199. };
  51200. }
  51201. declare module BABYLON {
  51202. /**
  51203. * Manages the defines for the PBR Material.
  51204. * @hidden
  51205. */
  51206. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  51207. PBR: boolean;
  51208. MAINUV1: boolean;
  51209. MAINUV2: boolean;
  51210. UV1: boolean;
  51211. UV2: boolean;
  51212. ALBEDO: boolean;
  51213. GAMMAALBEDO: boolean;
  51214. ALBEDODIRECTUV: number;
  51215. VERTEXCOLOR: boolean;
  51216. AMBIENT: boolean;
  51217. AMBIENTDIRECTUV: number;
  51218. AMBIENTINGRAYSCALE: boolean;
  51219. OPACITY: boolean;
  51220. VERTEXALPHA: boolean;
  51221. OPACITYDIRECTUV: number;
  51222. OPACITYRGB: boolean;
  51223. ALPHATEST: boolean;
  51224. DEPTHPREPASS: boolean;
  51225. ALPHABLEND: boolean;
  51226. ALPHAFROMALBEDO: boolean;
  51227. ALPHATESTVALUE: string;
  51228. SPECULAROVERALPHA: boolean;
  51229. RADIANCEOVERALPHA: boolean;
  51230. ALPHAFRESNEL: boolean;
  51231. LINEARALPHAFRESNEL: boolean;
  51232. PREMULTIPLYALPHA: boolean;
  51233. EMISSIVE: boolean;
  51234. EMISSIVEDIRECTUV: number;
  51235. REFLECTIVITY: boolean;
  51236. REFLECTIVITYDIRECTUV: number;
  51237. SPECULARTERM: boolean;
  51238. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  51239. MICROSURFACEAUTOMATIC: boolean;
  51240. LODBASEDMICROSFURACE: boolean;
  51241. MICROSURFACEMAP: boolean;
  51242. MICROSURFACEMAPDIRECTUV: number;
  51243. METALLICWORKFLOW: boolean;
  51244. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  51245. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  51246. METALLNESSSTOREINMETALMAPBLUE: boolean;
  51247. AOSTOREINMETALMAPRED: boolean;
  51248. METALLICF0FACTORFROMMETALLICMAP: boolean;
  51249. ENVIRONMENTBRDF: boolean;
  51250. ENVIRONMENTBRDF_RGBD: boolean;
  51251. NORMAL: boolean;
  51252. TANGENT: boolean;
  51253. BUMP: boolean;
  51254. BUMPDIRECTUV: number;
  51255. OBJECTSPACE_NORMALMAP: boolean;
  51256. PARALLAX: boolean;
  51257. PARALLAXOCCLUSION: boolean;
  51258. NORMALXYSCALE: boolean;
  51259. LIGHTMAP: boolean;
  51260. LIGHTMAPDIRECTUV: number;
  51261. USELIGHTMAPASSHADOWMAP: boolean;
  51262. GAMMALIGHTMAP: boolean;
  51263. RGBDLIGHTMAP: boolean;
  51264. REFLECTION: boolean;
  51265. REFLECTIONMAP_3D: boolean;
  51266. REFLECTIONMAP_SPHERICAL: boolean;
  51267. REFLECTIONMAP_PLANAR: boolean;
  51268. REFLECTIONMAP_CUBIC: boolean;
  51269. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  51270. REFLECTIONMAP_PROJECTION: boolean;
  51271. REFLECTIONMAP_SKYBOX: boolean;
  51272. REFLECTIONMAP_EXPLICIT: boolean;
  51273. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  51274. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  51275. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  51276. INVERTCUBICMAP: boolean;
  51277. USESPHERICALFROMREFLECTIONMAP: boolean;
  51278. USEIRRADIANCEMAP: boolean;
  51279. SPHERICAL_HARMONICS: boolean;
  51280. USESPHERICALINVERTEX: boolean;
  51281. REFLECTIONMAP_OPPOSITEZ: boolean;
  51282. LODINREFLECTIONALPHA: boolean;
  51283. GAMMAREFLECTION: boolean;
  51284. RGBDREFLECTION: boolean;
  51285. LINEARSPECULARREFLECTION: boolean;
  51286. RADIANCEOCCLUSION: boolean;
  51287. HORIZONOCCLUSION: boolean;
  51288. INSTANCES: boolean;
  51289. NUM_BONE_INFLUENCERS: number;
  51290. BonesPerMesh: number;
  51291. BONETEXTURE: boolean;
  51292. NONUNIFORMSCALING: boolean;
  51293. MORPHTARGETS: boolean;
  51294. MORPHTARGETS_NORMAL: boolean;
  51295. MORPHTARGETS_TANGENT: boolean;
  51296. MORPHTARGETS_UV: boolean;
  51297. NUM_MORPH_INFLUENCERS: number;
  51298. IMAGEPROCESSING: boolean;
  51299. VIGNETTE: boolean;
  51300. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51301. VIGNETTEBLENDMODEOPAQUE: boolean;
  51302. TONEMAPPING: boolean;
  51303. TONEMAPPING_ACES: boolean;
  51304. CONTRAST: boolean;
  51305. COLORCURVES: boolean;
  51306. COLORGRADING: boolean;
  51307. COLORGRADING3D: boolean;
  51308. SAMPLER3DGREENDEPTH: boolean;
  51309. SAMPLER3DBGRMAP: boolean;
  51310. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51311. EXPOSURE: boolean;
  51312. MULTIVIEW: boolean;
  51313. USEPHYSICALLIGHTFALLOFF: boolean;
  51314. USEGLTFLIGHTFALLOFF: boolean;
  51315. TWOSIDEDLIGHTING: boolean;
  51316. SHADOWFLOAT: boolean;
  51317. CLIPPLANE: boolean;
  51318. CLIPPLANE2: boolean;
  51319. CLIPPLANE3: boolean;
  51320. CLIPPLANE4: boolean;
  51321. CLIPPLANE5: boolean;
  51322. CLIPPLANE6: boolean;
  51323. POINTSIZE: boolean;
  51324. FOG: boolean;
  51325. LOGARITHMICDEPTH: boolean;
  51326. FORCENORMALFORWARD: boolean;
  51327. SPECULARAA: boolean;
  51328. CLEARCOAT: boolean;
  51329. CLEARCOAT_DEFAULTIOR: boolean;
  51330. CLEARCOAT_TEXTURE: boolean;
  51331. CLEARCOAT_TEXTUREDIRECTUV: number;
  51332. CLEARCOAT_BUMP: boolean;
  51333. CLEARCOAT_BUMPDIRECTUV: number;
  51334. CLEARCOAT_TINT: boolean;
  51335. CLEARCOAT_TINT_TEXTURE: boolean;
  51336. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51337. ANISOTROPIC: boolean;
  51338. ANISOTROPIC_TEXTURE: boolean;
  51339. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51340. BRDF_V_HEIGHT_CORRELATED: boolean;
  51341. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51342. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51343. SHEEN: boolean;
  51344. SHEEN_TEXTURE: boolean;
  51345. SHEEN_TEXTUREDIRECTUV: number;
  51346. SHEEN_LINKWITHALBEDO: boolean;
  51347. SHEEN_ROUGHNESS: boolean;
  51348. SHEEN_ALBEDOSCALING: boolean;
  51349. SUBSURFACE: boolean;
  51350. SS_REFRACTION: boolean;
  51351. SS_TRANSLUCENCY: boolean;
  51352. SS_SCATERRING: boolean;
  51353. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51354. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51355. SS_REFRACTIONMAP_3D: boolean;
  51356. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51357. SS_LODINREFRACTIONALPHA: boolean;
  51358. SS_GAMMAREFRACTION: boolean;
  51359. SS_RGBDREFRACTION: boolean;
  51360. SS_LINEARSPECULARREFRACTION: boolean;
  51361. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51362. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51363. UNLIT: boolean;
  51364. DEBUGMODE: number;
  51365. /**
  51366. * Initializes the PBR Material defines.
  51367. */
  51368. constructor();
  51369. /**
  51370. * Resets the PBR Material defines.
  51371. */
  51372. reset(): void;
  51373. }
  51374. /**
  51375. * The Physically based material base class of BJS.
  51376. *
  51377. * This offers the main features of a standard PBR material.
  51378. * For more information, please refer to the documentation :
  51379. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51380. */
  51381. export abstract class PBRBaseMaterial extends PushMaterial {
  51382. /**
  51383. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51384. */
  51385. static readonly PBRMATERIAL_OPAQUE: number;
  51386. /**
  51387. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51388. */
  51389. static readonly PBRMATERIAL_ALPHATEST: number;
  51390. /**
  51391. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51392. */
  51393. static readonly PBRMATERIAL_ALPHABLEND: number;
  51394. /**
  51395. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51396. * They are also discarded below the alpha cutoff threshold to improve performances.
  51397. */
  51398. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51399. /**
  51400. * Defines the default value of how much AO map is occluding the analytical lights
  51401. * (point spot...).
  51402. */
  51403. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51404. /**
  51405. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51406. */
  51407. static readonly LIGHTFALLOFF_PHYSICAL: number;
  51408. /**
  51409. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51410. * to enhance interoperability with other engines.
  51411. */
  51412. static readonly LIGHTFALLOFF_GLTF: number;
  51413. /**
  51414. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51415. * to enhance interoperability with other materials.
  51416. */
  51417. static readonly LIGHTFALLOFF_STANDARD: number;
  51418. /**
  51419. * Intensity of the direct lights e.g. the four lights available in your scene.
  51420. * This impacts both the direct diffuse and specular highlights.
  51421. */
  51422. protected _directIntensity: number;
  51423. /**
  51424. * Intensity of the emissive part of the material.
  51425. * This helps controlling the emissive effect without modifying the emissive color.
  51426. */
  51427. protected _emissiveIntensity: number;
  51428. /**
  51429. * Intensity of the environment e.g. how much the environment will light the object
  51430. * either through harmonics for rough material or through the refelction for shiny ones.
  51431. */
  51432. protected _environmentIntensity: number;
  51433. /**
  51434. * This is a special control allowing the reduction of the specular highlights coming from the
  51435. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51436. */
  51437. protected _specularIntensity: number;
  51438. /**
  51439. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51440. */
  51441. private _lightingInfos;
  51442. /**
  51443. * Debug Control allowing disabling the bump map on this material.
  51444. */
  51445. protected _disableBumpMap: boolean;
  51446. /**
  51447. * AKA Diffuse Texture in standard nomenclature.
  51448. */
  51449. protected _albedoTexture: Nullable<BaseTexture>;
  51450. /**
  51451. * AKA Occlusion Texture in other nomenclature.
  51452. */
  51453. protected _ambientTexture: Nullable<BaseTexture>;
  51454. /**
  51455. * AKA Occlusion Texture Intensity in other nomenclature.
  51456. */
  51457. protected _ambientTextureStrength: number;
  51458. /**
  51459. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51460. * 1 means it completely occludes it
  51461. * 0 mean it has no impact
  51462. */
  51463. protected _ambientTextureImpactOnAnalyticalLights: number;
  51464. /**
  51465. * Stores the alpha values in a texture.
  51466. */
  51467. protected _opacityTexture: Nullable<BaseTexture>;
  51468. /**
  51469. * Stores the reflection values in a texture.
  51470. */
  51471. protected _reflectionTexture: Nullable<BaseTexture>;
  51472. /**
  51473. * Stores the emissive values in a texture.
  51474. */
  51475. protected _emissiveTexture: Nullable<BaseTexture>;
  51476. /**
  51477. * AKA Specular texture in other nomenclature.
  51478. */
  51479. protected _reflectivityTexture: Nullable<BaseTexture>;
  51480. /**
  51481. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51482. */
  51483. protected _metallicTexture: Nullable<BaseTexture>;
  51484. /**
  51485. * Specifies the metallic scalar of the metallic/roughness workflow.
  51486. * Can also be used to scale the metalness values of the metallic texture.
  51487. */
  51488. protected _metallic: Nullable<number>;
  51489. /**
  51490. * Specifies the roughness scalar of the metallic/roughness workflow.
  51491. * Can also be used to scale the roughness values of the metallic texture.
  51492. */
  51493. protected _roughness: Nullable<number>;
  51494. /**
  51495. * Specifies the an F0 factor to help configuring the material F0.
  51496. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51497. * to 0.5 the previously hard coded value stays the same.
  51498. * Can also be used to scale the F0 values of the metallic texture.
  51499. */
  51500. protected _metallicF0Factor: number;
  51501. /**
  51502. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51503. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51504. * your expectation as it multiplies with the texture data.
  51505. */
  51506. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51507. /**
  51508. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51509. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51510. */
  51511. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51512. /**
  51513. * Stores surface normal data used to displace a mesh in a texture.
  51514. */
  51515. protected _bumpTexture: Nullable<BaseTexture>;
  51516. /**
  51517. * Stores the pre-calculated light information of a mesh in a texture.
  51518. */
  51519. protected _lightmapTexture: Nullable<BaseTexture>;
  51520. /**
  51521. * The color of a material in ambient lighting.
  51522. */
  51523. protected _ambientColor: Color3;
  51524. /**
  51525. * AKA Diffuse Color in other nomenclature.
  51526. */
  51527. protected _albedoColor: Color3;
  51528. /**
  51529. * AKA Specular Color in other nomenclature.
  51530. */
  51531. protected _reflectivityColor: Color3;
  51532. /**
  51533. * The color applied when light is reflected from a material.
  51534. */
  51535. protected _reflectionColor: Color3;
  51536. /**
  51537. * The color applied when light is emitted from a material.
  51538. */
  51539. protected _emissiveColor: Color3;
  51540. /**
  51541. * AKA Glossiness in other nomenclature.
  51542. */
  51543. protected _microSurface: number;
  51544. /**
  51545. * Specifies that the material will use the light map as a show map.
  51546. */
  51547. protected _useLightmapAsShadowmap: boolean;
  51548. /**
  51549. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51550. * makes the reflect vector face the model (under horizon).
  51551. */
  51552. protected _useHorizonOcclusion: boolean;
  51553. /**
  51554. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51555. * too much the area relying on ambient texture to define their ambient occlusion.
  51556. */
  51557. protected _useRadianceOcclusion: boolean;
  51558. /**
  51559. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51560. */
  51561. protected _useAlphaFromAlbedoTexture: boolean;
  51562. /**
  51563. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51564. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51565. */
  51566. protected _useSpecularOverAlpha: boolean;
  51567. /**
  51568. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51569. */
  51570. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51571. /**
  51572. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51573. */
  51574. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51575. /**
  51576. * Specifies if the metallic texture contains the roughness information in its green channel.
  51577. */
  51578. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51579. /**
  51580. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51581. */
  51582. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51583. /**
  51584. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51585. */
  51586. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51587. /**
  51588. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51589. */
  51590. protected _useAmbientInGrayScale: boolean;
  51591. /**
  51592. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51593. * The material will try to infer what glossiness each pixel should be.
  51594. */
  51595. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51596. /**
  51597. * Defines the falloff type used in this material.
  51598. * It by default is Physical.
  51599. */
  51600. protected _lightFalloff: number;
  51601. /**
  51602. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51603. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51604. */
  51605. protected _useRadianceOverAlpha: boolean;
  51606. /**
  51607. * Allows using an object space normal map (instead of tangent space).
  51608. */
  51609. protected _useObjectSpaceNormalMap: boolean;
  51610. /**
  51611. * Allows using the bump map in parallax mode.
  51612. */
  51613. protected _useParallax: boolean;
  51614. /**
  51615. * Allows using the bump map in parallax occlusion mode.
  51616. */
  51617. protected _useParallaxOcclusion: boolean;
  51618. /**
  51619. * Controls the scale bias of the parallax mode.
  51620. */
  51621. protected _parallaxScaleBias: number;
  51622. /**
  51623. * If sets to true, disables all the lights affecting the material.
  51624. */
  51625. protected _disableLighting: boolean;
  51626. /**
  51627. * Number of Simultaneous lights allowed on the material.
  51628. */
  51629. protected _maxSimultaneousLights: number;
  51630. /**
  51631. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51632. */
  51633. protected _invertNormalMapX: boolean;
  51634. /**
  51635. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51636. */
  51637. protected _invertNormalMapY: boolean;
  51638. /**
  51639. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51640. */
  51641. protected _twoSidedLighting: boolean;
  51642. /**
  51643. * Defines the alpha limits in alpha test mode.
  51644. */
  51645. protected _alphaCutOff: number;
  51646. /**
  51647. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51648. */
  51649. protected _forceAlphaTest: boolean;
  51650. /**
  51651. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51652. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51653. */
  51654. protected _useAlphaFresnel: boolean;
  51655. /**
  51656. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51657. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51658. */
  51659. protected _useLinearAlphaFresnel: boolean;
  51660. /**
  51661. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51662. * from cos thetav and roughness:
  51663. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51664. */
  51665. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51666. /**
  51667. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51668. */
  51669. protected _forceIrradianceInFragment: boolean;
  51670. /**
  51671. * Force normal to face away from face.
  51672. */
  51673. protected _forceNormalForward: boolean;
  51674. /**
  51675. * Enables specular anti aliasing in the PBR shader.
  51676. * It will both interacts on the Geometry for analytical and IBL lighting.
  51677. * It also prefilter the roughness map based on the bump values.
  51678. */
  51679. protected _enableSpecularAntiAliasing: boolean;
  51680. /**
  51681. * Default configuration related to image processing available in the PBR Material.
  51682. */
  51683. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51684. /**
  51685. * Keep track of the image processing observer to allow dispose and replace.
  51686. */
  51687. private _imageProcessingObserver;
  51688. /**
  51689. * Attaches a new image processing configuration to the PBR Material.
  51690. * @param configuration
  51691. */
  51692. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51693. /**
  51694. * Stores the available render targets.
  51695. */
  51696. private _renderTargets;
  51697. /**
  51698. * Sets the global ambient color for the material used in lighting calculations.
  51699. */
  51700. private _globalAmbientColor;
  51701. /**
  51702. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  51703. */
  51704. private _useLogarithmicDepth;
  51705. /**
  51706. * If set to true, no lighting calculations will be applied.
  51707. */
  51708. private _unlit;
  51709. private _debugMode;
  51710. /**
  51711. * @hidden
  51712. * This is reserved for the inspector.
  51713. * Defines the material debug mode.
  51714. * It helps seeing only some components of the material while troubleshooting.
  51715. */
  51716. debugMode: number;
  51717. /**
  51718. * @hidden
  51719. * This is reserved for the inspector.
  51720. * Specify from where on screen the debug mode should start.
  51721. * The value goes from -1 (full screen) to 1 (not visible)
  51722. * It helps with side by side comparison against the final render
  51723. * This defaults to -1
  51724. */
  51725. private debugLimit;
  51726. /**
  51727. * @hidden
  51728. * This is reserved for the inspector.
  51729. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51730. * You can use the factor to better multiply the final value.
  51731. */
  51732. private debugFactor;
  51733. /**
  51734. * Defines the clear coat layer parameters for the material.
  51735. */
  51736. readonly clearCoat: PBRClearCoatConfiguration;
  51737. /**
  51738. * Defines the anisotropic parameters for the material.
  51739. */
  51740. readonly anisotropy: PBRAnisotropicConfiguration;
  51741. /**
  51742. * Defines the BRDF parameters for the material.
  51743. */
  51744. readonly brdf: PBRBRDFConfiguration;
  51745. /**
  51746. * Defines the Sheen parameters for the material.
  51747. */
  51748. readonly sheen: PBRSheenConfiguration;
  51749. /**
  51750. * Defines the SubSurface parameters for the material.
  51751. */
  51752. readonly subSurface: PBRSubSurfaceConfiguration;
  51753. /**
  51754. * Custom callback helping to override the default shader used in the material.
  51755. */
  51756. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines, attributes?: string[]) => string;
  51757. protected _rebuildInParallel: boolean;
  51758. /**
  51759. * Instantiates a new PBRMaterial instance.
  51760. *
  51761. * @param name The material name
  51762. * @param scene The scene the material will be use in.
  51763. */
  51764. constructor(name: string, scene: Scene);
  51765. /**
  51766. * Gets a boolean indicating that current material needs to register RTT
  51767. */
  51768. get hasRenderTargetTextures(): boolean;
  51769. /**
  51770. * Gets the name of the material class.
  51771. */
  51772. getClassName(): string;
  51773. /**
  51774. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51775. */
  51776. get useLogarithmicDepth(): boolean;
  51777. /**
  51778. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51779. */
  51780. set useLogarithmicDepth(value: boolean);
  51781. /**
  51782. * Returns true if alpha blending should be disabled.
  51783. */
  51784. protected get _disableAlphaBlending(): boolean;
  51785. /**
  51786. * Specifies whether or not this material should be rendered in alpha blend mode.
  51787. */
  51788. needAlphaBlending(): boolean;
  51789. /**
  51790. * Specifies whether or not this material should be rendered in alpha test mode.
  51791. */
  51792. needAlphaTesting(): boolean;
  51793. /**
  51794. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51795. */
  51796. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  51797. /**
  51798. * Gets the texture used for the alpha test.
  51799. */
  51800. getAlphaTestTexture(): Nullable<BaseTexture>;
  51801. /**
  51802. * Specifies that the submesh is ready to be used.
  51803. * @param mesh - BJS mesh.
  51804. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51805. * @param useInstances - Specifies that instances should be used.
  51806. * @returns - boolean indicating that the submesh is ready or not.
  51807. */
  51808. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51809. /**
  51810. * Specifies if the material uses metallic roughness workflow.
  51811. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51812. */
  51813. isMetallicWorkflow(): boolean;
  51814. private _prepareEffect;
  51815. private _prepareDefines;
  51816. /**
  51817. * Force shader compilation
  51818. */
  51819. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  51820. /**
  51821. * Initializes the uniform buffer layout for the shader.
  51822. */
  51823. buildUniformLayout(): void;
  51824. /**
  51825. * Unbinds the material from the mesh
  51826. */
  51827. unbind(): void;
  51828. /**
  51829. * Binds the submesh data.
  51830. * @param world - The world matrix.
  51831. * @param mesh - The BJS mesh.
  51832. * @param subMesh - A submesh of the BJS mesh.
  51833. */
  51834. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51835. /**
  51836. * Returns the animatable textures.
  51837. * @returns - Array of animatable textures.
  51838. */
  51839. getAnimatables(): IAnimatable[];
  51840. /**
  51841. * Returns the texture used for reflections.
  51842. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51843. */
  51844. private _getReflectionTexture;
  51845. /**
  51846. * Returns an array of the actively used textures.
  51847. * @returns - Array of BaseTextures
  51848. */
  51849. getActiveTextures(): BaseTexture[];
  51850. /**
  51851. * Checks to see if a texture is used in the material.
  51852. * @param texture - Base texture to use.
  51853. * @returns - Boolean specifying if a texture is used in the material.
  51854. */
  51855. hasTexture(texture: BaseTexture): boolean;
  51856. /**
  51857. * Disposes the resources of the material.
  51858. * @param forceDisposeEffect - Forces the disposal of effects.
  51859. * @param forceDisposeTextures - Forces the disposal of all textures.
  51860. */
  51861. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51862. }
  51863. }
  51864. declare module BABYLON {
  51865. /**
  51866. * The Physically based material of BJS.
  51867. *
  51868. * This offers the main features of a standard PBR material.
  51869. * For more information, please refer to the documentation :
  51870. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51871. */
  51872. export class PBRMaterial extends PBRBaseMaterial {
  51873. /**
  51874. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51875. */
  51876. static readonly PBRMATERIAL_OPAQUE: number;
  51877. /**
  51878. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51879. */
  51880. static readonly PBRMATERIAL_ALPHATEST: number;
  51881. /**
  51882. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51883. */
  51884. static readonly PBRMATERIAL_ALPHABLEND: number;
  51885. /**
  51886. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51887. * They are also discarded below the alpha cutoff threshold to improve performances.
  51888. */
  51889. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51890. /**
  51891. * Defines the default value of how much AO map is occluding the analytical lights
  51892. * (point spot...).
  51893. */
  51894. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51895. /**
  51896. * Intensity of the direct lights e.g. the four lights available in your scene.
  51897. * This impacts both the direct diffuse and specular highlights.
  51898. */
  51899. directIntensity: number;
  51900. /**
  51901. * Intensity of the emissive part of the material.
  51902. * This helps controlling the emissive effect without modifying the emissive color.
  51903. */
  51904. emissiveIntensity: number;
  51905. /**
  51906. * Intensity of the environment e.g. how much the environment will light the object
  51907. * either through harmonics for rough material or through the refelction for shiny ones.
  51908. */
  51909. environmentIntensity: number;
  51910. /**
  51911. * This is a special control allowing the reduction of the specular highlights coming from the
  51912. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51913. */
  51914. specularIntensity: number;
  51915. /**
  51916. * Debug Control allowing disabling the bump map on this material.
  51917. */
  51918. disableBumpMap: boolean;
  51919. /**
  51920. * AKA Diffuse Texture in standard nomenclature.
  51921. */
  51922. albedoTexture: BaseTexture;
  51923. /**
  51924. * AKA Occlusion Texture in other nomenclature.
  51925. */
  51926. ambientTexture: BaseTexture;
  51927. /**
  51928. * AKA Occlusion Texture Intensity in other nomenclature.
  51929. */
  51930. ambientTextureStrength: number;
  51931. /**
  51932. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51933. * 1 means it completely occludes it
  51934. * 0 mean it has no impact
  51935. */
  51936. ambientTextureImpactOnAnalyticalLights: number;
  51937. /**
  51938. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  51939. */
  51940. opacityTexture: BaseTexture;
  51941. /**
  51942. * Stores the reflection values in a texture.
  51943. */
  51944. reflectionTexture: Nullable<BaseTexture>;
  51945. /**
  51946. * Stores the emissive values in a texture.
  51947. */
  51948. emissiveTexture: BaseTexture;
  51949. /**
  51950. * AKA Specular texture in other nomenclature.
  51951. */
  51952. reflectivityTexture: BaseTexture;
  51953. /**
  51954. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51955. */
  51956. metallicTexture: BaseTexture;
  51957. /**
  51958. * Specifies the metallic scalar of the metallic/roughness workflow.
  51959. * Can also be used to scale the metalness values of the metallic texture.
  51960. */
  51961. metallic: Nullable<number>;
  51962. /**
  51963. * Specifies the roughness scalar of the metallic/roughness workflow.
  51964. * Can also be used to scale the roughness values of the metallic texture.
  51965. */
  51966. roughness: Nullable<number>;
  51967. /**
  51968. * Specifies the an F0 factor to help configuring the material F0.
  51969. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51970. * to 0.5 the previously hard coded value stays the same.
  51971. * Can also be used to scale the F0 values of the metallic texture.
  51972. */
  51973. metallicF0Factor: number;
  51974. /**
  51975. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51976. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51977. * your expectation as it multiplies with the texture data.
  51978. */
  51979. useMetallicF0FactorFromMetallicTexture: boolean;
  51980. /**
  51981. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51982. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51983. */
  51984. microSurfaceTexture: BaseTexture;
  51985. /**
  51986. * Stores surface normal data used to displace a mesh in a texture.
  51987. */
  51988. bumpTexture: BaseTexture;
  51989. /**
  51990. * Stores the pre-calculated light information of a mesh in a texture.
  51991. */
  51992. lightmapTexture: BaseTexture;
  51993. /**
  51994. * Stores the refracted light information in a texture.
  51995. */
  51996. get refractionTexture(): Nullable<BaseTexture>;
  51997. set refractionTexture(value: Nullable<BaseTexture>);
  51998. /**
  51999. * The color of a material in ambient lighting.
  52000. */
  52001. ambientColor: Color3;
  52002. /**
  52003. * AKA Diffuse Color in other nomenclature.
  52004. */
  52005. albedoColor: Color3;
  52006. /**
  52007. * AKA Specular Color in other nomenclature.
  52008. */
  52009. reflectivityColor: Color3;
  52010. /**
  52011. * The color reflected from the material.
  52012. */
  52013. reflectionColor: Color3;
  52014. /**
  52015. * The color emitted from the material.
  52016. */
  52017. emissiveColor: Color3;
  52018. /**
  52019. * AKA Glossiness in other nomenclature.
  52020. */
  52021. microSurface: number;
  52022. /**
  52023. * source material index of refraction (IOR)' / 'destination material IOR.
  52024. */
  52025. get indexOfRefraction(): number;
  52026. set indexOfRefraction(value: number);
  52027. /**
  52028. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52029. */
  52030. get invertRefractionY(): boolean;
  52031. set invertRefractionY(value: boolean);
  52032. /**
  52033. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52034. * Materials half opaque for instance using refraction could benefit from this control.
  52035. */
  52036. get linkRefractionWithTransparency(): boolean;
  52037. set linkRefractionWithTransparency(value: boolean);
  52038. /**
  52039. * If true, the light map contains occlusion information instead of lighting info.
  52040. */
  52041. useLightmapAsShadowmap: boolean;
  52042. /**
  52043. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52044. */
  52045. useAlphaFromAlbedoTexture: boolean;
  52046. /**
  52047. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52048. */
  52049. forceAlphaTest: boolean;
  52050. /**
  52051. * Defines the alpha limits in alpha test mode.
  52052. */
  52053. alphaCutOff: number;
  52054. /**
  52055. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  52056. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52057. */
  52058. useSpecularOverAlpha: boolean;
  52059. /**
  52060. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52061. */
  52062. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52063. /**
  52064. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52065. */
  52066. useRoughnessFromMetallicTextureAlpha: boolean;
  52067. /**
  52068. * Specifies if the metallic texture contains the roughness information in its green channel.
  52069. */
  52070. useRoughnessFromMetallicTextureGreen: boolean;
  52071. /**
  52072. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52073. */
  52074. useMetallnessFromMetallicTextureBlue: boolean;
  52075. /**
  52076. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52077. */
  52078. useAmbientOcclusionFromMetallicTextureRed: boolean;
  52079. /**
  52080. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52081. */
  52082. useAmbientInGrayScale: boolean;
  52083. /**
  52084. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52085. * The material will try to infer what glossiness each pixel should be.
  52086. */
  52087. useAutoMicroSurfaceFromReflectivityMap: boolean;
  52088. /**
  52089. * BJS is using an harcoded light falloff based on a manually sets up range.
  52090. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52091. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52092. */
  52093. get usePhysicalLightFalloff(): boolean;
  52094. /**
  52095. * BJS is using an harcoded light falloff based on a manually sets up range.
  52096. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52097. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52098. */
  52099. set usePhysicalLightFalloff(value: boolean);
  52100. /**
  52101. * In order to support the falloff compatibility with gltf, a special mode has been added
  52102. * to reproduce the gltf light falloff.
  52103. */
  52104. get useGLTFLightFalloff(): boolean;
  52105. /**
  52106. * In order to support the falloff compatibility with gltf, a special mode has been added
  52107. * to reproduce the gltf light falloff.
  52108. */
  52109. set useGLTFLightFalloff(value: boolean);
  52110. /**
  52111. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52112. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52113. */
  52114. useRadianceOverAlpha: boolean;
  52115. /**
  52116. * Allows using an object space normal map (instead of tangent space).
  52117. */
  52118. useObjectSpaceNormalMap: boolean;
  52119. /**
  52120. * Allows using the bump map in parallax mode.
  52121. */
  52122. useParallax: boolean;
  52123. /**
  52124. * Allows using the bump map in parallax occlusion mode.
  52125. */
  52126. useParallaxOcclusion: boolean;
  52127. /**
  52128. * Controls the scale bias of the parallax mode.
  52129. */
  52130. parallaxScaleBias: number;
  52131. /**
  52132. * If sets to true, disables all the lights affecting the material.
  52133. */
  52134. disableLighting: boolean;
  52135. /**
  52136. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52137. */
  52138. forceIrradianceInFragment: boolean;
  52139. /**
  52140. * Number of Simultaneous lights allowed on the material.
  52141. */
  52142. maxSimultaneousLights: number;
  52143. /**
  52144. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52145. */
  52146. invertNormalMapX: boolean;
  52147. /**
  52148. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52149. */
  52150. invertNormalMapY: boolean;
  52151. /**
  52152. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52153. */
  52154. twoSidedLighting: boolean;
  52155. /**
  52156. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52157. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52158. */
  52159. useAlphaFresnel: boolean;
  52160. /**
  52161. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52162. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52163. */
  52164. useLinearAlphaFresnel: boolean;
  52165. /**
  52166. * Let user defines the brdf lookup texture used for IBL.
  52167. * A default 8bit version is embedded but you could point at :
  52168. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  52169. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  52170. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  52171. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  52172. */
  52173. environmentBRDFTexture: Nullable<BaseTexture>;
  52174. /**
  52175. * Force normal to face away from face.
  52176. */
  52177. forceNormalForward: boolean;
  52178. /**
  52179. * Enables specular anti aliasing in the PBR shader.
  52180. * It will both interacts on the Geometry for analytical and IBL lighting.
  52181. * It also prefilter the roughness map based on the bump values.
  52182. */
  52183. enableSpecularAntiAliasing: boolean;
  52184. /**
  52185. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52186. * makes the reflect vector face the model (under horizon).
  52187. */
  52188. useHorizonOcclusion: boolean;
  52189. /**
  52190. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52191. * too much the area relying on ambient texture to define their ambient occlusion.
  52192. */
  52193. useRadianceOcclusion: boolean;
  52194. /**
  52195. * If set to true, no lighting calculations will be applied.
  52196. */
  52197. unlit: boolean;
  52198. /**
  52199. * Gets the image processing configuration used either in this material.
  52200. */
  52201. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  52202. /**
  52203. * Sets the Default image processing configuration used either in the this material.
  52204. *
  52205. * If sets to null, the scene one is in use.
  52206. */
  52207. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  52208. /**
  52209. * Gets wether the color curves effect is enabled.
  52210. */
  52211. get cameraColorCurvesEnabled(): boolean;
  52212. /**
  52213. * Sets wether the color curves effect is enabled.
  52214. */
  52215. set cameraColorCurvesEnabled(value: boolean);
  52216. /**
  52217. * Gets wether the color grading effect is enabled.
  52218. */
  52219. get cameraColorGradingEnabled(): boolean;
  52220. /**
  52221. * Gets wether the color grading effect is enabled.
  52222. */
  52223. set cameraColorGradingEnabled(value: boolean);
  52224. /**
  52225. * Gets wether tonemapping is enabled or not.
  52226. */
  52227. get cameraToneMappingEnabled(): boolean;
  52228. /**
  52229. * Sets wether tonemapping is enabled or not
  52230. */
  52231. set cameraToneMappingEnabled(value: boolean);
  52232. /**
  52233. * The camera exposure used on this material.
  52234. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52235. * This corresponds to a photographic exposure.
  52236. */
  52237. get cameraExposure(): number;
  52238. /**
  52239. * The camera exposure used on this material.
  52240. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52241. * This corresponds to a photographic exposure.
  52242. */
  52243. set cameraExposure(value: number);
  52244. /**
  52245. * Gets The camera contrast used on this material.
  52246. */
  52247. get cameraContrast(): number;
  52248. /**
  52249. * Sets The camera contrast used on this material.
  52250. */
  52251. set cameraContrast(value: number);
  52252. /**
  52253. * Gets the Color Grading 2D Lookup Texture.
  52254. */
  52255. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52256. /**
  52257. * Sets the Color Grading 2D Lookup Texture.
  52258. */
  52259. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52260. /**
  52261. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52262. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52263. * 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;
  52264. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52265. */
  52266. get cameraColorCurves(): Nullable<ColorCurves>;
  52267. /**
  52268. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52269. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52270. * 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;
  52271. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52272. */
  52273. set cameraColorCurves(value: Nullable<ColorCurves>);
  52274. /**
  52275. * Instantiates a new PBRMaterial instance.
  52276. *
  52277. * @param name The material name
  52278. * @param scene The scene the material will be use in.
  52279. */
  52280. constructor(name: string, scene: Scene);
  52281. /**
  52282. * Returns the name of this material class.
  52283. */
  52284. getClassName(): string;
  52285. /**
  52286. * Makes a duplicate of the current material.
  52287. * @param name - name to use for the new material.
  52288. */
  52289. clone(name: string): PBRMaterial;
  52290. /**
  52291. * Serializes this PBR Material.
  52292. * @returns - An object with the serialized material.
  52293. */
  52294. serialize(): any;
  52295. /**
  52296. * Parses a PBR Material from a serialized object.
  52297. * @param source - Serialized object.
  52298. * @param scene - BJS scene instance.
  52299. * @param rootUrl - url for the scene object
  52300. * @returns - PBRMaterial
  52301. */
  52302. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  52303. }
  52304. }
  52305. declare module BABYLON {
  52306. /**
  52307. * Direct draw surface info
  52308. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  52309. */
  52310. export interface DDSInfo {
  52311. /**
  52312. * Width of the texture
  52313. */
  52314. width: number;
  52315. /**
  52316. * Width of the texture
  52317. */
  52318. height: number;
  52319. /**
  52320. * Number of Mipmaps for the texture
  52321. * @see https://en.wikipedia.org/wiki/Mipmap
  52322. */
  52323. mipmapCount: number;
  52324. /**
  52325. * If the textures format is a known fourCC format
  52326. * @see https://www.fourcc.org/
  52327. */
  52328. isFourCC: boolean;
  52329. /**
  52330. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  52331. */
  52332. isRGB: boolean;
  52333. /**
  52334. * If the texture is a lumincance format
  52335. */
  52336. isLuminance: boolean;
  52337. /**
  52338. * If this is a cube texture
  52339. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  52340. */
  52341. isCube: boolean;
  52342. /**
  52343. * If the texture is a compressed format eg. FOURCC_DXT1
  52344. */
  52345. isCompressed: boolean;
  52346. /**
  52347. * The dxgiFormat of the texture
  52348. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  52349. */
  52350. dxgiFormat: number;
  52351. /**
  52352. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  52353. */
  52354. textureType: number;
  52355. /**
  52356. * Sphericle polynomial created for the dds texture
  52357. */
  52358. sphericalPolynomial?: SphericalPolynomial;
  52359. }
  52360. /**
  52361. * Class used to provide DDS decompression tools
  52362. */
  52363. export class DDSTools {
  52364. /**
  52365. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  52366. */
  52367. static StoreLODInAlphaChannel: boolean;
  52368. /**
  52369. * Gets DDS information from an array buffer
  52370. * @param data defines the array buffer view to read data from
  52371. * @returns the DDS information
  52372. */
  52373. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  52374. private static _FloatView;
  52375. private static _Int32View;
  52376. private static _ToHalfFloat;
  52377. private static _FromHalfFloat;
  52378. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  52379. private static _GetHalfFloatRGBAArrayBuffer;
  52380. private static _GetFloatRGBAArrayBuffer;
  52381. private static _GetFloatAsUIntRGBAArrayBuffer;
  52382. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  52383. private static _GetRGBAArrayBuffer;
  52384. private static _ExtractLongWordOrder;
  52385. private static _GetRGBArrayBuffer;
  52386. private static _GetLuminanceArrayBuffer;
  52387. /**
  52388. * Uploads DDS Levels to a Babylon Texture
  52389. * @hidden
  52390. */
  52391. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  52392. }
  52393. interface ThinEngine {
  52394. /**
  52395. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52396. * @param rootUrl defines the url where the file to load is located
  52397. * @param scene defines the current scene
  52398. * @param lodScale defines scale to apply to the mip map selection
  52399. * @param lodOffset defines offset to apply to the mip map selection
  52400. * @param onLoad defines an optional callback raised when the texture is loaded
  52401. * @param onError defines an optional callback raised if there is an issue to load the texture
  52402. * @param format defines the format of the data
  52403. * @param forcedExtension defines the extension to use to pick the right loader
  52404. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52405. * @returns the cube texture as an InternalTexture
  52406. */
  52407. 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;
  52408. }
  52409. }
  52410. declare module BABYLON {
  52411. /**
  52412. * Implementation of the DDS Texture Loader.
  52413. * @hidden
  52414. */
  52415. export class _DDSTextureLoader implements IInternalTextureLoader {
  52416. /**
  52417. * Defines wether the loader supports cascade loading the different faces.
  52418. */
  52419. readonly supportCascades: boolean;
  52420. /**
  52421. * This returns if the loader support the current file information.
  52422. * @param extension defines the file extension of the file being loaded
  52423. * @returns true if the loader can load the specified file
  52424. */
  52425. canLoad(extension: string): boolean;
  52426. /**
  52427. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52428. * @param data contains the texture data
  52429. * @param texture defines the BabylonJS internal texture
  52430. * @param createPolynomials will be true if polynomials have been requested
  52431. * @param onLoad defines the callback to trigger once the texture is ready
  52432. * @param onError defines the callback to trigger in case of error
  52433. */
  52434. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52435. /**
  52436. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52437. * @param data contains the texture data
  52438. * @param texture defines the BabylonJS internal texture
  52439. * @param callback defines the method to call once ready to upload
  52440. */
  52441. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52442. }
  52443. }
  52444. declare module BABYLON {
  52445. /**
  52446. * Implementation of the ENV Texture Loader.
  52447. * @hidden
  52448. */
  52449. export class _ENVTextureLoader implements IInternalTextureLoader {
  52450. /**
  52451. * Defines wether the loader supports cascade loading the different faces.
  52452. */
  52453. readonly supportCascades: boolean;
  52454. /**
  52455. * This returns if the loader support the current file information.
  52456. * @param extension defines the file extension of the file being loaded
  52457. * @returns true if the loader can load the specified file
  52458. */
  52459. canLoad(extension: string): boolean;
  52460. /**
  52461. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52462. * @param data contains the texture data
  52463. * @param texture defines the BabylonJS internal texture
  52464. * @param createPolynomials will be true if polynomials have been requested
  52465. * @param onLoad defines the callback to trigger once the texture is ready
  52466. * @param onError defines the callback to trigger in case of error
  52467. */
  52468. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52469. /**
  52470. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52471. * @param data contains the texture data
  52472. * @param texture defines the BabylonJS internal texture
  52473. * @param callback defines the method to call once ready to upload
  52474. */
  52475. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52476. }
  52477. }
  52478. declare module BABYLON {
  52479. /**
  52480. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52481. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52482. */
  52483. export class KhronosTextureContainer {
  52484. /** contents of the KTX container file */
  52485. data: ArrayBufferView;
  52486. private static HEADER_LEN;
  52487. private static COMPRESSED_2D;
  52488. private static COMPRESSED_3D;
  52489. private static TEX_2D;
  52490. private static TEX_3D;
  52491. /**
  52492. * Gets the openGL type
  52493. */
  52494. glType: number;
  52495. /**
  52496. * Gets the openGL type size
  52497. */
  52498. glTypeSize: number;
  52499. /**
  52500. * Gets the openGL format
  52501. */
  52502. glFormat: number;
  52503. /**
  52504. * Gets the openGL internal format
  52505. */
  52506. glInternalFormat: number;
  52507. /**
  52508. * Gets the base internal format
  52509. */
  52510. glBaseInternalFormat: number;
  52511. /**
  52512. * Gets image width in pixel
  52513. */
  52514. pixelWidth: number;
  52515. /**
  52516. * Gets image height in pixel
  52517. */
  52518. pixelHeight: number;
  52519. /**
  52520. * Gets image depth in pixels
  52521. */
  52522. pixelDepth: number;
  52523. /**
  52524. * Gets the number of array elements
  52525. */
  52526. numberOfArrayElements: number;
  52527. /**
  52528. * Gets the number of faces
  52529. */
  52530. numberOfFaces: number;
  52531. /**
  52532. * Gets the number of mipmap levels
  52533. */
  52534. numberOfMipmapLevels: number;
  52535. /**
  52536. * Gets the bytes of key value data
  52537. */
  52538. bytesOfKeyValueData: number;
  52539. /**
  52540. * Gets the load type
  52541. */
  52542. loadType: number;
  52543. /**
  52544. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52545. */
  52546. isInvalid: boolean;
  52547. /**
  52548. * Creates a new KhronosTextureContainer
  52549. * @param data contents of the KTX container file
  52550. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52551. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52552. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52553. */
  52554. constructor(
  52555. /** contents of the KTX container file */
  52556. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52557. /**
  52558. * Uploads KTX content to a Babylon Texture.
  52559. * It is assumed that the texture has already been created & is currently bound
  52560. * @hidden
  52561. */
  52562. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52563. private _upload2DCompressedLevels;
  52564. /**
  52565. * Checks if the given data starts with a KTX file identifier.
  52566. * @param data the data to check
  52567. * @returns true if the data is a KTX file or false otherwise
  52568. */
  52569. static IsValid(data: ArrayBufferView): boolean;
  52570. }
  52571. }
  52572. declare module BABYLON {
  52573. /**
  52574. * Class for loading KTX2 files
  52575. * !!! Experimental Extension Subject to Changes !!!
  52576. * @hidden
  52577. */
  52578. export class KhronosTextureContainer2 {
  52579. private static _ModulePromise;
  52580. private static _TranscodeFormat;
  52581. constructor(engine: ThinEngine);
  52582. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  52583. private _determineTranscodeFormat;
  52584. /**
  52585. * Checks if the given data starts with a KTX2 file identifier.
  52586. * @param data the data to check
  52587. * @returns true if the data is a KTX2 file or false otherwise
  52588. */
  52589. static IsValid(data: ArrayBufferView): boolean;
  52590. }
  52591. }
  52592. declare module BABYLON {
  52593. /**
  52594. * Implementation of the KTX Texture Loader.
  52595. * @hidden
  52596. */
  52597. export class _KTXTextureLoader implements IInternalTextureLoader {
  52598. /**
  52599. * Defines wether the loader supports cascade loading the different faces.
  52600. */
  52601. readonly supportCascades: boolean;
  52602. /**
  52603. * This returns if the loader support the current file information.
  52604. * @param extension defines the file extension of the file being loaded
  52605. * @returns true if the loader can load the specified file
  52606. */
  52607. canLoad(extension: string): boolean;
  52608. /**
  52609. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52610. * @param data contains the texture data
  52611. * @param texture defines the BabylonJS internal texture
  52612. * @param createPolynomials will be true if polynomials have been requested
  52613. * @param onLoad defines the callback to trigger once the texture is ready
  52614. * @param onError defines the callback to trigger in case of error
  52615. */
  52616. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52617. /**
  52618. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52619. * @param data contains the texture data
  52620. * @param texture defines the BabylonJS internal texture
  52621. * @param callback defines the method to call once ready to upload
  52622. */
  52623. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52624. }
  52625. }
  52626. declare module BABYLON {
  52627. /** @hidden */
  52628. export var _forceSceneHelpersToBundle: boolean;
  52629. interface Scene {
  52630. /**
  52631. * Creates a default light for the scene.
  52632. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52633. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52634. */
  52635. createDefaultLight(replace?: boolean): void;
  52636. /**
  52637. * Creates a default camera for the scene.
  52638. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52639. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52640. * @param replace has default false, when true replaces the active camera in the scene
  52641. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52642. */
  52643. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52644. /**
  52645. * Creates a default camera and a default light.
  52646. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52647. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52648. * @param replace has the default false, when true replaces the active camera/light in the scene
  52649. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  52650. */
  52651. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52652. /**
  52653. * Creates a new sky box
  52654. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  52655. * @param environmentTexture defines the texture to use as environment texture
  52656. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  52657. * @param scale defines the overall scale of the skybox
  52658. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  52659. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  52660. * @returns a new mesh holding the sky box
  52661. */
  52662. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  52663. /**
  52664. * Creates a new environment
  52665. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  52666. * @param options defines the options you can use to configure the environment
  52667. * @returns the new EnvironmentHelper
  52668. */
  52669. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  52670. /**
  52671. * Creates a new VREXperienceHelper
  52672. * @see http://doc.babylonjs.com/how_to/webvr_helper
  52673. * @param webVROptions defines the options used to create the new VREXperienceHelper
  52674. * @returns a new VREXperienceHelper
  52675. */
  52676. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  52677. /**
  52678. * Creates a new WebXRDefaultExperience
  52679. * @see http://doc.babylonjs.com/how_to/webxr
  52680. * @param options experience options
  52681. * @returns a promise for a new WebXRDefaultExperience
  52682. */
  52683. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52684. }
  52685. }
  52686. declare module BABYLON {
  52687. /**
  52688. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  52689. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  52690. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  52691. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52692. */
  52693. export class VideoDome extends TransformNode {
  52694. /**
  52695. * Define the video source as a Monoscopic panoramic 360 video.
  52696. */
  52697. static readonly MODE_MONOSCOPIC: number;
  52698. /**
  52699. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52700. */
  52701. static readonly MODE_TOPBOTTOM: number;
  52702. /**
  52703. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52704. */
  52705. static readonly MODE_SIDEBYSIDE: number;
  52706. private _halfDome;
  52707. private _useDirectMapping;
  52708. /**
  52709. * The video texture being displayed on the sphere
  52710. */
  52711. protected _videoTexture: VideoTexture;
  52712. /**
  52713. * Gets the video texture being displayed on the sphere
  52714. */
  52715. get videoTexture(): VideoTexture;
  52716. /**
  52717. * The skybox material
  52718. */
  52719. protected _material: BackgroundMaterial;
  52720. /**
  52721. * The surface used for the skybox
  52722. */
  52723. protected _mesh: Mesh;
  52724. /**
  52725. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  52726. */
  52727. private _halfDomeMask;
  52728. /**
  52729. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52730. * Also see the options.resolution property.
  52731. */
  52732. get fovMultiplier(): number;
  52733. set fovMultiplier(value: number);
  52734. private _videoMode;
  52735. /**
  52736. * Gets or set the current video mode for the video. It can be:
  52737. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  52738. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52739. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52740. */
  52741. get videoMode(): number;
  52742. set videoMode(value: number);
  52743. /**
  52744. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  52745. *
  52746. */
  52747. get halfDome(): boolean;
  52748. /**
  52749. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  52750. */
  52751. set halfDome(enabled: boolean);
  52752. /**
  52753. * Oberserver used in Stereoscopic VR Mode.
  52754. */
  52755. private _onBeforeCameraRenderObserver;
  52756. /**
  52757. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  52758. * @param name Element's name, child elements will append suffixes for their own names.
  52759. * @param urlsOrVideo defines the url(s) or the video element to use
  52760. * @param options An object containing optional or exposed sub element properties
  52761. */
  52762. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  52763. resolution?: number;
  52764. clickToPlay?: boolean;
  52765. autoPlay?: boolean;
  52766. loop?: boolean;
  52767. size?: number;
  52768. poster?: string;
  52769. faceForward?: boolean;
  52770. useDirectMapping?: boolean;
  52771. halfDomeMode?: boolean;
  52772. }, scene: Scene);
  52773. private _changeVideoMode;
  52774. /**
  52775. * Releases resources associated with this node.
  52776. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52777. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52778. */
  52779. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52780. }
  52781. }
  52782. declare module BABYLON {
  52783. /**
  52784. * This class can be used to get instrumentation data from a Babylon engine
  52785. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52786. */
  52787. export class EngineInstrumentation implements IDisposable {
  52788. /**
  52789. * Define the instrumented engine.
  52790. */
  52791. engine: Engine;
  52792. private _captureGPUFrameTime;
  52793. private _gpuFrameTimeToken;
  52794. private _gpuFrameTime;
  52795. private _captureShaderCompilationTime;
  52796. private _shaderCompilationTime;
  52797. private _onBeginFrameObserver;
  52798. private _onEndFrameObserver;
  52799. private _onBeforeShaderCompilationObserver;
  52800. private _onAfterShaderCompilationObserver;
  52801. /**
  52802. * Gets the perf counter used for GPU frame time
  52803. */
  52804. get gpuFrameTimeCounter(): PerfCounter;
  52805. /**
  52806. * Gets the GPU frame time capture status
  52807. */
  52808. get captureGPUFrameTime(): boolean;
  52809. /**
  52810. * Enable or disable the GPU frame time capture
  52811. */
  52812. set captureGPUFrameTime(value: boolean);
  52813. /**
  52814. * Gets the perf counter used for shader compilation time
  52815. */
  52816. get shaderCompilationTimeCounter(): PerfCounter;
  52817. /**
  52818. * Gets the shader compilation time capture status
  52819. */
  52820. get captureShaderCompilationTime(): boolean;
  52821. /**
  52822. * Enable or disable the shader compilation time capture
  52823. */
  52824. set captureShaderCompilationTime(value: boolean);
  52825. /**
  52826. * Instantiates a new engine instrumentation.
  52827. * This class can be used to get instrumentation data from a Babylon engine
  52828. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52829. * @param engine Defines the engine to instrument
  52830. */
  52831. constructor(
  52832. /**
  52833. * Define the instrumented engine.
  52834. */
  52835. engine: Engine);
  52836. /**
  52837. * Dispose and release associated resources.
  52838. */
  52839. dispose(): void;
  52840. }
  52841. }
  52842. declare module BABYLON {
  52843. /**
  52844. * This class can be used to get instrumentation data from a Babylon engine
  52845. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52846. */
  52847. export class SceneInstrumentation implements IDisposable {
  52848. /**
  52849. * Defines the scene to instrument
  52850. */
  52851. scene: Scene;
  52852. private _captureActiveMeshesEvaluationTime;
  52853. private _activeMeshesEvaluationTime;
  52854. private _captureRenderTargetsRenderTime;
  52855. private _renderTargetsRenderTime;
  52856. private _captureFrameTime;
  52857. private _frameTime;
  52858. private _captureRenderTime;
  52859. private _renderTime;
  52860. private _captureInterFrameTime;
  52861. private _interFrameTime;
  52862. private _captureParticlesRenderTime;
  52863. private _particlesRenderTime;
  52864. private _captureSpritesRenderTime;
  52865. private _spritesRenderTime;
  52866. private _capturePhysicsTime;
  52867. private _physicsTime;
  52868. private _captureAnimationsTime;
  52869. private _animationsTime;
  52870. private _captureCameraRenderTime;
  52871. private _cameraRenderTime;
  52872. private _onBeforeActiveMeshesEvaluationObserver;
  52873. private _onAfterActiveMeshesEvaluationObserver;
  52874. private _onBeforeRenderTargetsRenderObserver;
  52875. private _onAfterRenderTargetsRenderObserver;
  52876. private _onAfterRenderObserver;
  52877. private _onBeforeDrawPhaseObserver;
  52878. private _onAfterDrawPhaseObserver;
  52879. private _onBeforeAnimationsObserver;
  52880. private _onBeforeParticlesRenderingObserver;
  52881. private _onAfterParticlesRenderingObserver;
  52882. private _onBeforeSpritesRenderingObserver;
  52883. private _onAfterSpritesRenderingObserver;
  52884. private _onBeforePhysicsObserver;
  52885. private _onAfterPhysicsObserver;
  52886. private _onAfterAnimationsObserver;
  52887. private _onBeforeCameraRenderObserver;
  52888. private _onAfterCameraRenderObserver;
  52889. /**
  52890. * Gets the perf counter used for active meshes evaluation time
  52891. */
  52892. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  52893. /**
  52894. * Gets the active meshes evaluation time capture status
  52895. */
  52896. get captureActiveMeshesEvaluationTime(): boolean;
  52897. /**
  52898. * Enable or disable the active meshes evaluation time capture
  52899. */
  52900. set captureActiveMeshesEvaluationTime(value: boolean);
  52901. /**
  52902. * Gets the perf counter used for render targets render time
  52903. */
  52904. get renderTargetsRenderTimeCounter(): PerfCounter;
  52905. /**
  52906. * Gets the render targets render time capture status
  52907. */
  52908. get captureRenderTargetsRenderTime(): boolean;
  52909. /**
  52910. * Enable or disable the render targets render time capture
  52911. */
  52912. set captureRenderTargetsRenderTime(value: boolean);
  52913. /**
  52914. * Gets the perf counter used for particles render time
  52915. */
  52916. get particlesRenderTimeCounter(): PerfCounter;
  52917. /**
  52918. * Gets the particles render time capture status
  52919. */
  52920. get captureParticlesRenderTime(): boolean;
  52921. /**
  52922. * Enable or disable the particles render time capture
  52923. */
  52924. set captureParticlesRenderTime(value: boolean);
  52925. /**
  52926. * Gets the perf counter used for sprites render time
  52927. */
  52928. get spritesRenderTimeCounter(): PerfCounter;
  52929. /**
  52930. * Gets the sprites render time capture status
  52931. */
  52932. get captureSpritesRenderTime(): boolean;
  52933. /**
  52934. * Enable or disable the sprites render time capture
  52935. */
  52936. set captureSpritesRenderTime(value: boolean);
  52937. /**
  52938. * Gets the perf counter used for physics time
  52939. */
  52940. get physicsTimeCounter(): PerfCounter;
  52941. /**
  52942. * Gets the physics time capture status
  52943. */
  52944. get capturePhysicsTime(): boolean;
  52945. /**
  52946. * Enable or disable the physics time capture
  52947. */
  52948. set capturePhysicsTime(value: boolean);
  52949. /**
  52950. * Gets the perf counter used for animations time
  52951. */
  52952. get animationsTimeCounter(): PerfCounter;
  52953. /**
  52954. * Gets the animations time capture status
  52955. */
  52956. get captureAnimationsTime(): boolean;
  52957. /**
  52958. * Enable or disable the animations time capture
  52959. */
  52960. set captureAnimationsTime(value: boolean);
  52961. /**
  52962. * Gets the perf counter used for frame time capture
  52963. */
  52964. get frameTimeCounter(): PerfCounter;
  52965. /**
  52966. * Gets the frame time capture status
  52967. */
  52968. get captureFrameTime(): boolean;
  52969. /**
  52970. * Enable or disable the frame time capture
  52971. */
  52972. set captureFrameTime(value: boolean);
  52973. /**
  52974. * Gets the perf counter used for inter-frames time capture
  52975. */
  52976. get interFrameTimeCounter(): PerfCounter;
  52977. /**
  52978. * Gets the inter-frames time capture status
  52979. */
  52980. get captureInterFrameTime(): boolean;
  52981. /**
  52982. * Enable or disable the inter-frames time capture
  52983. */
  52984. set captureInterFrameTime(value: boolean);
  52985. /**
  52986. * Gets the perf counter used for render time capture
  52987. */
  52988. get renderTimeCounter(): PerfCounter;
  52989. /**
  52990. * Gets the render time capture status
  52991. */
  52992. get captureRenderTime(): boolean;
  52993. /**
  52994. * Enable or disable the render time capture
  52995. */
  52996. set captureRenderTime(value: boolean);
  52997. /**
  52998. * Gets the perf counter used for camera render time capture
  52999. */
  53000. get cameraRenderTimeCounter(): PerfCounter;
  53001. /**
  53002. * Gets the camera render time capture status
  53003. */
  53004. get captureCameraRenderTime(): boolean;
  53005. /**
  53006. * Enable or disable the camera render time capture
  53007. */
  53008. set captureCameraRenderTime(value: boolean);
  53009. /**
  53010. * Gets the perf counter used for draw calls
  53011. */
  53012. get drawCallsCounter(): PerfCounter;
  53013. /**
  53014. * Instantiates a new scene instrumentation.
  53015. * This class can be used to get instrumentation data from a Babylon engine
  53016. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53017. * @param scene Defines the scene to instrument
  53018. */
  53019. constructor(
  53020. /**
  53021. * Defines the scene to instrument
  53022. */
  53023. scene: Scene);
  53024. /**
  53025. * Dispose and release associated resources.
  53026. */
  53027. dispose(): void;
  53028. }
  53029. }
  53030. declare module BABYLON {
  53031. /** @hidden */
  53032. export var glowMapGenerationPixelShader: {
  53033. name: string;
  53034. shader: string;
  53035. };
  53036. }
  53037. declare module BABYLON {
  53038. /** @hidden */
  53039. export var glowMapGenerationVertexShader: {
  53040. name: string;
  53041. shader: string;
  53042. };
  53043. }
  53044. declare module BABYLON {
  53045. /**
  53046. * Effect layer options. This helps customizing the behaviour
  53047. * of the effect layer.
  53048. */
  53049. export interface IEffectLayerOptions {
  53050. /**
  53051. * Multiplication factor apply to the canvas size to compute the render target size
  53052. * used to generated the objects (the smaller the faster).
  53053. */
  53054. mainTextureRatio: number;
  53055. /**
  53056. * Enforces a fixed size texture to ensure effect stability across devices.
  53057. */
  53058. mainTextureFixedSize?: number;
  53059. /**
  53060. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  53061. */
  53062. alphaBlendingMode: number;
  53063. /**
  53064. * The camera attached to the layer.
  53065. */
  53066. camera: Nullable<Camera>;
  53067. /**
  53068. * The rendering group to draw the layer in.
  53069. */
  53070. renderingGroupId: number;
  53071. }
  53072. /**
  53073. * The effect layer Helps adding post process effect blended with the main pass.
  53074. *
  53075. * This can be for instance use to generate glow or higlight effects on the scene.
  53076. *
  53077. * The effect layer class can not be used directly and is intented to inherited from to be
  53078. * customized per effects.
  53079. */
  53080. export abstract class EffectLayer {
  53081. private _vertexBuffers;
  53082. private _indexBuffer;
  53083. private _cachedDefines;
  53084. private _effectLayerMapGenerationEffect;
  53085. private _effectLayerOptions;
  53086. private _mergeEffect;
  53087. protected _scene: Scene;
  53088. protected _engine: Engine;
  53089. protected _maxSize: number;
  53090. protected _mainTextureDesiredSize: ISize;
  53091. protected _mainTexture: RenderTargetTexture;
  53092. protected _shouldRender: boolean;
  53093. protected _postProcesses: PostProcess[];
  53094. protected _textures: BaseTexture[];
  53095. protected _emissiveTextureAndColor: {
  53096. texture: Nullable<BaseTexture>;
  53097. color: Color4;
  53098. };
  53099. /**
  53100. * The name of the layer
  53101. */
  53102. name: string;
  53103. /**
  53104. * The clear color of the texture used to generate the glow map.
  53105. */
  53106. neutralColor: Color4;
  53107. /**
  53108. * Specifies whether the highlight layer is enabled or not.
  53109. */
  53110. isEnabled: boolean;
  53111. /**
  53112. * Gets the camera attached to the layer.
  53113. */
  53114. get camera(): Nullable<Camera>;
  53115. /**
  53116. * Gets the rendering group id the layer should render in.
  53117. */
  53118. get renderingGroupId(): number;
  53119. set renderingGroupId(renderingGroupId: number);
  53120. /**
  53121. * An event triggered when the effect layer has been disposed.
  53122. */
  53123. onDisposeObservable: Observable<EffectLayer>;
  53124. /**
  53125. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  53126. */
  53127. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  53128. /**
  53129. * An event triggered when the generated texture is being merged in the scene.
  53130. */
  53131. onBeforeComposeObservable: Observable<EffectLayer>;
  53132. /**
  53133. * An event triggered when the mesh is rendered into the effect render target.
  53134. */
  53135. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  53136. /**
  53137. * An event triggered after the mesh has been rendered into the effect render target.
  53138. */
  53139. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  53140. /**
  53141. * An event triggered when the generated texture has been merged in the scene.
  53142. */
  53143. onAfterComposeObservable: Observable<EffectLayer>;
  53144. /**
  53145. * An event triggered when the efffect layer changes its size.
  53146. */
  53147. onSizeChangedObservable: Observable<EffectLayer>;
  53148. /** @hidden */
  53149. static _SceneComponentInitialization: (scene: Scene) => void;
  53150. /**
  53151. * Instantiates a new effect Layer and references it in the scene.
  53152. * @param name The name of the layer
  53153. * @param scene The scene to use the layer in
  53154. */
  53155. constructor(
  53156. /** The Friendly of the effect in the scene */
  53157. name: string, scene: Scene);
  53158. /**
  53159. * Get the effect name of the layer.
  53160. * @return The effect name
  53161. */
  53162. abstract getEffectName(): string;
  53163. /**
  53164. * Checks for the readiness of the element composing the layer.
  53165. * @param subMesh the mesh to check for
  53166. * @param useInstances specify whether or not to use instances to render the mesh
  53167. * @return true if ready otherwise, false
  53168. */
  53169. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53170. /**
  53171. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53172. * @returns true if the effect requires stencil during the main canvas render pass.
  53173. */
  53174. abstract needStencil(): boolean;
  53175. /**
  53176. * Create the merge effect. This is the shader use to blit the information back
  53177. * to the main canvas at the end of the scene rendering.
  53178. * @returns The effect containing the shader used to merge the effect on the main canvas
  53179. */
  53180. protected abstract _createMergeEffect(): Effect;
  53181. /**
  53182. * Creates the render target textures and post processes used in the effect layer.
  53183. */
  53184. protected abstract _createTextureAndPostProcesses(): void;
  53185. /**
  53186. * Implementation specific of rendering the generating effect on the main canvas.
  53187. * @param effect The effect used to render through
  53188. */
  53189. protected abstract _internalRender(effect: Effect): void;
  53190. /**
  53191. * Sets the required values for both the emissive texture and and the main color.
  53192. */
  53193. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53194. /**
  53195. * Free any resources and references associated to a mesh.
  53196. * Internal use
  53197. * @param mesh The mesh to free.
  53198. */
  53199. abstract _disposeMesh(mesh: Mesh): void;
  53200. /**
  53201. * Serializes this layer (Glow or Highlight for example)
  53202. * @returns a serialized layer object
  53203. */
  53204. abstract serialize?(): any;
  53205. /**
  53206. * Initializes the effect layer with the required options.
  53207. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  53208. */
  53209. protected _init(options: Partial<IEffectLayerOptions>): void;
  53210. /**
  53211. * Generates the index buffer of the full screen quad blending to the main canvas.
  53212. */
  53213. private _generateIndexBuffer;
  53214. /**
  53215. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  53216. */
  53217. private _generateVertexBuffer;
  53218. /**
  53219. * Sets the main texture desired size which is the closest power of two
  53220. * of the engine canvas size.
  53221. */
  53222. private _setMainTextureSize;
  53223. /**
  53224. * Creates the main texture for the effect layer.
  53225. */
  53226. protected _createMainTexture(): void;
  53227. /**
  53228. * Adds specific effects defines.
  53229. * @param defines The defines to add specifics to.
  53230. */
  53231. protected _addCustomEffectDefines(defines: string[]): void;
  53232. /**
  53233. * Checks for the readiness of the element composing the layer.
  53234. * @param subMesh the mesh to check for
  53235. * @param useInstances specify whether or not to use instances to render the mesh
  53236. * @param emissiveTexture the associated emissive texture used to generate the glow
  53237. * @return true if ready otherwise, false
  53238. */
  53239. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  53240. /**
  53241. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  53242. */
  53243. render(): void;
  53244. /**
  53245. * Determine if a given mesh will be used in the current effect.
  53246. * @param mesh mesh to test
  53247. * @returns true if the mesh will be used
  53248. */
  53249. hasMesh(mesh: AbstractMesh): boolean;
  53250. /**
  53251. * Returns true if the layer contains information to display, otherwise false.
  53252. * @returns true if the glow layer should be rendered
  53253. */
  53254. shouldRender(): boolean;
  53255. /**
  53256. * Returns true if the mesh should render, otherwise false.
  53257. * @param mesh The mesh to render
  53258. * @returns true if it should render otherwise false
  53259. */
  53260. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  53261. /**
  53262. * Returns true if the mesh can be rendered, otherwise false.
  53263. * @param mesh The mesh to render
  53264. * @param material The material used on the mesh
  53265. * @returns true if it can be rendered otherwise false
  53266. */
  53267. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53268. /**
  53269. * Returns true if the mesh should render, otherwise false.
  53270. * @param mesh The mesh to render
  53271. * @returns true if it should render otherwise false
  53272. */
  53273. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  53274. /**
  53275. * Renders the submesh passed in parameter to the generation map.
  53276. */
  53277. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  53278. /**
  53279. * Defines whether the current material of the mesh should be use to render the effect.
  53280. * @param mesh defines the current mesh to render
  53281. */
  53282. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53283. /**
  53284. * Rebuild the required buffers.
  53285. * @hidden Internal use only.
  53286. */
  53287. _rebuild(): void;
  53288. /**
  53289. * Dispose only the render target textures and post process.
  53290. */
  53291. private _disposeTextureAndPostProcesses;
  53292. /**
  53293. * Dispose the highlight layer and free resources.
  53294. */
  53295. dispose(): void;
  53296. /**
  53297. * Gets the class name of the effect layer
  53298. * @returns the string with the class name of the effect layer
  53299. */
  53300. getClassName(): string;
  53301. /**
  53302. * Creates an effect layer from parsed effect layer data
  53303. * @param parsedEffectLayer defines effect layer data
  53304. * @param scene defines the current scene
  53305. * @param rootUrl defines the root URL containing the effect layer information
  53306. * @returns a parsed effect Layer
  53307. */
  53308. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  53309. }
  53310. }
  53311. declare module BABYLON {
  53312. interface AbstractScene {
  53313. /**
  53314. * The list of effect layers (highlights/glow) added to the scene
  53315. * @see http://doc.babylonjs.com/how_to/highlight_layer
  53316. * @see http://doc.babylonjs.com/how_to/glow_layer
  53317. */
  53318. effectLayers: Array<EffectLayer>;
  53319. /**
  53320. * Removes the given effect layer from this scene.
  53321. * @param toRemove defines the effect layer to remove
  53322. * @returns the index of the removed effect layer
  53323. */
  53324. removeEffectLayer(toRemove: EffectLayer): number;
  53325. /**
  53326. * Adds the given effect layer to this scene
  53327. * @param newEffectLayer defines the effect layer to add
  53328. */
  53329. addEffectLayer(newEffectLayer: EffectLayer): void;
  53330. }
  53331. /**
  53332. * Defines the layer scene component responsible to manage any effect layers
  53333. * in a given scene.
  53334. */
  53335. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  53336. /**
  53337. * The component name helpfull to identify the component in the list of scene components.
  53338. */
  53339. readonly name: string;
  53340. /**
  53341. * The scene the component belongs to.
  53342. */
  53343. scene: Scene;
  53344. private _engine;
  53345. private _renderEffects;
  53346. private _needStencil;
  53347. private _previousStencilState;
  53348. /**
  53349. * Creates a new instance of the component for the given scene
  53350. * @param scene Defines the scene to register the component in
  53351. */
  53352. constructor(scene: Scene);
  53353. /**
  53354. * Registers the component in a given scene
  53355. */
  53356. register(): void;
  53357. /**
  53358. * Rebuilds the elements related to this component in case of
  53359. * context lost for instance.
  53360. */
  53361. rebuild(): void;
  53362. /**
  53363. * Serializes the component data to the specified json object
  53364. * @param serializationObject The object to serialize to
  53365. */
  53366. serialize(serializationObject: any): void;
  53367. /**
  53368. * Adds all the elements from the container to the scene
  53369. * @param container the container holding the elements
  53370. */
  53371. addFromContainer(container: AbstractScene): void;
  53372. /**
  53373. * Removes all the elements in the container from the scene
  53374. * @param container contains the elements to remove
  53375. * @param dispose if the removed element should be disposed (default: false)
  53376. */
  53377. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53378. /**
  53379. * Disposes the component and the associated ressources.
  53380. */
  53381. dispose(): void;
  53382. private _isReadyForMesh;
  53383. private _renderMainTexture;
  53384. private _setStencil;
  53385. private _setStencilBack;
  53386. private _draw;
  53387. private _drawCamera;
  53388. private _drawRenderingGroup;
  53389. }
  53390. }
  53391. declare module BABYLON {
  53392. /** @hidden */
  53393. export var glowMapMergePixelShader: {
  53394. name: string;
  53395. shader: string;
  53396. };
  53397. }
  53398. declare module BABYLON {
  53399. /** @hidden */
  53400. export var glowMapMergeVertexShader: {
  53401. name: string;
  53402. shader: string;
  53403. };
  53404. }
  53405. declare module BABYLON {
  53406. interface AbstractScene {
  53407. /**
  53408. * Return a the first highlight layer of the scene with a given name.
  53409. * @param name The name of the highlight layer to look for.
  53410. * @return The highlight layer if found otherwise null.
  53411. */
  53412. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53413. }
  53414. /**
  53415. * Glow layer options. This helps customizing the behaviour
  53416. * of the glow layer.
  53417. */
  53418. export interface IGlowLayerOptions {
  53419. /**
  53420. * Multiplication factor apply to the canvas size to compute the render target size
  53421. * used to generated the glowing objects (the smaller the faster).
  53422. */
  53423. mainTextureRatio: number;
  53424. /**
  53425. * Enforces a fixed size texture to ensure resize independant blur.
  53426. */
  53427. mainTextureFixedSize?: number;
  53428. /**
  53429. * How big is the kernel of the blur texture.
  53430. */
  53431. blurKernelSize: number;
  53432. /**
  53433. * The camera attached to the layer.
  53434. */
  53435. camera: Nullable<Camera>;
  53436. /**
  53437. * Enable MSAA by chosing the number of samples.
  53438. */
  53439. mainTextureSamples?: number;
  53440. /**
  53441. * The rendering group to draw the layer in.
  53442. */
  53443. renderingGroupId: number;
  53444. }
  53445. /**
  53446. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53447. *
  53448. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53449. *
  53450. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53451. */
  53452. export class GlowLayer extends EffectLayer {
  53453. /**
  53454. * Effect Name of the layer.
  53455. */
  53456. static readonly EffectName: string;
  53457. /**
  53458. * The default blur kernel size used for the glow.
  53459. */
  53460. static DefaultBlurKernelSize: number;
  53461. /**
  53462. * The default texture size ratio used for the glow.
  53463. */
  53464. static DefaultTextureRatio: number;
  53465. /**
  53466. * Sets the kernel size of the blur.
  53467. */
  53468. set blurKernelSize(value: number);
  53469. /**
  53470. * Gets the kernel size of the blur.
  53471. */
  53472. get blurKernelSize(): number;
  53473. /**
  53474. * Sets the glow intensity.
  53475. */
  53476. set intensity(value: number);
  53477. /**
  53478. * Gets the glow intensity.
  53479. */
  53480. get intensity(): number;
  53481. private _options;
  53482. private _intensity;
  53483. private _horizontalBlurPostprocess1;
  53484. private _verticalBlurPostprocess1;
  53485. private _horizontalBlurPostprocess2;
  53486. private _verticalBlurPostprocess2;
  53487. private _blurTexture1;
  53488. private _blurTexture2;
  53489. private _postProcesses1;
  53490. private _postProcesses2;
  53491. private _includedOnlyMeshes;
  53492. private _excludedMeshes;
  53493. private _meshesUsingTheirOwnMaterials;
  53494. /**
  53495. * Callback used to let the user override the color selection on a per mesh basis
  53496. */
  53497. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53498. /**
  53499. * Callback used to let the user override the texture selection on a per mesh basis
  53500. */
  53501. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53502. /**
  53503. * Instantiates a new glow Layer and references it to the scene.
  53504. * @param name The name of the layer
  53505. * @param scene The scene to use the layer in
  53506. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53507. */
  53508. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53509. /**
  53510. * Get the effect name of the layer.
  53511. * @return The effect name
  53512. */
  53513. getEffectName(): string;
  53514. /**
  53515. * Create the merge effect. This is the shader use to blit the information back
  53516. * to the main canvas at the end of the scene rendering.
  53517. */
  53518. protected _createMergeEffect(): Effect;
  53519. /**
  53520. * Creates the render target textures and post processes used in the glow layer.
  53521. */
  53522. protected _createTextureAndPostProcesses(): void;
  53523. /**
  53524. * Checks for the readiness of the element composing the layer.
  53525. * @param subMesh the mesh to check for
  53526. * @param useInstances specify wether or not to use instances to render the mesh
  53527. * @param emissiveTexture the associated emissive texture used to generate the glow
  53528. * @return true if ready otherwise, false
  53529. */
  53530. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53531. /**
  53532. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53533. */
  53534. needStencil(): boolean;
  53535. /**
  53536. * Returns true if the mesh can be rendered, otherwise false.
  53537. * @param mesh The mesh to render
  53538. * @param material The material used on the mesh
  53539. * @returns true if it can be rendered otherwise false
  53540. */
  53541. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53542. /**
  53543. * Implementation specific of rendering the generating effect on the main canvas.
  53544. * @param effect The effect used to render through
  53545. */
  53546. protected _internalRender(effect: Effect): void;
  53547. /**
  53548. * Sets the required values for both the emissive texture and and the main color.
  53549. */
  53550. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53551. /**
  53552. * Returns true if the mesh should render, otherwise false.
  53553. * @param mesh The mesh to render
  53554. * @returns true if it should render otherwise false
  53555. */
  53556. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53557. /**
  53558. * Adds specific effects defines.
  53559. * @param defines The defines to add specifics to.
  53560. */
  53561. protected _addCustomEffectDefines(defines: string[]): void;
  53562. /**
  53563. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53564. * @param mesh The mesh to exclude from the glow layer
  53565. */
  53566. addExcludedMesh(mesh: Mesh): void;
  53567. /**
  53568. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53569. * @param mesh The mesh to remove
  53570. */
  53571. removeExcludedMesh(mesh: Mesh): void;
  53572. /**
  53573. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53574. * @param mesh The mesh to include in the glow layer
  53575. */
  53576. addIncludedOnlyMesh(mesh: Mesh): void;
  53577. /**
  53578. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53579. * @param mesh The mesh to remove
  53580. */
  53581. removeIncludedOnlyMesh(mesh: Mesh): void;
  53582. /**
  53583. * Determine if a given mesh will be used in the glow layer
  53584. * @param mesh The mesh to test
  53585. * @returns true if the mesh will be highlighted by the current glow layer
  53586. */
  53587. hasMesh(mesh: AbstractMesh): boolean;
  53588. /**
  53589. * Defines whether the current material of the mesh should be use to render the effect.
  53590. * @param mesh defines the current mesh to render
  53591. */
  53592. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53593. /**
  53594. * Add a mesh to be rendered through its own material and not with emissive only.
  53595. * @param mesh The mesh for which we need to use its material
  53596. */
  53597. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53598. /**
  53599. * Remove a mesh from being rendered through its own material and not with emissive only.
  53600. * @param mesh The mesh for which we need to not use its material
  53601. */
  53602. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53603. /**
  53604. * Free any resources and references associated to a mesh.
  53605. * Internal use
  53606. * @param mesh The mesh to free.
  53607. * @hidden
  53608. */
  53609. _disposeMesh(mesh: Mesh): void;
  53610. /**
  53611. * Gets the class name of the effect layer
  53612. * @returns the string with the class name of the effect layer
  53613. */
  53614. getClassName(): string;
  53615. /**
  53616. * Serializes this glow layer
  53617. * @returns a serialized glow layer object
  53618. */
  53619. serialize(): any;
  53620. /**
  53621. * Creates a Glow Layer from parsed glow layer data
  53622. * @param parsedGlowLayer defines glow layer data
  53623. * @param scene defines the current scene
  53624. * @param rootUrl defines the root URL containing the glow layer information
  53625. * @returns a parsed Glow Layer
  53626. */
  53627. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53628. }
  53629. }
  53630. declare module BABYLON {
  53631. /** @hidden */
  53632. export var glowBlurPostProcessPixelShader: {
  53633. name: string;
  53634. shader: string;
  53635. };
  53636. }
  53637. declare module BABYLON {
  53638. interface AbstractScene {
  53639. /**
  53640. * Return a the first highlight layer of the scene with a given name.
  53641. * @param name The name of the highlight layer to look for.
  53642. * @return The highlight layer if found otherwise null.
  53643. */
  53644. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53645. }
  53646. /**
  53647. * Highlight layer options. This helps customizing the behaviour
  53648. * of the highlight layer.
  53649. */
  53650. export interface IHighlightLayerOptions {
  53651. /**
  53652. * Multiplication factor apply to the canvas size to compute the render target size
  53653. * used to generated the glowing objects (the smaller the faster).
  53654. */
  53655. mainTextureRatio: number;
  53656. /**
  53657. * Enforces a fixed size texture to ensure resize independant blur.
  53658. */
  53659. mainTextureFixedSize?: number;
  53660. /**
  53661. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  53662. * of the picture to blur (the smaller the faster).
  53663. */
  53664. blurTextureSizeRatio: number;
  53665. /**
  53666. * How big in texel of the blur texture is the vertical blur.
  53667. */
  53668. blurVerticalSize: number;
  53669. /**
  53670. * How big in texel of the blur texture is the horizontal blur.
  53671. */
  53672. blurHorizontalSize: number;
  53673. /**
  53674. * Alpha blending mode used to apply the blur. Default is combine.
  53675. */
  53676. alphaBlendingMode: number;
  53677. /**
  53678. * The camera attached to the layer.
  53679. */
  53680. camera: Nullable<Camera>;
  53681. /**
  53682. * Should we display highlight as a solid stroke?
  53683. */
  53684. isStroke?: boolean;
  53685. /**
  53686. * The rendering group to draw the layer in.
  53687. */
  53688. renderingGroupId: number;
  53689. }
  53690. /**
  53691. * The highlight layer Helps adding a glow effect around a mesh.
  53692. *
  53693. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53694. * glowy meshes to your scene.
  53695. *
  53696. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53697. */
  53698. export class HighlightLayer extends EffectLayer {
  53699. name: string;
  53700. /**
  53701. * Effect Name of the highlight layer.
  53702. */
  53703. static readonly EffectName: string;
  53704. /**
  53705. * The neutral color used during the preparation of the glow effect.
  53706. * This is black by default as the blend operation is a blend operation.
  53707. */
  53708. static NeutralColor: Color4;
  53709. /**
  53710. * Stencil value used for glowing meshes.
  53711. */
  53712. static GlowingMeshStencilReference: number;
  53713. /**
  53714. * Stencil value used for the other meshes in the scene.
  53715. */
  53716. static NormalMeshStencilReference: number;
  53717. /**
  53718. * Specifies whether or not the inner glow is ACTIVE in the layer.
  53719. */
  53720. innerGlow: boolean;
  53721. /**
  53722. * Specifies whether or not the outer glow is ACTIVE in the layer.
  53723. */
  53724. outerGlow: boolean;
  53725. /**
  53726. * Specifies the horizontal size of the blur.
  53727. */
  53728. set blurHorizontalSize(value: number);
  53729. /**
  53730. * Specifies the vertical size of the blur.
  53731. */
  53732. set blurVerticalSize(value: number);
  53733. /**
  53734. * Gets the horizontal size of the blur.
  53735. */
  53736. get blurHorizontalSize(): number;
  53737. /**
  53738. * Gets the vertical size of the blur.
  53739. */
  53740. get blurVerticalSize(): number;
  53741. /**
  53742. * An event triggered when the highlight layer is being blurred.
  53743. */
  53744. onBeforeBlurObservable: Observable<HighlightLayer>;
  53745. /**
  53746. * An event triggered when the highlight layer has been blurred.
  53747. */
  53748. onAfterBlurObservable: Observable<HighlightLayer>;
  53749. private _instanceGlowingMeshStencilReference;
  53750. private _options;
  53751. private _downSamplePostprocess;
  53752. private _horizontalBlurPostprocess;
  53753. private _verticalBlurPostprocess;
  53754. private _blurTexture;
  53755. private _meshes;
  53756. private _excludedMeshes;
  53757. /**
  53758. * Instantiates a new highlight Layer and references it to the scene..
  53759. * @param name The name of the layer
  53760. * @param scene The scene to use the layer in
  53761. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  53762. */
  53763. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  53764. /**
  53765. * Get the effect name of the layer.
  53766. * @return The effect name
  53767. */
  53768. getEffectName(): string;
  53769. /**
  53770. * Create the merge effect. This is the shader use to blit the information back
  53771. * to the main canvas at the end of the scene rendering.
  53772. */
  53773. protected _createMergeEffect(): Effect;
  53774. /**
  53775. * Creates the render target textures and post processes used in the highlight layer.
  53776. */
  53777. protected _createTextureAndPostProcesses(): void;
  53778. /**
  53779. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53780. */
  53781. needStencil(): boolean;
  53782. /**
  53783. * Checks for the readiness of the element composing the layer.
  53784. * @param subMesh the mesh to check for
  53785. * @param useInstances specify wether or not to use instances to render the mesh
  53786. * @param emissiveTexture the associated emissive texture used to generate the glow
  53787. * @return true if ready otherwise, false
  53788. */
  53789. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53790. /**
  53791. * Implementation specific of rendering the generating effect on the main canvas.
  53792. * @param effect The effect used to render through
  53793. */
  53794. protected _internalRender(effect: Effect): void;
  53795. /**
  53796. * Returns true if the layer contains information to display, otherwise false.
  53797. */
  53798. shouldRender(): boolean;
  53799. /**
  53800. * Returns true if the mesh should render, otherwise false.
  53801. * @param mesh The mesh to render
  53802. * @returns true if it should render otherwise false
  53803. */
  53804. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53805. /**
  53806. * Sets the required values for both the emissive texture and and the main color.
  53807. */
  53808. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53809. /**
  53810. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53811. * @param mesh The mesh to exclude from the highlight layer
  53812. */
  53813. addExcludedMesh(mesh: Mesh): void;
  53814. /**
  53815. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  53816. * @param mesh The mesh to highlight
  53817. */
  53818. removeExcludedMesh(mesh: Mesh): void;
  53819. /**
  53820. * Determine if a given mesh will be highlighted by the current HighlightLayer
  53821. * @param mesh mesh to test
  53822. * @returns true if the mesh will be highlighted by the current HighlightLayer
  53823. */
  53824. hasMesh(mesh: AbstractMesh): boolean;
  53825. /**
  53826. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  53827. * @param mesh The mesh to highlight
  53828. * @param color The color of the highlight
  53829. * @param glowEmissiveOnly Extract the glow from the emissive texture
  53830. */
  53831. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  53832. /**
  53833. * Remove a mesh from the highlight layer in order to make it stop glowing.
  53834. * @param mesh The mesh to highlight
  53835. */
  53836. removeMesh(mesh: Mesh): void;
  53837. /**
  53838. * Remove all the meshes currently referenced in the highlight layer
  53839. */
  53840. removeAllMeshes(): void;
  53841. /**
  53842. * Force the stencil to the normal expected value for none glowing parts
  53843. */
  53844. private _defaultStencilReference;
  53845. /**
  53846. * Free any resources and references associated to a mesh.
  53847. * Internal use
  53848. * @param mesh The mesh to free.
  53849. * @hidden
  53850. */
  53851. _disposeMesh(mesh: Mesh): void;
  53852. /**
  53853. * Dispose the highlight layer and free resources.
  53854. */
  53855. dispose(): void;
  53856. /**
  53857. * Gets the class name of the effect layer
  53858. * @returns the string with the class name of the effect layer
  53859. */
  53860. getClassName(): string;
  53861. /**
  53862. * Serializes this Highlight layer
  53863. * @returns a serialized Highlight layer object
  53864. */
  53865. serialize(): any;
  53866. /**
  53867. * Creates a Highlight layer from parsed Highlight layer data
  53868. * @param parsedHightlightLayer defines the Highlight layer data
  53869. * @param scene defines the current scene
  53870. * @param rootUrl defines the root URL containing the Highlight layer information
  53871. * @returns a parsed Highlight layer
  53872. */
  53873. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  53874. }
  53875. }
  53876. declare module BABYLON {
  53877. interface AbstractScene {
  53878. /**
  53879. * The list of layers (background and foreground) of the scene
  53880. */
  53881. layers: Array<Layer>;
  53882. }
  53883. /**
  53884. * Defines the layer scene component responsible to manage any layers
  53885. * in a given scene.
  53886. */
  53887. export class LayerSceneComponent implements ISceneComponent {
  53888. /**
  53889. * The component name helpfull to identify the component in the list of scene components.
  53890. */
  53891. readonly name: string;
  53892. /**
  53893. * The scene the component belongs to.
  53894. */
  53895. scene: Scene;
  53896. private _engine;
  53897. /**
  53898. * Creates a new instance of the component for the given scene
  53899. * @param scene Defines the scene to register the component in
  53900. */
  53901. constructor(scene: Scene);
  53902. /**
  53903. * Registers the component in a given scene
  53904. */
  53905. register(): void;
  53906. /**
  53907. * Rebuilds the elements related to this component in case of
  53908. * context lost for instance.
  53909. */
  53910. rebuild(): void;
  53911. /**
  53912. * Disposes the component and the associated ressources.
  53913. */
  53914. dispose(): void;
  53915. private _draw;
  53916. private _drawCameraPredicate;
  53917. private _drawCameraBackground;
  53918. private _drawCameraForeground;
  53919. private _drawRenderTargetPredicate;
  53920. private _drawRenderTargetBackground;
  53921. private _drawRenderTargetForeground;
  53922. /**
  53923. * Adds all the elements from the container to the scene
  53924. * @param container the container holding the elements
  53925. */
  53926. addFromContainer(container: AbstractScene): void;
  53927. /**
  53928. * Removes all the elements in the container from the scene
  53929. * @param container contains the elements to remove
  53930. * @param dispose if the removed element should be disposed (default: false)
  53931. */
  53932. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53933. }
  53934. }
  53935. declare module BABYLON {
  53936. /** @hidden */
  53937. export var layerPixelShader: {
  53938. name: string;
  53939. shader: string;
  53940. };
  53941. }
  53942. declare module BABYLON {
  53943. /** @hidden */
  53944. export var layerVertexShader: {
  53945. name: string;
  53946. shader: string;
  53947. };
  53948. }
  53949. declare module BABYLON {
  53950. /**
  53951. * This represents a full screen 2d layer.
  53952. * This can be useful to display a picture in the background of your scene for instance.
  53953. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53954. */
  53955. export class Layer {
  53956. /**
  53957. * Define the name of the layer.
  53958. */
  53959. name: string;
  53960. /**
  53961. * Define the texture the layer should display.
  53962. */
  53963. texture: Nullable<Texture>;
  53964. /**
  53965. * Is the layer in background or foreground.
  53966. */
  53967. isBackground: boolean;
  53968. /**
  53969. * Define the color of the layer (instead of texture).
  53970. */
  53971. color: Color4;
  53972. /**
  53973. * Define the scale of the layer in order to zoom in out of the texture.
  53974. */
  53975. scale: Vector2;
  53976. /**
  53977. * Define an offset for the layer in order to shift the texture.
  53978. */
  53979. offset: Vector2;
  53980. /**
  53981. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53982. */
  53983. alphaBlendingMode: number;
  53984. /**
  53985. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53986. * Alpha test will not mix with the background color in case of transparency.
  53987. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53988. */
  53989. alphaTest: boolean;
  53990. /**
  53991. * Define a mask to restrict the layer to only some of the scene cameras.
  53992. */
  53993. layerMask: number;
  53994. /**
  53995. * Define the list of render target the layer is visible into.
  53996. */
  53997. renderTargetTextures: RenderTargetTexture[];
  53998. /**
  53999. * Define if the layer is only used in renderTarget or if it also
  54000. * renders in the main frame buffer of the canvas.
  54001. */
  54002. renderOnlyInRenderTargetTextures: boolean;
  54003. private _scene;
  54004. private _vertexBuffers;
  54005. private _indexBuffer;
  54006. private _effect;
  54007. private _previousDefines;
  54008. /**
  54009. * An event triggered when the layer is disposed.
  54010. */
  54011. onDisposeObservable: Observable<Layer>;
  54012. private _onDisposeObserver;
  54013. /**
  54014. * Back compatibility with callback before the onDisposeObservable existed.
  54015. * The set callback will be triggered when the layer has been disposed.
  54016. */
  54017. set onDispose(callback: () => void);
  54018. /**
  54019. * An event triggered before rendering the scene
  54020. */
  54021. onBeforeRenderObservable: Observable<Layer>;
  54022. private _onBeforeRenderObserver;
  54023. /**
  54024. * Back compatibility with callback before the onBeforeRenderObservable existed.
  54025. * The set callback will be triggered just before rendering the layer.
  54026. */
  54027. set onBeforeRender(callback: () => void);
  54028. /**
  54029. * An event triggered after rendering the scene
  54030. */
  54031. onAfterRenderObservable: Observable<Layer>;
  54032. private _onAfterRenderObserver;
  54033. /**
  54034. * Back compatibility with callback before the onAfterRenderObservable existed.
  54035. * The set callback will be triggered just after rendering the layer.
  54036. */
  54037. set onAfterRender(callback: () => void);
  54038. /**
  54039. * Instantiates a new layer.
  54040. * This represents a full screen 2d layer.
  54041. * This can be useful to display a picture in the background of your scene for instance.
  54042. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54043. * @param name Define the name of the layer in the scene
  54044. * @param imgUrl Define the url of the texture to display in the layer
  54045. * @param scene Define the scene the layer belongs to
  54046. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  54047. * @param color Defines a color for the layer
  54048. */
  54049. constructor(
  54050. /**
  54051. * Define the name of the layer.
  54052. */
  54053. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  54054. private _createIndexBuffer;
  54055. /** @hidden */
  54056. _rebuild(): void;
  54057. /**
  54058. * Renders the layer in the scene.
  54059. */
  54060. render(): void;
  54061. /**
  54062. * Disposes and releases the associated ressources.
  54063. */
  54064. dispose(): void;
  54065. }
  54066. }
  54067. declare module BABYLON {
  54068. /** @hidden */
  54069. export var lensFlarePixelShader: {
  54070. name: string;
  54071. shader: string;
  54072. };
  54073. }
  54074. declare module BABYLON {
  54075. /** @hidden */
  54076. export var lensFlareVertexShader: {
  54077. name: string;
  54078. shader: string;
  54079. };
  54080. }
  54081. declare module BABYLON {
  54082. /**
  54083. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54084. * It is usually composed of several `lensFlare`.
  54085. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54086. */
  54087. export class LensFlareSystem {
  54088. /**
  54089. * Define the name of the lens flare system
  54090. */
  54091. name: string;
  54092. /**
  54093. * List of lens flares used in this system.
  54094. */
  54095. lensFlares: LensFlare[];
  54096. /**
  54097. * Define a limit from the border the lens flare can be visible.
  54098. */
  54099. borderLimit: number;
  54100. /**
  54101. * Define a viewport border we do not want to see the lens flare in.
  54102. */
  54103. viewportBorder: number;
  54104. /**
  54105. * Define a predicate which could limit the list of meshes able to occlude the effect.
  54106. */
  54107. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  54108. /**
  54109. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  54110. */
  54111. layerMask: number;
  54112. /**
  54113. * Define the id of the lens flare system in the scene.
  54114. * (equal to name by default)
  54115. */
  54116. id: string;
  54117. private _scene;
  54118. private _emitter;
  54119. private _vertexBuffers;
  54120. private _indexBuffer;
  54121. private _effect;
  54122. private _positionX;
  54123. private _positionY;
  54124. private _isEnabled;
  54125. /** @hidden */
  54126. static _SceneComponentInitialization: (scene: Scene) => void;
  54127. /**
  54128. * Instantiates a lens flare system.
  54129. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54130. * It is usually composed of several `lensFlare`.
  54131. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54132. * @param name Define the name of the lens flare system in the scene
  54133. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  54134. * @param scene Define the scene the lens flare system belongs to
  54135. */
  54136. constructor(
  54137. /**
  54138. * Define the name of the lens flare system
  54139. */
  54140. name: string, emitter: any, scene: Scene);
  54141. /**
  54142. * Define if the lens flare system is enabled.
  54143. */
  54144. get isEnabled(): boolean;
  54145. set isEnabled(value: boolean);
  54146. /**
  54147. * Get the scene the effects belongs to.
  54148. * @returns the scene holding the lens flare system
  54149. */
  54150. getScene(): Scene;
  54151. /**
  54152. * Get the emitter of the lens flare system.
  54153. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54154. * @returns the emitter of the lens flare system
  54155. */
  54156. getEmitter(): any;
  54157. /**
  54158. * Set the emitter of the lens flare system.
  54159. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54160. * @param newEmitter Define the new emitter of the system
  54161. */
  54162. setEmitter(newEmitter: any): void;
  54163. /**
  54164. * Get the lens flare system emitter position.
  54165. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  54166. * @returns the position
  54167. */
  54168. getEmitterPosition(): Vector3;
  54169. /**
  54170. * @hidden
  54171. */
  54172. computeEffectivePosition(globalViewport: Viewport): boolean;
  54173. /** @hidden */
  54174. _isVisible(): boolean;
  54175. /**
  54176. * @hidden
  54177. */
  54178. render(): boolean;
  54179. /**
  54180. * Dispose and release the lens flare with its associated resources.
  54181. */
  54182. dispose(): void;
  54183. /**
  54184. * Parse a lens flare system from a JSON repressentation
  54185. * @param parsedLensFlareSystem Define the JSON to parse
  54186. * @param scene Define the scene the parsed system should be instantiated in
  54187. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  54188. * @returns the parsed system
  54189. */
  54190. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  54191. /**
  54192. * Serialize the current Lens Flare System into a JSON representation.
  54193. * @returns the serialized JSON
  54194. */
  54195. serialize(): any;
  54196. }
  54197. }
  54198. declare module BABYLON {
  54199. /**
  54200. * This represents one of the lens effect in a `lensFlareSystem`.
  54201. * It controls one of the indiviual texture used in the effect.
  54202. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54203. */
  54204. export class LensFlare {
  54205. /**
  54206. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54207. */
  54208. size: number;
  54209. /**
  54210. * 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.
  54211. */
  54212. position: number;
  54213. /**
  54214. * Define the lens color.
  54215. */
  54216. color: Color3;
  54217. /**
  54218. * Define the lens texture.
  54219. */
  54220. texture: Nullable<Texture>;
  54221. /**
  54222. * Define the alpha mode to render this particular lens.
  54223. */
  54224. alphaMode: number;
  54225. private _system;
  54226. /**
  54227. * Creates a new Lens Flare.
  54228. * This represents one of the lens effect in a `lensFlareSystem`.
  54229. * It controls one of the indiviual texture used in the effect.
  54230. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54231. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  54232. * @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.
  54233. * @param color Define the lens color
  54234. * @param imgUrl Define the lens texture url
  54235. * @param system Define the `lensFlareSystem` this flare is part of
  54236. * @returns The newly created Lens Flare
  54237. */
  54238. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  54239. /**
  54240. * Instantiates a new Lens Flare.
  54241. * This represents one of the lens effect in a `lensFlareSystem`.
  54242. * It controls one of the indiviual texture used in the effect.
  54243. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54244. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  54245. * @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.
  54246. * @param color Define the lens color
  54247. * @param imgUrl Define the lens texture url
  54248. * @param system Define the `lensFlareSystem` this flare is part of
  54249. */
  54250. constructor(
  54251. /**
  54252. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54253. */
  54254. size: number,
  54255. /**
  54256. * 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.
  54257. */
  54258. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  54259. /**
  54260. * Dispose and release the lens flare with its associated resources.
  54261. */
  54262. dispose(): void;
  54263. }
  54264. }
  54265. declare module BABYLON {
  54266. interface AbstractScene {
  54267. /**
  54268. * The list of lens flare system added to the scene
  54269. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54270. */
  54271. lensFlareSystems: Array<LensFlareSystem>;
  54272. /**
  54273. * Removes the given lens flare system from this scene.
  54274. * @param toRemove The lens flare system to remove
  54275. * @returns The index of the removed lens flare system
  54276. */
  54277. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  54278. /**
  54279. * Adds the given lens flare system to this scene
  54280. * @param newLensFlareSystem The lens flare system to add
  54281. */
  54282. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  54283. /**
  54284. * Gets a lens flare system using its name
  54285. * @param name defines the name to look for
  54286. * @returns the lens flare system or null if not found
  54287. */
  54288. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  54289. /**
  54290. * Gets a lens flare system using its id
  54291. * @param id defines the id to look for
  54292. * @returns the lens flare system or null if not found
  54293. */
  54294. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  54295. }
  54296. /**
  54297. * Defines the lens flare scene component responsible to manage any lens flares
  54298. * in a given scene.
  54299. */
  54300. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  54301. /**
  54302. * The component name helpfull to identify the component in the list of scene components.
  54303. */
  54304. readonly name: string;
  54305. /**
  54306. * The scene the component belongs to.
  54307. */
  54308. scene: Scene;
  54309. /**
  54310. * Creates a new instance of the component for the given scene
  54311. * @param scene Defines the scene to register the component in
  54312. */
  54313. constructor(scene: Scene);
  54314. /**
  54315. * Registers the component in a given scene
  54316. */
  54317. register(): void;
  54318. /**
  54319. * Rebuilds the elements related to this component in case of
  54320. * context lost for instance.
  54321. */
  54322. rebuild(): void;
  54323. /**
  54324. * Adds all the elements from the container to the scene
  54325. * @param container the container holding the elements
  54326. */
  54327. addFromContainer(container: AbstractScene): void;
  54328. /**
  54329. * Removes all the elements in the container from the scene
  54330. * @param container contains the elements to remove
  54331. * @param dispose if the removed element should be disposed (default: false)
  54332. */
  54333. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54334. /**
  54335. * Serializes the component data to the specified json object
  54336. * @param serializationObject The object to serialize to
  54337. */
  54338. serialize(serializationObject: any): void;
  54339. /**
  54340. * Disposes the component and the associated ressources.
  54341. */
  54342. dispose(): void;
  54343. private _draw;
  54344. }
  54345. }
  54346. declare module BABYLON {
  54347. /** @hidden */
  54348. export var depthPixelShader: {
  54349. name: string;
  54350. shader: string;
  54351. };
  54352. }
  54353. declare module BABYLON {
  54354. /** @hidden */
  54355. export var depthVertexShader: {
  54356. name: string;
  54357. shader: string;
  54358. };
  54359. }
  54360. declare module BABYLON {
  54361. /**
  54362. * This represents a depth renderer in Babylon.
  54363. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54364. */
  54365. export class DepthRenderer {
  54366. private _scene;
  54367. private _depthMap;
  54368. private _effect;
  54369. private readonly _storeNonLinearDepth;
  54370. private readonly _clearColor;
  54371. /** Get if the depth renderer is using packed depth or not */
  54372. readonly isPacked: boolean;
  54373. private _cachedDefines;
  54374. private _camera;
  54375. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  54376. enabled: boolean;
  54377. /**
  54378. * Specifiess that the depth renderer will only be used within
  54379. * the camera it is created for.
  54380. * This can help forcing its rendering during the camera processing.
  54381. */
  54382. useOnlyInActiveCamera: boolean;
  54383. /** @hidden */
  54384. static _SceneComponentInitialization: (scene: Scene) => void;
  54385. /**
  54386. * Instantiates a depth renderer
  54387. * @param scene The scene the renderer belongs to
  54388. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54389. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54390. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  54391. */
  54392. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  54393. /**
  54394. * Creates the depth rendering effect and checks if the effect is ready.
  54395. * @param subMesh The submesh to be used to render the depth map of
  54396. * @param useInstances If multiple world instances should be used
  54397. * @returns if the depth renderer is ready to render the depth map
  54398. */
  54399. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54400. /**
  54401. * Gets the texture which the depth map will be written to.
  54402. * @returns The depth map texture
  54403. */
  54404. getDepthMap(): RenderTargetTexture;
  54405. /**
  54406. * Disposes of the depth renderer.
  54407. */
  54408. dispose(): void;
  54409. }
  54410. }
  54411. declare module BABYLON {
  54412. /** @hidden */
  54413. export var minmaxReduxPixelShader: {
  54414. name: string;
  54415. shader: string;
  54416. };
  54417. }
  54418. declare module BABYLON {
  54419. /**
  54420. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54421. * and maximum values from all values of the texture.
  54422. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54423. * The source values are read from the red channel of the texture.
  54424. */
  54425. export class MinMaxReducer {
  54426. /**
  54427. * Observable triggered when the computation has been performed
  54428. */
  54429. onAfterReductionPerformed: Observable<{
  54430. min: number;
  54431. max: number;
  54432. }>;
  54433. protected _camera: Camera;
  54434. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54435. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54436. protected _postProcessManager: PostProcessManager;
  54437. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54438. protected _forceFullscreenViewport: boolean;
  54439. /**
  54440. * Creates a min/max reducer
  54441. * @param camera The camera to use for the post processes
  54442. */
  54443. constructor(camera: Camera);
  54444. /**
  54445. * Gets the texture used to read the values from.
  54446. */
  54447. get sourceTexture(): Nullable<RenderTargetTexture>;
  54448. /**
  54449. * Sets the source texture to read the values from.
  54450. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54451. * because in such textures '1' value must not be taken into account to compute the maximum
  54452. * as this value is used to clear the texture.
  54453. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54454. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54455. * @param depthRedux Indicates if the texture is a depth texture or not
  54456. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54457. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54458. */
  54459. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54460. /**
  54461. * Defines the refresh rate of the computation.
  54462. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54463. */
  54464. get refreshRate(): number;
  54465. set refreshRate(value: number);
  54466. protected _activated: boolean;
  54467. /**
  54468. * Gets the activation status of the reducer
  54469. */
  54470. get activated(): boolean;
  54471. /**
  54472. * Activates the reduction computation.
  54473. * When activated, the observers registered in onAfterReductionPerformed are
  54474. * called after the compuation is performed
  54475. */
  54476. activate(): void;
  54477. /**
  54478. * Deactivates the reduction computation.
  54479. */
  54480. deactivate(): void;
  54481. /**
  54482. * Disposes the min/max reducer
  54483. * @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.
  54484. */
  54485. dispose(disposeAll?: boolean): void;
  54486. }
  54487. }
  54488. declare module BABYLON {
  54489. /**
  54490. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54491. */
  54492. export class DepthReducer extends MinMaxReducer {
  54493. private _depthRenderer;
  54494. private _depthRendererId;
  54495. /**
  54496. * Gets the depth renderer used for the computation.
  54497. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54498. */
  54499. get depthRenderer(): Nullable<DepthRenderer>;
  54500. /**
  54501. * Creates a depth reducer
  54502. * @param camera The camera used to render the depth texture
  54503. */
  54504. constructor(camera: Camera);
  54505. /**
  54506. * Sets the depth renderer to use to generate the depth map
  54507. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  54508. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  54509. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54510. */
  54511. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  54512. /** @hidden */
  54513. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54514. /**
  54515. * Activates the reduction computation.
  54516. * When activated, the observers registered in onAfterReductionPerformed are
  54517. * called after the compuation is performed
  54518. */
  54519. activate(): void;
  54520. /**
  54521. * Deactivates the reduction computation.
  54522. */
  54523. deactivate(): void;
  54524. /**
  54525. * Disposes the depth reducer
  54526. * @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.
  54527. */
  54528. dispose(disposeAll?: boolean): void;
  54529. }
  54530. }
  54531. declare module BABYLON {
  54532. /**
  54533. * A CSM implementation allowing casting shadows on large scenes.
  54534. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54535. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  54536. */
  54537. export class CascadedShadowGenerator extends ShadowGenerator {
  54538. private static readonly frustumCornersNDCSpace;
  54539. /**
  54540. * Name of the CSM class
  54541. */
  54542. static CLASSNAME: string;
  54543. /**
  54544. * Defines the default number of cascades used by the CSM.
  54545. */
  54546. static readonly DEFAULT_CASCADES_COUNT: number;
  54547. /**
  54548. * Defines the minimum number of cascades used by the CSM.
  54549. */
  54550. static readonly MIN_CASCADES_COUNT: number;
  54551. /**
  54552. * Defines the maximum number of cascades used by the CSM.
  54553. */
  54554. static readonly MAX_CASCADES_COUNT: number;
  54555. protected _validateFilter(filter: number): number;
  54556. /**
  54557. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  54558. */
  54559. penumbraDarkness: number;
  54560. private _numCascades;
  54561. /**
  54562. * Gets or set the number of cascades used by the CSM.
  54563. */
  54564. get numCascades(): number;
  54565. set numCascades(value: number);
  54566. /**
  54567. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  54568. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  54569. */
  54570. stabilizeCascades: boolean;
  54571. private _freezeShadowCastersBoundingInfo;
  54572. private _freezeShadowCastersBoundingInfoObservable;
  54573. /**
  54574. * Enables or disables the shadow casters bounding info computation.
  54575. * If your shadow casters don't move, you can disable this feature.
  54576. * If it is enabled, the bounding box computation is done every frame.
  54577. */
  54578. get freezeShadowCastersBoundingInfo(): boolean;
  54579. set freezeShadowCastersBoundingInfo(freeze: boolean);
  54580. private _scbiMin;
  54581. private _scbiMax;
  54582. protected _computeShadowCastersBoundingInfo(): void;
  54583. protected _shadowCastersBoundingInfo: BoundingInfo;
  54584. /**
  54585. * Gets or sets the shadow casters bounding info.
  54586. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  54587. * so that the system won't overwrite the bounds you provide
  54588. */
  54589. get shadowCastersBoundingInfo(): BoundingInfo;
  54590. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  54591. protected _breaksAreDirty: boolean;
  54592. protected _minDistance: number;
  54593. protected _maxDistance: number;
  54594. /**
  54595. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  54596. *
  54597. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  54598. * If you don't know these values, simply leave them to their defaults and don't call this function.
  54599. * @param min minimal distance for the breaks (default to 0.)
  54600. * @param max maximal distance for the breaks (default to 1.)
  54601. */
  54602. setMinMaxDistance(min: number, max: number): void;
  54603. /** Gets the minimal distance used in the cascade break computation */
  54604. get minDistance(): number;
  54605. /** Gets the maximal distance used in the cascade break computation */
  54606. get maxDistance(): number;
  54607. /**
  54608. * Gets the class name of that object
  54609. * @returns "CascadedShadowGenerator"
  54610. */
  54611. getClassName(): string;
  54612. private _cascadeMinExtents;
  54613. private _cascadeMaxExtents;
  54614. /**
  54615. * Gets a cascade minimum extents
  54616. * @param cascadeIndex index of the cascade
  54617. * @returns the minimum cascade extents
  54618. */
  54619. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  54620. /**
  54621. * Gets a cascade maximum extents
  54622. * @param cascadeIndex index of the cascade
  54623. * @returns the maximum cascade extents
  54624. */
  54625. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  54626. private _cascades;
  54627. private _currentLayer;
  54628. private _viewSpaceFrustumsZ;
  54629. private _viewMatrices;
  54630. private _projectionMatrices;
  54631. private _transformMatrices;
  54632. private _transformMatricesAsArray;
  54633. private _frustumLengths;
  54634. private _lightSizeUVCorrection;
  54635. private _depthCorrection;
  54636. private _frustumCornersWorldSpace;
  54637. private _frustumCenter;
  54638. private _shadowCameraPos;
  54639. private _shadowMaxZ;
  54640. /**
  54641. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  54642. * It defaults to camera.maxZ
  54643. */
  54644. get shadowMaxZ(): number;
  54645. /**
  54646. * Sets the shadow max z distance.
  54647. */
  54648. set shadowMaxZ(value: number);
  54649. protected _debug: boolean;
  54650. /**
  54651. * Gets or sets the debug flag.
  54652. * When enabled, the cascades are materialized by different colors on the screen.
  54653. */
  54654. get debug(): boolean;
  54655. set debug(dbg: boolean);
  54656. private _depthClamp;
  54657. /**
  54658. * Gets or sets the depth clamping value.
  54659. *
  54660. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  54661. * to account for the shadow casters far away.
  54662. *
  54663. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  54664. */
  54665. get depthClamp(): boolean;
  54666. set depthClamp(value: boolean);
  54667. private _cascadeBlendPercentage;
  54668. /**
  54669. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  54670. * It defaults to 0.1 (10% blending).
  54671. */
  54672. get cascadeBlendPercentage(): number;
  54673. set cascadeBlendPercentage(value: number);
  54674. private _lambda;
  54675. /**
  54676. * Gets or set the lambda parameter.
  54677. * This parameter is used to split the camera frustum and create the cascades.
  54678. * 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.
  54679. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  54680. */
  54681. get lambda(): number;
  54682. set lambda(value: number);
  54683. /**
  54684. * Gets the view matrix corresponding to a given cascade
  54685. * @param cascadeNum cascade to retrieve the view matrix from
  54686. * @returns the cascade view matrix
  54687. */
  54688. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  54689. /**
  54690. * Gets the projection matrix corresponding to a given cascade
  54691. * @param cascadeNum cascade to retrieve the projection matrix from
  54692. * @returns the cascade projection matrix
  54693. */
  54694. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  54695. /**
  54696. * Gets the transformation matrix corresponding to a given cascade
  54697. * @param cascadeNum cascade to retrieve the transformation matrix from
  54698. * @returns the cascade transformation matrix
  54699. */
  54700. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  54701. private _depthRenderer;
  54702. /**
  54703. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  54704. *
  54705. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  54706. *
  54707. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  54708. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  54709. * @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
  54710. */
  54711. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  54712. private _depthReducer;
  54713. private _autoCalcDepthBounds;
  54714. /**
  54715. * Gets or sets the autoCalcDepthBounds property.
  54716. *
  54717. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  54718. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  54719. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  54720. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  54721. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  54722. */
  54723. get autoCalcDepthBounds(): boolean;
  54724. set autoCalcDepthBounds(value: boolean);
  54725. /**
  54726. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  54727. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54728. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  54729. * for setting the refresh rate on the renderer yourself!
  54730. */
  54731. get autoCalcDepthBoundsRefreshRate(): number;
  54732. set autoCalcDepthBoundsRefreshRate(value: number);
  54733. /**
  54734. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  54735. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  54736. * you change the camera near/far planes!
  54737. */
  54738. splitFrustum(): void;
  54739. private _splitFrustum;
  54740. private _computeMatrices;
  54741. private _computeFrustumInWorldSpace;
  54742. private _computeCascadeFrustum;
  54743. /**
  54744. * Support test.
  54745. */
  54746. static get IsSupported(): boolean;
  54747. /** @hidden */
  54748. static _SceneComponentInitialization: (scene: Scene) => void;
  54749. /**
  54750. * Creates a Cascaded Shadow Generator object.
  54751. * A ShadowGenerator is the required tool to use the shadows.
  54752. * Each directional light casting shadows needs to use its own ShadowGenerator.
  54753. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54754. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  54755. * @param light The directional light object generating the shadows.
  54756. * @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.
  54757. */
  54758. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  54759. protected _initializeGenerator(): void;
  54760. protected _createTargetRenderTexture(): void;
  54761. protected _initializeShadowMap(): void;
  54762. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  54763. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  54764. /**
  54765. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  54766. * @param defines Defines of the material we want to update
  54767. * @param lightIndex Index of the light in the enabled light list of the material
  54768. */
  54769. prepareDefines(defines: any, lightIndex: number): void;
  54770. /**
  54771. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  54772. * defined in the generator but impacting the effect).
  54773. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  54774. * @param effect The effect we are binfing the information for
  54775. */
  54776. bindShadowLight(lightIndex: string, effect: Effect): void;
  54777. /**
  54778. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  54779. * (eq to view projection * shadow projection matrices)
  54780. * @returns The transform matrix used to create the shadow map
  54781. */
  54782. getTransformMatrix(): Matrix;
  54783. /**
  54784. * Disposes the ShadowGenerator.
  54785. * Returns nothing.
  54786. */
  54787. dispose(): void;
  54788. /**
  54789. * Serializes the shadow generator setup to a json object.
  54790. * @returns The serialized JSON object
  54791. */
  54792. serialize(): any;
  54793. /**
  54794. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  54795. * @param parsedShadowGenerator The JSON object to parse
  54796. * @param scene The scene to create the shadow map for
  54797. * @returns The parsed shadow generator
  54798. */
  54799. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  54800. }
  54801. }
  54802. declare module BABYLON {
  54803. /**
  54804. * Defines the shadow generator component responsible to manage any shadow generators
  54805. * in a given scene.
  54806. */
  54807. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  54808. /**
  54809. * The component name helpfull to identify the component in the list of scene components.
  54810. */
  54811. readonly name: string;
  54812. /**
  54813. * The scene the component belongs to.
  54814. */
  54815. scene: Scene;
  54816. /**
  54817. * Creates a new instance of the component for the given scene
  54818. * @param scene Defines the scene to register the component in
  54819. */
  54820. constructor(scene: Scene);
  54821. /**
  54822. * Registers the component in a given scene
  54823. */
  54824. register(): void;
  54825. /**
  54826. * Rebuilds the elements related to this component in case of
  54827. * context lost for instance.
  54828. */
  54829. rebuild(): void;
  54830. /**
  54831. * Serializes the component data to the specified json object
  54832. * @param serializationObject The object to serialize to
  54833. */
  54834. serialize(serializationObject: any): void;
  54835. /**
  54836. * Adds all the elements from the container to the scene
  54837. * @param container the container holding the elements
  54838. */
  54839. addFromContainer(container: AbstractScene): void;
  54840. /**
  54841. * Removes all the elements in the container from the scene
  54842. * @param container contains the elements to remove
  54843. * @param dispose if the removed element should be disposed (default: false)
  54844. */
  54845. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54846. /**
  54847. * Rebuilds the elements related to this component in case of
  54848. * context lost for instance.
  54849. */
  54850. dispose(): void;
  54851. private _gatherRenderTargets;
  54852. }
  54853. }
  54854. declare module BABYLON {
  54855. /**
  54856. * A point light is a light defined by an unique point in world space.
  54857. * The light is emitted in every direction from this point.
  54858. * A good example of a point light is a standard light bulb.
  54859. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54860. */
  54861. export class PointLight extends ShadowLight {
  54862. private _shadowAngle;
  54863. /**
  54864. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54865. * This specifies what angle the shadow will use to be created.
  54866. *
  54867. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54868. */
  54869. get shadowAngle(): number;
  54870. /**
  54871. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54872. * This specifies what angle the shadow will use to be created.
  54873. *
  54874. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54875. */
  54876. set shadowAngle(value: number);
  54877. /**
  54878. * Gets the direction if it has been set.
  54879. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54880. */
  54881. get direction(): Vector3;
  54882. /**
  54883. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54884. */
  54885. set direction(value: Vector3);
  54886. /**
  54887. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  54888. * A PointLight emits the light in every direction.
  54889. * It can cast shadows.
  54890. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  54891. * ```javascript
  54892. * var pointLight = new PointLight("pl", camera.position, scene);
  54893. * ```
  54894. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54895. * @param name The light friendly name
  54896. * @param position The position of the point light in the scene
  54897. * @param scene The scene the lights belongs to
  54898. */
  54899. constructor(name: string, position: Vector3, scene: Scene);
  54900. /**
  54901. * Returns the string "PointLight"
  54902. * @returns the class name
  54903. */
  54904. getClassName(): string;
  54905. /**
  54906. * Returns the integer 0.
  54907. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54908. */
  54909. getTypeID(): number;
  54910. /**
  54911. * Specifies wether or not the shadowmap should be a cube texture.
  54912. * @returns true if the shadowmap needs to be a cube texture.
  54913. */
  54914. needCube(): boolean;
  54915. /**
  54916. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  54917. * @param faceIndex The index of the face we are computed the direction to generate shadow
  54918. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  54919. */
  54920. getShadowDirection(faceIndex?: number): Vector3;
  54921. /**
  54922. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  54923. * - fov = PI / 2
  54924. * - aspect ratio : 1.0
  54925. * - z-near and far equal to the active camera minZ and maxZ.
  54926. * Returns the PointLight.
  54927. */
  54928. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54929. protected _buildUniformLayout(): void;
  54930. /**
  54931. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  54932. * @param effect The effect to update
  54933. * @param lightIndex The index of the light in the effect to update
  54934. * @returns The point light
  54935. */
  54936. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  54937. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54938. /**
  54939. * Prepares the list of defines specific to the light type.
  54940. * @param defines the list of defines
  54941. * @param lightIndex defines the index of the light for the effect
  54942. */
  54943. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54944. }
  54945. }
  54946. declare module BABYLON {
  54947. /**
  54948. * Header information of HDR texture files.
  54949. */
  54950. export interface HDRInfo {
  54951. /**
  54952. * The height of the texture in pixels.
  54953. */
  54954. height: number;
  54955. /**
  54956. * The width of the texture in pixels.
  54957. */
  54958. width: number;
  54959. /**
  54960. * The index of the beginning of the data in the binary file.
  54961. */
  54962. dataPosition: number;
  54963. }
  54964. /**
  54965. * This groups tools to convert HDR texture to native colors array.
  54966. */
  54967. export class HDRTools {
  54968. private static Ldexp;
  54969. private static Rgbe2float;
  54970. private static readStringLine;
  54971. /**
  54972. * Reads header information from an RGBE texture stored in a native array.
  54973. * More information on this format are available here:
  54974. * https://en.wikipedia.org/wiki/RGBE_image_format
  54975. *
  54976. * @param uint8array The binary file stored in native array.
  54977. * @return The header information.
  54978. */
  54979. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  54980. /**
  54981. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  54982. * This RGBE texture needs to store the information as a panorama.
  54983. *
  54984. * More information on this format are available here:
  54985. * https://en.wikipedia.org/wiki/RGBE_image_format
  54986. *
  54987. * @param buffer The binary file stored in an array buffer.
  54988. * @param size The expected size of the extracted cubemap.
  54989. * @return The Cube Map information.
  54990. */
  54991. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  54992. /**
  54993. * Returns the pixels data extracted from an RGBE texture.
  54994. * This pixels will be stored left to right up to down in the R G B order in one array.
  54995. *
  54996. * More information on this format are available here:
  54997. * https://en.wikipedia.org/wiki/RGBE_image_format
  54998. *
  54999. * @param uint8array The binary file stored in an array buffer.
  55000. * @param hdrInfo The header information of the file.
  55001. * @return The pixels data in RGB right to left up to down order.
  55002. */
  55003. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  55004. private static RGBE_ReadPixels_RLE;
  55005. }
  55006. }
  55007. declare module BABYLON {
  55008. /**
  55009. * This represents a texture coming from an HDR input.
  55010. *
  55011. * The only supported format is currently panorama picture stored in RGBE format.
  55012. * Example of such files can be found on HDRLib: http://hdrlib.com/
  55013. */
  55014. export class HDRCubeTexture extends BaseTexture {
  55015. private static _facesMapping;
  55016. private _generateHarmonics;
  55017. private _noMipmap;
  55018. private _textureMatrix;
  55019. private _size;
  55020. private _onLoad;
  55021. private _onError;
  55022. /**
  55023. * The texture URL.
  55024. */
  55025. url: string;
  55026. /**
  55027. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  55028. */
  55029. coordinatesMode: number;
  55030. protected _isBlocking: boolean;
  55031. /**
  55032. * Sets wether or not the texture is blocking during loading.
  55033. */
  55034. set isBlocking(value: boolean);
  55035. /**
  55036. * Gets wether or not the texture is blocking during loading.
  55037. */
  55038. get isBlocking(): boolean;
  55039. protected _rotationY: number;
  55040. /**
  55041. * Sets texture matrix rotation angle around Y axis in radians.
  55042. */
  55043. set rotationY(value: number);
  55044. /**
  55045. * Gets texture matrix rotation angle around Y axis radians.
  55046. */
  55047. get rotationY(): number;
  55048. /**
  55049. * Gets or sets the center of the bounding box associated with the cube texture
  55050. * It must define where the camera used to render the texture was set
  55051. */
  55052. boundingBoxPosition: Vector3;
  55053. private _boundingBoxSize;
  55054. /**
  55055. * Gets or sets the size of the bounding box associated with the cube texture
  55056. * When defined, the cubemap will switch to local mode
  55057. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55058. * @example https://www.babylonjs-playground.com/#RNASML
  55059. */
  55060. set boundingBoxSize(value: Vector3);
  55061. get boundingBoxSize(): Vector3;
  55062. /**
  55063. * Instantiates an HDRTexture from the following parameters.
  55064. *
  55065. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  55066. * @param scene The scene the texture will be used in
  55067. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55068. * @param noMipmap Forces to not generate the mipmap if true
  55069. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55070. * @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)
  55071. * @param reserved Reserved flag for internal use.
  55072. */
  55073. 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>);
  55074. /**
  55075. * Get the current class name of the texture useful for serialization or dynamic coding.
  55076. * @returns "HDRCubeTexture"
  55077. */
  55078. getClassName(): string;
  55079. /**
  55080. * Occurs when the file is raw .hdr file.
  55081. */
  55082. private loadTexture;
  55083. clone(): HDRCubeTexture;
  55084. delayLoad(): void;
  55085. /**
  55086. * Get the texture reflection matrix used to rotate/transform the reflection.
  55087. * @returns the reflection matrix
  55088. */
  55089. getReflectionTextureMatrix(): Matrix;
  55090. /**
  55091. * Set the texture reflection matrix used to rotate/transform the reflection.
  55092. * @param value Define the reflection matrix to set
  55093. */
  55094. setReflectionTextureMatrix(value: Matrix): void;
  55095. /**
  55096. * Parses a JSON representation of an HDR Texture in order to create the texture
  55097. * @param parsedTexture Define the JSON representation
  55098. * @param scene Define the scene the texture should be created in
  55099. * @param rootUrl Define the root url in case we need to load relative dependencies
  55100. * @returns the newly created texture after parsing
  55101. */
  55102. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  55103. serialize(): any;
  55104. }
  55105. }
  55106. declare module BABYLON {
  55107. /**
  55108. * Class used to control physics engine
  55109. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55110. */
  55111. export class PhysicsEngine implements IPhysicsEngine {
  55112. private _physicsPlugin;
  55113. /**
  55114. * Global value used to control the smallest number supported by the simulation
  55115. */
  55116. static Epsilon: number;
  55117. private _impostors;
  55118. private _joints;
  55119. private _subTimeStep;
  55120. /**
  55121. * Gets the gravity vector used by the simulation
  55122. */
  55123. gravity: Vector3;
  55124. /**
  55125. * Factory used to create the default physics plugin.
  55126. * @returns The default physics plugin
  55127. */
  55128. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  55129. /**
  55130. * Creates a new Physics Engine
  55131. * @param gravity defines the gravity vector used by the simulation
  55132. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  55133. */
  55134. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  55135. /**
  55136. * Sets the gravity vector used by the simulation
  55137. * @param gravity defines the gravity vector to use
  55138. */
  55139. setGravity(gravity: Vector3): void;
  55140. /**
  55141. * Set the time step of the physics engine.
  55142. * Default is 1/60.
  55143. * To slow it down, enter 1/600 for example.
  55144. * To speed it up, 1/30
  55145. * @param newTimeStep defines the new timestep to apply to this world.
  55146. */
  55147. setTimeStep(newTimeStep?: number): void;
  55148. /**
  55149. * Get the time step of the physics engine.
  55150. * @returns the current time step
  55151. */
  55152. getTimeStep(): number;
  55153. /**
  55154. * Set the sub time step of the physics engine.
  55155. * Default is 0 meaning there is no sub steps
  55156. * To increase physics resolution precision, set a small value (like 1 ms)
  55157. * @param subTimeStep defines the new sub timestep used for physics resolution.
  55158. */
  55159. setSubTimeStep(subTimeStep?: number): void;
  55160. /**
  55161. * Get the sub time step of the physics engine.
  55162. * @returns the current sub time step
  55163. */
  55164. getSubTimeStep(): number;
  55165. /**
  55166. * Release all resources
  55167. */
  55168. dispose(): void;
  55169. /**
  55170. * Gets the name of the current physics plugin
  55171. * @returns the name of the plugin
  55172. */
  55173. getPhysicsPluginName(): string;
  55174. /**
  55175. * Adding a new impostor for the impostor tracking.
  55176. * This will be done by the impostor itself.
  55177. * @param impostor the impostor to add
  55178. */
  55179. addImpostor(impostor: PhysicsImpostor): void;
  55180. /**
  55181. * Remove an impostor from the engine.
  55182. * This impostor and its mesh will not longer be updated by the physics engine.
  55183. * @param impostor the impostor to remove
  55184. */
  55185. removeImpostor(impostor: PhysicsImpostor): void;
  55186. /**
  55187. * Add a joint to the physics engine
  55188. * @param mainImpostor defines the main impostor to which the joint is added.
  55189. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  55190. * @param joint defines the joint that will connect both impostors.
  55191. */
  55192. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55193. /**
  55194. * Removes a joint from the simulation
  55195. * @param mainImpostor defines the impostor used with the joint
  55196. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  55197. * @param joint defines the joint to remove
  55198. */
  55199. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55200. /**
  55201. * Called by the scene. No need to call it.
  55202. * @param delta defines the timespam between frames
  55203. */
  55204. _step(delta: number): void;
  55205. /**
  55206. * Gets the current plugin used to run the simulation
  55207. * @returns current plugin
  55208. */
  55209. getPhysicsPlugin(): IPhysicsEnginePlugin;
  55210. /**
  55211. * Gets the list of physic impostors
  55212. * @returns an array of PhysicsImpostor
  55213. */
  55214. getImpostors(): Array<PhysicsImpostor>;
  55215. /**
  55216. * Gets the impostor for a physics enabled object
  55217. * @param object defines the object impersonated by the impostor
  55218. * @returns the PhysicsImpostor or null if not found
  55219. */
  55220. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  55221. /**
  55222. * Gets the impostor for a physics body object
  55223. * @param body defines physics body used by the impostor
  55224. * @returns the PhysicsImpostor or null if not found
  55225. */
  55226. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  55227. /**
  55228. * Does a raycast in the physics world
  55229. * @param from when should the ray start?
  55230. * @param to when should the ray end?
  55231. * @returns PhysicsRaycastResult
  55232. */
  55233. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55234. }
  55235. }
  55236. declare module BABYLON {
  55237. /** @hidden */
  55238. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  55239. private _useDeltaForWorldStep;
  55240. world: any;
  55241. name: string;
  55242. private _physicsMaterials;
  55243. private _fixedTimeStep;
  55244. private _cannonRaycastResult;
  55245. private _raycastResult;
  55246. private _physicsBodysToRemoveAfterStep;
  55247. BJSCANNON: any;
  55248. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  55249. setGravity(gravity: Vector3): void;
  55250. setTimeStep(timeStep: number): void;
  55251. getTimeStep(): number;
  55252. executeStep(delta: number): void;
  55253. private _removeMarkedPhysicsBodiesFromWorld;
  55254. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55255. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55256. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55257. private _processChildMeshes;
  55258. removePhysicsBody(impostor: PhysicsImpostor): void;
  55259. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55260. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55261. private _addMaterial;
  55262. private _checkWithEpsilon;
  55263. private _createShape;
  55264. private _createHeightmap;
  55265. private _minus90X;
  55266. private _plus90X;
  55267. private _tmpPosition;
  55268. private _tmpDeltaPosition;
  55269. private _tmpUnityRotation;
  55270. private _updatePhysicsBodyTransformation;
  55271. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55272. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55273. isSupported(): boolean;
  55274. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55275. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55276. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55277. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55278. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55279. getBodyMass(impostor: PhysicsImpostor): number;
  55280. getBodyFriction(impostor: PhysicsImpostor): number;
  55281. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55282. getBodyRestitution(impostor: PhysicsImpostor): number;
  55283. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55284. sleepBody(impostor: PhysicsImpostor): void;
  55285. wakeUpBody(impostor: PhysicsImpostor): void;
  55286. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  55287. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55288. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55289. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55290. getRadius(impostor: PhysicsImpostor): number;
  55291. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55292. dispose(): void;
  55293. private _extendNamespace;
  55294. /**
  55295. * Does a raycast in the physics world
  55296. * @param from when should the ray start?
  55297. * @param to when should the ray end?
  55298. * @returns PhysicsRaycastResult
  55299. */
  55300. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55301. }
  55302. }
  55303. declare module BABYLON {
  55304. /** @hidden */
  55305. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  55306. world: any;
  55307. name: string;
  55308. BJSOIMO: any;
  55309. private _raycastResult;
  55310. constructor(iterations?: number, oimoInjection?: any);
  55311. setGravity(gravity: Vector3): void;
  55312. setTimeStep(timeStep: number): void;
  55313. getTimeStep(): number;
  55314. private _tmpImpostorsArray;
  55315. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55316. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55317. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55318. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55319. private _tmpPositionVector;
  55320. removePhysicsBody(impostor: PhysicsImpostor): void;
  55321. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55322. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55323. isSupported(): boolean;
  55324. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55325. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55326. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55327. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55328. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55329. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55330. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55331. getBodyMass(impostor: PhysicsImpostor): number;
  55332. getBodyFriction(impostor: PhysicsImpostor): number;
  55333. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55334. getBodyRestitution(impostor: PhysicsImpostor): number;
  55335. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55336. sleepBody(impostor: PhysicsImpostor): void;
  55337. wakeUpBody(impostor: PhysicsImpostor): void;
  55338. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55339. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55340. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55341. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55342. getRadius(impostor: PhysicsImpostor): number;
  55343. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55344. dispose(): void;
  55345. /**
  55346. * Does a raycast in the physics world
  55347. * @param from when should the ray start?
  55348. * @param to when should the ray end?
  55349. * @returns PhysicsRaycastResult
  55350. */
  55351. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55352. }
  55353. }
  55354. declare module BABYLON {
  55355. /**
  55356. * Class containing static functions to help procedurally build meshes
  55357. */
  55358. export class RibbonBuilder {
  55359. /**
  55360. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55361. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55362. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55363. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55364. * * 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
  55365. * * 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
  55366. * * 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
  55367. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55368. * * 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
  55369. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55370. * * 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
  55371. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55372. * * 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
  55373. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55375. * @param name defines the name of the mesh
  55376. * @param options defines the options used to create the mesh
  55377. * @param scene defines the hosting scene
  55378. * @returns the ribbon mesh
  55379. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55380. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55381. */
  55382. static CreateRibbon(name: string, options: {
  55383. pathArray: Vector3[][];
  55384. closeArray?: boolean;
  55385. closePath?: boolean;
  55386. offset?: number;
  55387. updatable?: boolean;
  55388. sideOrientation?: number;
  55389. frontUVs?: Vector4;
  55390. backUVs?: Vector4;
  55391. instance?: Mesh;
  55392. invertUV?: boolean;
  55393. uvs?: Vector2[];
  55394. colors?: Color4[];
  55395. }, scene?: Nullable<Scene>): Mesh;
  55396. }
  55397. }
  55398. declare module BABYLON {
  55399. /**
  55400. * Class containing static functions to help procedurally build meshes
  55401. */
  55402. export class ShapeBuilder {
  55403. /**
  55404. * 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.
  55405. * * 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.
  55406. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55407. * * 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.
  55408. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55409. * * 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
  55410. * * 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
  55411. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55412. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55413. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55414. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55415. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55416. * @param name defines the name of the mesh
  55417. * @param options defines the options used to create the mesh
  55418. * @param scene defines the hosting scene
  55419. * @returns the extruded shape mesh
  55420. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55421. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55422. */
  55423. static ExtrudeShape(name: string, options: {
  55424. shape: Vector3[];
  55425. path: Vector3[];
  55426. scale?: number;
  55427. rotation?: number;
  55428. cap?: number;
  55429. updatable?: boolean;
  55430. sideOrientation?: number;
  55431. frontUVs?: Vector4;
  55432. backUVs?: Vector4;
  55433. instance?: Mesh;
  55434. invertUV?: boolean;
  55435. }, scene?: Nullable<Scene>): Mesh;
  55436. /**
  55437. * Creates an custom extruded shape mesh.
  55438. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55439. * * 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.
  55440. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55441. * * 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
  55442. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55443. * * 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
  55444. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55445. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55446. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55447. * * 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
  55448. * * 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
  55449. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55450. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55451. * * 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
  55452. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55453. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55454. * @param name defines the name of the mesh
  55455. * @param options defines the options used to create the mesh
  55456. * @param scene defines the hosting scene
  55457. * @returns the custom extruded shape mesh
  55458. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55459. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55460. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55461. */
  55462. static ExtrudeShapeCustom(name: string, options: {
  55463. shape: Vector3[];
  55464. path: Vector3[];
  55465. scaleFunction?: any;
  55466. rotationFunction?: any;
  55467. ribbonCloseArray?: boolean;
  55468. ribbonClosePath?: boolean;
  55469. cap?: number;
  55470. updatable?: boolean;
  55471. sideOrientation?: number;
  55472. frontUVs?: Vector4;
  55473. backUVs?: Vector4;
  55474. instance?: Mesh;
  55475. invertUV?: boolean;
  55476. }, scene?: Nullable<Scene>): Mesh;
  55477. private static _ExtrudeShapeGeneric;
  55478. }
  55479. }
  55480. declare module BABYLON {
  55481. /**
  55482. * AmmoJS Physics plugin
  55483. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55484. * @see https://github.com/kripken/ammo.js/
  55485. */
  55486. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55487. private _useDeltaForWorldStep;
  55488. /**
  55489. * Reference to the Ammo library
  55490. */
  55491. bjsAMMO: any;
  55492. /**
  55493. * Created ammoJS world which physics bodies are added to
  55494. */
  55495. world: any;
  55496. /**
  55497. * Name of the plugin
  55498. */
  55499. name: string;
  55500. private _timeStep;
  55501. private _fixedTimeStep;
  55502. private _maxSteps;
  55503. private _tmpQuaternion;
  55504. private _tmpAmmoTransform;
  55505. private _tmpAmmoQuaternion;
  55506. private _tmpAmmoConcreteContactResultCallback;
  55507. private _collisionConfiguration;
  55508. private _dispatcher;
  55509. private _overlappingPairCache;
  55510. private _solver;
  55511. private _softBodySolver;
  55512. private _tmpAmmoVectorA;
  55513. private _tmpAmmoVectorB;
  55514. private _tmpAmmoVectorC;
  55515. private _tmpAmmoVectorD;
  55516. private _tmpContactCallbackResult;
  55517. private _tmpAmmoVectorRCA;
  55518. private _tmpAmmoVectorRCB;
  55519. private _raycastResult;
  55520. private static readonly DISABLE_COLLISION_FLAG;
  55521. private static readonly KINEMATIC_FLAG;
  55522. private static readonly DISABLE_DEACTIVATION_FLAG;
  55523. /**
  55524. * Initializes the ammoJS plugin
  55525. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  55526. * @param ammoInjection can be used to inject your own ammo reference
  55527. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  55528. */
  55529. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  55530. /**
  55531. * Sets the gravity of the physics world (m/(s^2))
  55532. * @param gravity Gravity to set
  55533. */
  55534. setGravity(gravity: Vector3): void;
  55535. /**
  55536. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  55537. * @param timeStep timestep to use in seconds
  55538. */
  55539. setTimeStep(timeStep: number): void;
  55540. /**
  55541. * 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)
  55542. * @param fixedTimeStep fixedTimeStep to use in seconds
  55543. */
  55544. setFixedTimeStep(fixedTimeStep: number): void;
  55545. /**
  55546. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  55547. * @param maxSteps the maximum number of steps by the physics engine per frame
  55548. */
  55549. setMaxSteps(maxSteps: number): void;
  55550. /**
  55551. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  55552. * @returns the current timestep in seconds
  55553. */
  55554. getTimeStep(): number;
  55555. /**
  55556. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  55557. */
  55558. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  55559. private _isImpostorInContact;
  55560. private _isImpostorPairInContact;
  55561. private _stepSimulation;
  55562. /**
  55563. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  55564. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  55565. * After the step the babylon meshes are set to the position of the physics imposters
  55566. * @param delta amount of time to step forward
  55567. * @param impostors array of imposters to update before/after the step
  55568. */
  55569. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55570. /**
  55571. * Update babylon mesh to match physics world object
  55572. * @param impostor imposter to match
  55573. */
  55574. private _afterSoftStep;
  55575. /**
  55576. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55577. * @param impostor imposter to match
  55578. */
  55579. private _ropeStep;
  55580. /**
  55581. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55582. * @param impostor imposter to match
  55583. */
  55584. private _softbodyOrClothStep;
  55585. private _tmpVector;
  55586. private _tmpMatrix;
  55587. /**
  55588. * Applies an impulse on the imposter
  55589. * @param impostor imposter to apply impulse to
  55590. * @param force amount of force to be applied to the imposter
  55591. * @param contactPoint the location to apply the impulse on the imposter
  55592. */
  55593. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55594. /**
  55595. * Applies a force on the imposter
  55596. * @param impostor imposter to apply force
  55597. * @param force amount of force to be applied to the imposter
  55598. * @param contactPoint the location to apply the force on the imposter
  55599. */
  55600. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55601. /**
  55602. * Creates a physics body using the plugin
  55603. * @param impostor the imposter to create the physics body on
  55604. */
  55605. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55606. /**
  55607. * Removes the physics body from the imposter and disposes of the body's memory
  55608. * @param impostor imposter to remove the physics body from
  55609. */
  55610. removePhysicsBody(impostor: PhysicsImpostor): void;
  55611. /**
  55612. * Generates a joint
  55613. * @param impostorJoint the imposter joint to create the joint with
  55614. */
  55615. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55616. /**
  55617. * Removes a joint
  55618. * @param impostorJoint the imposter joint to remove the joint from
  55619. */
  55620. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55621. private _addMeshVerts;
  55622. /**
  55623. * Initialise the soft body vertices to match its object's (mesh) vertices
  55624. * Softbody vertices (nodes) are in world space and to match this
  55625. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  55626. * @param impostor to create the softbody for
  55627. */
  55628. private _softVertexData;
  55629. /**
  55630. * Create an impostor's soft body
  55631. * @param impostor to create the softbody for
  55632. */
  55633. private _createSoftbody;
  55634. /**
  55635. * Create cloth for an impostor
  55636. * @param impostor to create the softbody for
  55637. */
  55638. private _createCloth;
  55639. /**
  55640. * Create rope for an impostor
  55641. * @param impostor to create the softbody for
  55642. */
  55643. private _createRope;
  55644. /**
  55645. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  55646. * @param impostor to create the custom physics shape for
  55647. */
  55648. private _createCustom;
  55649. private _addHullVerts;
  55650. private _createShape;
  55651. /**
  55652. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  55653. * @param impostor imposter containing the physics body and babylon object
  55654. */
  55655. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55656. /**
  55657. * Sets the babylon object's position/rotation from the physics body's position/rotation
  55658. * @param impostor imposter containing the physics body and babylon object
  55659. * @param newPosition new position
  55660. * @param newRotation new rotation
  55661. */
  55662. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55663. /**
  55664. * If this plugin is supported
  55665. * @returns true if its supported
  55666. */
  55667. isSupported(): boolean;
  55668. /**
  55669. * Sets the linear velocity of the physics body
  55670. * @param impostor imposter to set the velocity on
  55671. * @param velocity velocity to set
  55672. */
  55673. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55674. /**
  55675. * Sets the angular velocity of the physics body
  55676. * @param impostor imposter to set the velocity on
  55677. * @param velocity velocity to set
  55678. */
  55679. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55680. /**
  55681. * gets the linear velocity
  55682. * @param impostor imposter to get linear velocity from
  55683. * @returns linear velocity
  55684. */
  55685. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55686. /**
  55687. * gets the angular velocity
  55688. * @param impostor imposter to get angular velocity from
  55689. * @returns angular velocity
  55690. */
  55691. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55692. /**
  55693. * Sets the mass of physics body
  55694. * @param impostor imposter to set the mass on
  55695. * @param mass mass to set
  55696. */
  55697. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55698. /**
  55699. * Gets the mass of the physics body
  55700. * @param impostor imposter to get the mass from
  55701. * @returns mass
  55702. */
  55703. getBodyMass(impostor: PhysicsImpostor): number;
  55704. /**
  55705. * Gets friction of the impostor
  55706. * @param impostor impostor to get friction from
  55707. * @returns friction value
  55708. */
  55709. getBodyFriction(impostor: PhysicsImpostor): number;
  55710. /**
  55711. * Sets friction of the impostor
  55712. * @param impostor impostor to set friction on
  55713. * @param friction friction value
  55714. */
  55715. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55716. /**
  55717. * Gets restitution of the impostor
  55718. * @param impostor impostor to get restitution from
  55719. * @returns restitution value
  55720. */
  55721. getBodyRestitution(impostor: PhysicsImpostor): number;
  55722. /**
  55723. * Sets resitution of the impostor
  55724. * @param impostor impostor to set resitution on
  55725. * @param restitution resitution value
  55726. */
  55727. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55728. /**
  55729. * Gets pressure inside the impostor
  55730. * @param impostor impostor to get pressure from
  55731. * @returns pressure value
  55732. */
  55733. getBodyPressure(impostor: PhysicsImpostor): number;
  55734. /**
  55735. * Sets pressure inside a soft body impostor
  55736. * Cloth and rope must remain 0 pressure
  55737. * @param impostor impostor to set pressure on
  55738. * @param pressure pressure value
  55739. */
  55740. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  55741. /**
  55742. * Gets stiffness of the impostor
  55743. * @param impostor impostor to get stiffness from
  55744. * @returns pressure value
  55745. */
  55746. getBodyStiffness(impostor: PhysicsImpostor): number;
  55747. /**
  55748. * Sets stiffness of the impostor
  55749. * @param impostor impostor to set stiffness on
  55750. * @param stiffness stiffness value from 0 to 1
  55751. */
  55752. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  55753. /**
  55754. * Gets velocityIterations of the impostor
  55755. * @param impostor impostor to get velocity iterations from
  55756. * @returns velocityIterations value
  55757. */
  55758. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  55759. /**
  55760. * Sets velocityIterations of the impostor
  55761. * @param impostor impostor to set velocity iterations on
  55762. * @param velocityIterations velocityIterations value
  55763. */
  55764. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  55765. /**
  55766. * Gets positionIterations of the impostor
  55767. * @param impostor impostor to get position iterations from
  55768. * @returns positionIterations value
  55769. */
  55770. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  55771. /**
  55772. * Sets positionIterations of the impostor
  55773. * @param impostor impostor to set position on
  55774. * @param positionIterations positionIterations value
  55775. */
  55776. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  55777. /**
  55778. * Append an anchor to a cloth object
  55779. * @param impostor is the cloth impostor to add anchor to
  55780. * @param otherImpostor is the rigid impostor to anchor to
  55781. * @param width ratio across width from 0 to 1
  55782. * @param height ratio up height from 0 to 1
  55783. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  55784. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55785. */
  55786. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55787. /**
  55788. * Append an hook to a rope object
  55789. * @param impostor is the rope impostor to add hook to
  55790. * @param otherImpostor is the rigid impostor to hook to
  55791. * @param length ratio along the rope from 0 to 1
  55792. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  55793. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55794. */
  55795. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55796. /**
  55797. * Sleeps the physics body and stops it from being active
  55798. * @param impostor impostor to sleep
  55799. */
  55800. sleepBody(impostor: PhysicsImpostor): void;
  55801. /**
  55802. * Activates the physics body
  55803. * @param impostor impostor to activate
  55804. */
  55805. wakeUpBody(impostor: PhysicsImpostor): void;
  55806. /**
  55807. * Updates the distance parameters of the joint
  55808. * @param joint joint to update
  55809. * @param maxDistance maximum distance of the joint
  55810. * @param minDistance minimum distance of the joint
  55811. */
  55812. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55813. /**
  55814. * Sets a motor on the joint
  55815. * @param joint joint to set motor on
  55816. * @param speed speed of the motor
  55817. * @param maxForce maximum force of the motor
  55818. * @param motorIndex index of the motor
  55819. */
  55820. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55821. /**
  55822. * Sets the motors limit
  55823. * @param joint joint to set limit on
  55824. * @param upperLimit upper limit
  55825. * @param lowerLimit lower limit
  55826. */
  55827. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55828. /**
  55829. * Syncs the position and rotation of a mesh with the impostor
  55830. * @param mesh mesh to sync
  55831. * @param impostor impostor to update the mesh with
  55832. */
  55833. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55834. /**
  55835. * Gets the radius of the impostor
  55836. * @param impostor impostor to get radius from
  55837. * @returns the radius
  55838. */
  55839. getRadius(impostor: PhysicsImpostor): number;
  55840. /**
  55841. * Gets the box size of the impostor
  55842. * @param impostor impostor to get box size from
  55843. * @param result the resulting box size
  55844. */
  55845. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55846. /**
  55847. * Disposes of the impostor
  55848. */
  55849. dispose(): void;
  55850. /**
  55851. * Does a raycast in the physics world
  55852. * @param from when should the ray start?
  55853. * @param to when should the ray end?
  55854. * @returns PhysicsRaycastResult
  55855. */
  55856. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55857. }
  55858. }
  55859. declare module BABYLON {
  55860. interface AbstractScene {
  55861. /**
  55862. * The list of reflection probes added to the scene
  55863. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55864. */
  55865. reflectionProbes: Array<ReflectionProbe>;
  55866. /**
  55867. * Removes the given reflection probe from this scene.
  55868. * @param toRemove The reflection probe to remove
  55869. * @returns The index of the removed reflection probe
  55870. */
  55871. removeReflectionProbe(toRemove: ReflectionProbe): number;
  55872. /**
  55873. * Adds the given reflection probe to this scene.
  55874. * @param newReflectionProbe The reflection probe to add
  55875. */
  55876. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  55877. }
  55878. /**
  55879. * Class used to generate realtime reflection / refraction cube textures
  55880. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55881. */
  55882. export class ReflectionProbe {
  55883. /** defines the name of the probe */
  55884. name: string;
  55885. private _scene;
  55886. private _renderTargetTexture;
  55887. private _projectionMatrix;
  55888. private _viewMatrix;
  55889. private _target;
  55890. private _add;
  55891. private _attachedMesh;
  55892. private _invertYAxis;
  55893. /** Gets or sets probe position (center of the cube map) */
  55894. position: Vector3;
  55895. /**
  55896. * Creates a new reflection probe
  55897. * @param name defines the name of the probe
  55898. * @param size defines the texture resolution (for each face)
  55899. * @param scene defines the hosting scene
  55900. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  55901. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  55902. */
  55903. constructor(
  55904. /** defines the name of the probe */
  55905. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  55906. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  55907. get samples(): number;
  55908. set samples(value: number);
  55909. /** Gets or sets the refresh rate to use (on every frame by default) */
  55910. get refreshRate(): number;
  55911. set refreshRate(value: number);
  55912. /**
  55913. * Gets the hosting scene
  55914. * @returns a Scene
  55915. */
  55916. getScene(): Scene;
  55917. /** Gets the internal CubeTexture used to render to */
  55918. get cubeTexture(): RenderTargetTexture;
  55919. /** Gets the list of meshes to render */
  55920. get renderList(): Nullable<AbstractMesh[]>;
  55921. /**
  55922. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  55923. * @param mesh defines the mesh to attach to
  55924. */
  55925. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55926. /**
  55927. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  55928. * @param renderingGroupId The rendering group id corresponding to its index
  55929. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  55930. */
  55931. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  55932. /**
  55933. * Clean all associated resources
  55934. */
  55935. dispose(): void;
  55936. /**
  55937. * Converts the reflection probe information to a readable string for debug purpose.
  55938. * @param fullDetails Supports for multiple levels of logging within scene loading
  55939. * @returns the human readable reflection probe info
  55940. */
  55941. toString(fullDetails?: boolean): string;
  55942. /**
  55943. * Get the class name of the relfection probe.
  55944. * @returns "ReflectionProbe"
  55945. */
  55946. getClassName(): string;
  55947. /**
  55948. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  55949. * @returns The JSON representation of the texture
  55950. */
  55951. serialize(): any;
  55952. /**
  55953. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  55954. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  55955. * @param scene Define the scene the parsed reflection probe should be instantiated in
  55956. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  55957. * @returns The parsed reflection probe if successful
  55958. */
  55959. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  55960. }
  55961. }
  55962. declare module BABYLON {
  55963. /** @hidden */
  55964. export var _BabylonLoaderRegistered: boolean;
  55965. /**
  55966. * Helps setting up some configuration for the babylon file loader.
  55967. */
  55968. export class BabylonFileLoaderConfiguration {
  55969. /**
  55970. * The loader does not allow injecting custom physix engine into the plugins.
  55971. * Unfortunately in ES6, we need to manually inject them into the plugin.
  55972. * So you could set this variable to your engine import to make it work.
  55973. */
  55974. static LoaderInjectedPhysicsEngine: any;
  55975. }
  55976. }
  55977. declare module BABYLON {
  55978. /**
  55979. * The Physically based simple base material of BJS.
  55980. *
  55981. * This enables better naming and convention enforcements on top of the pbrMaterial.
  55982. * It is used as the base class for both the specGloss and metalRough conventions.
  55983. */
  55984. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  55985. /**
  55986. * Number of Simultaneous lights allowed on the material.
  55987. */
  55988. maxSimultaneousLights: number;
  55989. /**
  55990. * If sets to true, disables all the lights affecting the material.
  55991. */
  55992. disableLighting: boolean;
  55993. /**
  55994. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  55995. */
  55996. environmentTexture: BaseTexture;
  55997. /**
  55998. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55999. */
  56000. invertNormalMapX: boolean;
  56001. /**
  56002. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56003. */
  56004. invertNormalMapY: boolean;
  56005. /**
  56006. * Normal map used in the model.
  56007. */
  56008. normalTexture: BaseTexture;
  56009. /**
  56010. * Emissivie color used to self-illuminate the model.
  56011. */
  56012. emissiveColor: Color3;
  56013. /**
  56014. * Emissivie texture used to self-illuminate the model.
  56015. */
  56016. emissiveTexture: BaseTexture;
  56017. /**
  56018. * Occlusion Channel Strenght.
  56019. */
  56020. occlusionStrength: number;
  56021. /**
  56022. * Occlusion Texture of the material (adding extra occlusion effects).
  56023. */
  56024. occlusionTexture: BaseTexture;
  56025. /**
  56026. * Defines the alpha limits in alpha test mode.
  56027. */
  56028. alphaCutOff: number;
  56029. /**
  56030. * Gets the current double sided mode.
  56031. */
  56032. get doubleSided(): boolean;
  56033. /**
  56034. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56035. */
  56036. set doubleSided(value: boolean);
  56037. /**
  56038. * Stores the pre-calculated light information of a mesh in a texture.
  56039. */
  56040. lightmapTexture: BaseTexture;
  56041. /**
  56042. * If true, the light map contains occlusion information instead of lighting info.
  56043. */
  56044. useLightmapAsShadowmap: boolean;
  56045. /**
  56046. * Instantiates a new PBRMaterial instance.
  56047. *
  56048. * @param name The material name
  56049. * @param scene The scene the material will be use in.
  56050. */
  56051. constructor(name: string, scene: Scene);
  56052. getClassName(): string;
  56053. }
  56054. }
  56055. declare module BABYLON {
  56056. /**
  56057. * The PBR material of BJS following the metal roughness convention.
  56058. *
  56059. * This fits to the PBR convention in the GLTF definition:
  56060. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  56061. */
  56062. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  56063. /**
  56064. * The base color has two different interpretations depending on the value of metalness.
  56065. * When the material is a metal, the base color is the specific measured reflectance value
  56066. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  56067. * of the material.
  56068. */
  56069. baseColor: Color3;
  56070. /**
  56071. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  56072. * well as opacity information in the alpha channel.
  56073. */
  56074. baseTexture: BaseTexture;
  56075. /**
  56076. * Specifies the metallic scalar value of the material.
  56077. * Can also be used to scale the metalness values of the metallic texture.
  56078. */
  56079. metallic: number;
  56080. /**
  56081. * Specifies the roughness scalar value of the material.
  56082. * Can also be used to scale the roughness values of the metallic texture.
  56083. */
  56084. roughness: number;
  56085. /**
  56086. * Texture containing both the metallic value in the B channel and the
  56087. * roughness value in the G channel to keep better precision.
  56088. */
  56089. metallicRoughnessTexture: BaseTexture;
  56090. /**
  56091. * Instantiates a new PBRMetalRoughnessMaterial instance.
  56092. *
  56093. * @param name The material name
  56094. * @param scene The scene the material will be use in.
  56095. */
  56096. constructor(name: string, scene: Scene);
  56097. /**
  56098. * Return the currrent class name of the material.
  56099. */
  56100. getClassName(): string;
  56101. /**
  56102. * Makes a duplicate of the current material.
  56103. * @param name - name to use for the new material.
  56104. */
  56105. clone(name: string): PBRMetallicRoughnessMaterial;
  56106. /**
  56107. * Serialize the material to a parsable JSON object.
  56108. */
  56109. serialize(): any;
  56110. /**
  56111. * Parses a JSON object correponding to the serialize function.
  56112. */
  56113. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  56114. }
  56115. }
  56116. declare module BABYLON {
  56117. /**
  56118. * The PBR material of BJS following the specular glossiness convention.
  56119. *
  56120. * This fits to the PBR convention in the GLTF definition:
  56121. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  56122. */
  56123. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  56124. /**
  56125. * Specifies the diffuse color of the material.
  56126. */
  56127. diffuseColor: Color3;
  56128. /**
  56129. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  56130. * channel.
  56131. */
  56132. diffuseTexture: BaseTexture;
  56133. /**
  56134. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  56135. */
  56136. specularColor: Color3;
  56137. /**
  56138. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  56139. */
  56140. glossiness: number;
  56141. /**
  56142. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  56143. */
  56144. specularGlossinessTexture: BaseTexture;
  56145. /**
  56146. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  56147. *
  56148. * @param name The material name
  56149. * @param scene The scene the material will be use in.
  56150. */
  56151. constructor(name: string, scene: Scene);
  56152. /**
  56153. * Return the currrent class name of the material.
  56154. */
  56155. getClassName(): string;
  56156. /**
  56157. * Makes a duplicate of the current material.
  56158. * @param name - name to use for the new material.
  56159. */
  56160. clone(name: string): PBRSpecularGlossinessMaterial;
  56161. /**
  56162. * Serialize the material to a parsable JSON object.
  56163. */
  56164. serialize(): any;
  56165. /**
  56166. * Parses a JSON object correponding to the serialize function.
  56167. */
  56168. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  56169. }
  56170. }
  56171. declare module BABYLON {
  56172. /**
  56173. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  56174. * It can help converting any input color in a desired output one. This can then be used to create effects
  56175. * from sepia, black and white to sixties or futuristic rendering...
  56176. *
  56177. * The only supported format is currently 3dl.
  56178. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  56179. */
  56180. export class ColorGradingTexture extends BaseTexture {
  56181. /**
  56182. * The current texture matrix. (will always be identity in color grading texture)
  56183. */
  56184. private _textureMatrix;
  56185. /**
  56186. * The texture URL.
  56187. */
  56188. url: string;
  56189. /**
  56190. * Empty line regex stored for GC.
  56191. */
  56192. private static _noneEmptyLineRegex;
  56193. private _engine;
  56194. /**
  56195. * Instantiates a ColorGradingTexture from the following parameters.
  56196. *
  56197. * @param url The location of the color gradind data (currently only supporting 3dl)
  56198. * @param scene The scene the texture will be used in
  56199. */
  56200. constructor(url: string, scene: Scene);
  56201. /**
  56202. * Returns the texture matrix used in most of the material.
  56203. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  56204. */
  56205. getTextureMatrix(): Matrix;
  56206. /**
  56207. * Occurs when the file being loaded is a .3dl LUT file.
  56208. */
  56209. private load3dlTexture;
  56210. /**
  56211. * Starts the loading process of the texture.
  56212. */
  56213. private loadTexture;
  56214. /**
  56215. * Clones the color gradind texture.
  56216. */
  56217. clone(): ColorGradingTexture;
  56218. /**
  56219. * Called during delayed load for textures.
  56220. */
  56221. delayLoad(): void;
  56222. /**
  56223. * Parses a color grading texture serialized by Babylon.
  56224. * @param parsedTexture The texture information being parsedTexture
  56225. * @param scene The scene to load the texture in
  56226. * @param rootUrl The root url of the data assets to load
  56227. * @return A color gradind texture
  56228. */
  56229. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  56230. /**
  56231. * Serializes the LUT texture to json format.
  56232. */
  56233. serialize(): any;
  56234. }
  56235. }
  56236. declare module BABYLON {
  56237. /**
  56238. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  56239. */
  56240. export class EquiRectangularCubeTexture extends BaseTexture {
  56241. /** The six faces of the cube. */
  56242. private static _FacesMapping;
  56243. private _noMipmap;
  56244. private _onLoad;
  56245. private _onError;
  56246. /** The size of the cubemap. */
  56247. private _size;
  56248. /** The buffer of the image. */
  56249. private _buffer;
  56250. /** The width of the input image. */
  56251. private _width;
  56252. /** The height of the input image. */
  56253. private _height;
  56254. /** The URL to the image. */
  56255. url: string;
  56256. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  56257. coordinatesMode: number;
  56258. /**
  56259. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  56260. * @param url The location of the image
  56261. * @param scene The scene the texture will be used in
  56262. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56263. * @param noMipmap Forces to not generate the mipmap if true
  56264. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56265. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56266. * @param onLoad — defines a callback called when texture is loaded
  56267. * @param onError — defines a callback called if there is an error
  56268. */
  56269. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  56270. /**
  56271. * Load the image data, by putting the image on a canvas and extracting its buffer.
  56272. */
  56273. private loadImage;
  56274. /**
  56275. * Convert the image buffer into a cubemap and create a CubeTexture.
  56276. */
  56277. private loadTexture;
  56278. /**
  56279. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  56280. * @param buffer The ArrayBuffer that should be converted.
  56281. * @returns The buffer as Float32Array.
  56282. */
  56283. private getFloat32ArrayFromArrayBuffer;
  56284. /**
  56285. * Get the current class name of the texture useful for serialization or dynamic coding.
  56286. * @returns "EquiRectangularCubeTexture"
  56287. */
  56288. getClassName(): string;
  56289. /**
  56290. * Create a clone of the current EquiRectangularCubeTexture and return it.
  56291. * @returns A clone of the current EquiRectangularCubeTexture.
  56292. */
  56293. clone(): EquiRectangularCubeTexture;
  56294. }
  56295. }
  56296. declare module BABYLON {
  56297. /**
  56298. * Based on jsTGALoader - Javascript loader for TGA file
  56299. * By Vincent Thibault
  56300. * @see http://blog.robrowser.com/javascript-tga-loader.html
  56301. */
  56302. export class TGATools {
  56303. private static _TYPE_INDEXED;
  56304. private static _TYPE_RGB;
  56305. private static _TYPE_GREY;
  56306. private static _TYPE_RLE_INDEXED;
  56307. private static _TYPE_RLE_RGB;
  56308. private static _TYPE_RLE_GREY;
  56309. private static _ORIGIN_MASK;
  56310. private static _ORIGIN_SHIFT;
  56311. private static _ORIGIN_BL;
  56312. private static _ORIGIN_BR;
  56313. private static _ORIGIN_UL;
  56314. private static _ORIGIN_UR;
  56315. /**
  56316. * Gets the header of a TGA file
  56317. * @param data defines the TGA data
  56318. * @returns the header
  56319. */
  56320. static GetTGAHeader(data: Uint8Array): any;
  56321. /**
  56322. * Uploads TGA content to a Babylon Texture
  56323. * @hidden
  56324. */
  56325. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56326. /** @hidden */
  56327. 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;
  56328. /** @hidden */
  56329. 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;
  56330. /** @hidden */
  56331. 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;
  56332. /** @hidden */
  56333. 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;
  56334. /** @hidden */
  56335. 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;
  56336. /** @hidden */
  56337. 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;
  56338. }
  56339. }
  56340. declare module BABYLON {
  56341. /**
  56342. * Implementation of the TGA Texture Loader.
  56343. * @hidden
  56344. */
  56345. export class _TGATextureLoader implements IInternalTextureLoader {
  56346. /**
  56347. * Defines wether the loader supports cascade loading the different faces.
  56348. */
  56349. readonly supportCascades: boolean;
  56350. /**
  56351. * This returns if the loader support the current file information.
  56352. * @param extension defines the file extension of the file being loaded
  56353. * @returns true if the loader can load the specified file
  56354. */
  56355. canLoad(extension: string): boolean;
  56356. /**
  56357. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56358. * @param data contains the texture data
  56359. * @param texture defines the BabylonJS internal texture
  56360. * @param createPolynomials will be true if polynomials have been requested
  56361. * @param onLoad defines the callback to trigger once the texture is ready
  56362. * @param onError defines the callback to trigger in case of error
  56363. */
  56364. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56365. /**
  56366. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56367. * @param data contains the texture data
  56368. * @param texture defines the BabylonJS internal texture
  56369. * @param callback defines the method to call once ready to upload
  56370. */
  56371. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56372. }
  56373. }
  56374. declare module BABYLON {
  56375. /**
  56376. * Info about the .basis files
  56377. */
  56378. class BasisFileInfo {
  56379. /**
  56380. * If the file has alpha
  56381. */
  56382. hasAlpha: boolean;
  56383. /**
  56384. * Info about each image of the basis file
  56385. */
  56386. images: Array<{
  56387. levels: Array<{
  56388. width: number;
  56389. height: number;
  56390. transcodedPixels: ArrayBufferView;
  56391. }>;
  56392. }>;
  56393. }
  56394. /**
  56395. * Result of transcoding a basis file
  56396. */
  56397. class TranscodeResult {
  56398. /**
  56399. * Info about the .basis file
  56400. */
  56401. fileInfo: BasisFileInfo;
  56402. /**
  56403. * Format to use when loading the file
  56404. */
  56405. format: number;
  56406. }
  56407. /**
  56408. * Configuration options for the Basis transcoder
  56409. */
  56410. export class BasisTranscodeConfiguration {
  56411. /**
  56412. * Supported compression formats used to determine the supported output format of the transcoder
  56413. */
  56414. supportedCompressionFormats?: {
  56415. /**
  56416. * etc1 compression format
  56417. */
  56418. etc1?: boolean;
  56419. /**
  56420. * s3tc compression format
  56421. */
  56422. s3tc?: boolean;
  56423. /**
  56424. * pvrtc compression format
  56425. */
  56426. pvrtc?: boolean;
  56427. /**
  56428. * etc2 compression format
  56429. */
  56430. etc2?: boolean;
  56431. };
  56432. /**
  56433. * If mipmap levels should be loaded for transcoded images (Default: true)
  56434. */
  56435. loadMipmapLevels?: boolean;
  56436. /**
  56437. * Index of a single image to load (Default: all images)
  56438. */
  56439. loadSingleImage?: number;
  56440. }
  56441. /**
  56442. * Used to load .Basis files
  56443. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56444. */
  56445. export class BasisTools {
  56446. private static _IgnoreSupportedFormats;
  56447. /**
  56448. * URL to use when loading the basis transcoder
  56449. */
  56450. static JSModuleURL: string;
  56451. /**
  56452. * URL to use when loading the wasm module for the transcoder
  56453. */
  56454. static WasmModuleURL: string;
  56455. /**
  56456. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56457. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56458. * @returns internal format corresponding to the Basis format
  56459. */
  56460. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56461. private static _WorkerPromise;
  56462. private static _Worker;
  56463. private static _actionId;
  56464. private static _CreateWorkerAsync;
  56465. /**
  56466. * Transcodes a loaded image file to compressed pixel data
  56467. * @param data image data to transcode
  56468. * @param config configuration options for the transcoding
  56469. * @returns a promise resulting in the transcoded image
  56470. */
  56471. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56472. /**
  56473. * Loads a texture from the transcode result
  56474. * @param texture texture load to
  56475. * @param transcodeResult the result of transcoding the basis file to load from
  56476. */
  56477. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56478. }
  56479. }
  56480. declare module BABYLON {
  56481. /**
  56482. * Loader for .basis file format
  56483. */
  56484. export class _BasisTextureLoader implements IInternalTextureLoader {
  56485. /**
  56486. * Defines whether the loader supports cascade loading the different faces.
  56487. */
  56488. readonly supportCascades: boolean;
  56489. /**
  56490. * This returns if the loader support the current file information.
  56491. * @param extension defines the file extension of the file being loaded
  56492. * @returns true if the loader can load the specified file
  56493. */
  56494. canLoad(extension: string): boolean;
  56495. /**
  56496. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56497. * @param data contains the texture data
  56498. * @param texture defines the BabylonJS internal texture
  56499. * @param createPolynomials will be true if polynomials have been requested
  56500. * @param onLoad defines the callback to trigger once the texture is ready
  56501. * @param onError defines the callback to trigger in case of error
  56502. */
  56503. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56504. /**
  56505. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56506. * @param data contains the texture data
  56507. * @param texture defines the BabylonJS internal texture
  56508. * @param callback defines the method to call once ready to upload
  56509. */
  56510. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56511. }
  56512. }
  56513. declare module BABYLON {
  56514. /**
  56515. * 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.
  56516. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56517. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56518. */
  56519. export class CustomProceduralTexture extends ProceduralTexture {
  56520. private _animate;
  56521. private _time;
  56522. private _config;
  56523. private _texturePath;
  56524. /**
  56525. * Instantiates a new Custom Procedural Texture.
  56526. * 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.
  56527. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56528. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56529. * @param name Define the name of the texture
  56530. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56531. * @param size Define the size of the texture to create
  56532. * @param scene Define the scene the texture belongs to
  56533. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56534. * @param generateMipMaps Define if the texture should creates mip maps or not
  56535. */
  56536. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56537. private _loadJson;
  56538. /**
  56539. * Is the texture ready to be used ? (rendered at least once)
  56540. * @returns true if ready, otherwise, false.
  56541. */
  56542. isReady(): boolean;
  56543. /**
  56544. * Render the texture to its associated render target.
  56545. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56546. */
  56547. render(useCameraPostProcess?: boolean): void;
  56548. /**
  56549. * Update the list of dependant textures samplers in the shader.
  56550. */
  56551. updateTextures(): void;
  56552. /**
  56553. * Update the uniform values of the procedural texture in the shader.
  56554. */
  56555. updateShaderUniforms(): void;
  56556. /**
  56557. * Define if the texture animates or not.
  56558. */
  56559. get animate(): boolean;
  56560. set animate(value: boolean);
  56561. }
  56562. }
  56563. declare module BABYLON {
  56564. /** @hidden */
  56565. export var noisePixelShader: {
  56566. name: string;
  56567. shader: string;
  56568. };
  56569. }
  56570. declare module BABYLON {
  56571. /**
  56572. * Class used to generate noise procedural textures
  56573. */
  56574. export class NoiseProceduralTexture extends ProceduralTexture {
  56575. private _time;
  56576. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56577. brightness: number;
  56578. /** Defines the number of octaves to process */
  56579. octaves: number;
  56580. /** Defines the level of persistence (0.8 by default) */
  56581. persistence: number;
  56582. /** Gets or sets animation speed factor (default is 1) */
  56583. animationSpeedFactor: number;
  56584. /**
  56585. * Creates a new NoiseProceduralTexture
  56586. * @param name defines the name fo the texture
  56587. * @param size defines the size of the texture (default is 256)
  56588. * @param scene defines the hosting scene
  56589. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56590. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56591. */
  56592. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56593. private _updateShaderUniforms;
  56594. protected _getDefines(): string;
  56595. /** Generate the current state of the procedural texture */
  56596. render(useCameraPostProcess?: boolean): void;
  56597. /**
  56598. * Serializes this noise procedural texture
  56599. * @returns a serialized noise procedural texture object
  56600. */
  56601. serialize(): any;
  56602. /**
  56603. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56604. * @param parsedTexture defines parsed texture data
  56605. * @param scene defines the current scene
  56606. * @param rootUrl defines the root URL containing noise procedural texture information
  56607. * @returns a parsed NoiseProceduralTexture
  56608. */
  56609. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  56610. }
  56611. }
  56612. declare module BABYLON {
  56613. /**
  56614. * Raw cube texture where the raw buffers are passed in
  56615. */
  56616. export class RawCubeTexture extends CubeTexture {
  56617. /**
  56618. * Creates a cube texture where the raw buffers are passed in.
  56619. * @param scene defines the scene the texture is attached to
  56620. * @param data defines the array of data to use to create each face
  56621. * @param size defines the size of the textures
  56622. * @param format defines the format of the data
  56623. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56624. * @param generateMipMaps defines if the engine should generate the mip levels
  56625. * @param invertY defines if data must be stored with Y axis inverted
  56626. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56627. * @param compression defines the compression used (null by default)
  56628. */
  56629. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  56630. /**
  56631. * Updates the raw cube texture.
  56632. * @param data defines the data to store
  56633. * @param format defines the data format
  56634. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56635. * @param invertY defines if data must be stored with Y axis inverted
  56636. * @param compression defines the compression used (null by default)
  56637. * @param level defines which level of the texture to update
  56638. */
  56639. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  56640. /**
  56641. * Updates a raw cube texture with RGBD encoded data.
  56642. * @param data defines the array of data [mipmap][face] to use to create each face
  56643. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56644. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56645. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56646. * @returns a promsie that resolves when the operation is complete
  56647. */
  56648. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  56649. /**
  56650. * Clones the raw cube texture.
  56651. * @return a new cube texture
  56652. */
  56653. clone(): CubeTexture;
  56654. /** @hidden */
  56655. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56656. }
  56657. }
  56658. declare module BABYLON {
  56659. /**
  56660. * Class used to store 3D textures containing user data
  56661. */
  56662. export class RawTexture3D extends Texture {
  56663. /** Gets or sets the texture format to use */
  56664. format: number;
  56665. private _engine;
  56666. /**
  56667. * Create a new RawTexture3D
  56668. * @param data defines the data of the texture
  56669. * @param width defines the width of the texture
  56670. * @param height defines the height of the texture
  56671. * @param depth defines the depth of the texture
  56672. * @param format defines the texture format to use
  56673. * @param scene defines the hosting scene
  56674. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56675. * @param invertY defines if texture must be stored with Y axis inverted
  56676. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56677. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56678. */
  56679. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56680. /** Gets or sets the texture format to use */
  56681. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56682. /**
  56683. * Update the texture with new data
  56684. * @param data defines the data to store in the texture
  56685. */
  56686. update(data: ArrayBufferView): void;
  56687. }
  56688. }
  56689. declare module BABYLON {
  56690. /**
  56691. * Class used to store 2D array textures containing user data
  56692. */
  56693. export class RawTexture2DArray extends Texture {
  56694. /** Gets or sets the texture format to use */
  56695. format: number;
  56696. private _engine;
  56697. /**
  56698. * Create a new RawTexture2DArray
  56699. * @param data defines the data of the texture
  56700. * @param width defines the width of the texture
  56701. * @param height defines the height of the texture
  56702. * @param depth defines the number of layers of the texture
  56703. * @param format defines the texture format to use
  56704. * @param scene defines the hosting scene
  56705. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56706. * @param invertY defines if texture must be stored with Y axis inverted
  56707. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56708. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56709. */
  56710. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56711. /** Gets or sets the texture format to use */
  56712. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56713. /**
  56714. * Update the texture with new data
  56715. * @param data defines the data to store in the texture
  56716. */
  56717. update(data: ArrayBufferView): void;
  56718. }
  56719. }
  56720. declare module BABYLON {
  56721. /**
  56722. * Creates a refraction texture used by refraction channel of the standard material.
  56723. * It is like a mirror but to see through a material.
  56724. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56725. */
  56726. export class RefractionTexture extends RenderTargetTexture {
  56727. /**
  56728. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56729. * 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.
  56730. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56731. */
  56732. refractionPlane: Plane;
  56733. /**
  56734. * Define how deep under the surface we should see.
  56735. */
  56736. depth: number;
  56737. /**
  56738. * Creates a refraction texture used by refraction channel of the standard material.
  56739. * It is like a mirror but to see through a material.
  56740. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56741. * @param name Define the texture name
  56742. * @param size Define the size of the underlying texture
  56743. * @param scene Define the scene the refraction belongs to
  56744. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56745. */
  56746. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  56747. /**
  56748. * Clone the refraction texture.
  56749. * @returns the cloned texture
  56750. */
  56751. clone(): RefractionTexture;
  56752. /**
  56753. * Serialize the texture to a JSON representation you could use in Parse later on
  56754. * @returns the serialized JSON representation
  56755. */
  56756. serialize(): any;
  56757. }
  56758. }
  56759. declare module BABYLON {
  56760. /**
  56761. * Defines the options related to the creation of an HtmlElementTexture
  56762. */
  56763. export interface IHtmlElementTextureOptions {
  56764. /**
  56765. * Defines wether mip maps should be created or not.
  56766. */
  56767. generateMipMaps?: boolean;
  56768. /**
  56769. * Defines the sampling mode of the texture.
  56770. */
  56771. samplingMode?: number;
  56772. /**
  56773. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  56774. */
  56775. engine: Nullable<ThinEngine>;
  56776. /**
  56777. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  56778. */
  56779. scene: Nullable<Scene>;
  56780. }
  56781. /**
  56782. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  56783. * To be as efficient as possible depending on your constraints nothing aside the first upload
  56784. * is automatically managed.
  56785. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  56786. * in your application.
  56787. *
  56788. * As the update is not automatic, you need to call them manually.
  56789. */
  56790. export class HtmlElementTexture extends BaseTexture {
  56791. /**
  56792. * The texture URL.
  56793. */
  56794. element: HTMLVideoElement | HTMLCanvasElement;
  56795. private static readonly DefaultOptions;
  56796. private _textureMatrix;
  56797. private _engine;
  56798. private _isVideo;
  56799. private _generateMipMaps;
  56800. private _samplingMode;
  56801. /**
  56802. * Instantiates a HtmlElementTexture from the following parameters.
  56803. *
  56804. * @param name Defines the name of the texture
  56805. * @param element Defines the video or canvas the texture is filled with
  56806. * @param options Defines the other none mandatory texture creation options
  56807. */
  56808. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  56809. private _createInternalTexture;
  56810. /**
  56811. * Returns the texture matrix used in most of the material.
  56812. */
  56813. getTextureMatrix(): Matrix;
  56814. /**
  56815. * Updates the content of the texture.
  56816. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  56817. */
  56818. update(invertY?: Nullable<boolean>): void;
  56819. }
  56820. }
  56821. declare module BABYLON {
  56822. /**
  56823. * Defines the basic options interface of a TexturePacker Frame
  56824. */
  56825. export interface ITexturePackerFrame {
  56826. /**
  56827. * The frame ID
  56828. */
  56829. id: number;
  56830. /**
  56831. * The frames Scale
  56832. */
  56833. scale: Vector2;
  56834. /**
  56835. * The Frames offset
  56836. */
  56837. offset: Vector2;
  56838. }
  56839. /**
  56840. * This is a support class for frame Data on texture packer sets.
  56841. */
  56842. export class TexturePackerFrame implements ITexturePackerFrame {
  56843. /**
  56844. * The frame ID
  56845. */
  56846. id: number;
  56847. /**
  56848. * The frames Scale
  56849. */
  56850. scale: Vector2;
  56851. /**
  56852. * The Frames offset
  56853. */
  56854. offset: Vector2;
  56855. /**
  56856. * Initializes a texture package frame.
  56857. * @param id The numerical frame identifier
  56858. * @param scale Scalar Vector2 for UV frame
  56859. * @param offset Vector2 for the frame position in UV units.
  56860. * @returns TexturePackerFrame
  56861. */
  56862. constructor(id: number, scale: Vector2, offset: Vector2);
  56863. }
  56864. }
  56865. declare module BABYLON {
  56866. /**
  56867. * Defines the basic options interface of a TexturePacker
  56868. */
  56869. export interface ITexturePackerOptions {
  56870. /**
  56871. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  56872. */
  56873. map?: string[];
  56874. /**
  56875. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  56876. */
  56877. uvsIn?: string;
  56878. /**
  56879. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  56880. */
  56881. uvsOut?: string;
  56882. /**
  56883. * number representing the layout style. Defaults to LAYOUT_STRIP
  56884. */
  56885. layout?: number;
  56886. /**
  56887. * number of columns if using custom column count layout(2). This defaults to 4.
  56888. */
  56889. colnum?: number;
  56890. /**
  56891. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  56892. */
  56893. updateInputMeshes?: boolean;
  56894. /**
  56895. * boolean flag to dispose all the source textures. Defaults to true.
  56896. */
  56897. disposeSources?: boolean;
  56898. /**
  56899. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  56900. */
  56901. fillBlanks?: boolean;
  56902. /**
  56903. * string value representing the context fill style color. Defaults to 'black'.
  56904. */
  56905. customFillColor?: string;
  56906. /**
  56907. * Width and Height Value of each Frame in the TexturePacker Sets
  56908. */
  56909. frameSize?: number;
  56910. /**
  56911. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  56912. */
  56913. paddingRatio?: number;
  56914. /**
  56915. * Number that declares the fill method for the padding gutter.
  56916. */
  56917. paddingMode?: number;
  56918. /**
  56919. * If in SUBUV_COLOR padding mode what color to use.
  56920. */
  56921. paddingColor?: Color3 | Color4;
  56922. }
  56923. /**
  56924. * Defines the basic interface of a TexturePacker JSON File
  56925. */
  56926. export interface ITexturePackerJSON {
  56927. /**
  56928. * The frame ID
  56929. */
  56930. name: string;
  56931. /**
  56932. * The base64 channel data
  56933. */
  56934. sets: any;
  56935. /**
  56936. * The options of the Packer
  56937. */
  56938. options: ITexturePackerOptions;
  56939. /**
  56940. * The frame data of the Packer
  56941. */
  56942. frames: Array<number>;
  56943. }
  56944. /**
  56945. * This is a support class that generates a series of packed texture sets.
  56946. * @see https://doc.babylonjs.com/babylon101/materials
  56947. */
  56948. export class TexturePacker {
  56949. /** Packer Layout Constant 0 */
  56950. static readonly LAYOUT_STRIP: number;
  56951. /** Packer Layout Constant 1 */
  56952. static readonly LAYOUT_POWER2: number;
  56953. /** Packer Layout Constant 2 */
  56954. static readonly LAYOUT_COLNUM: number;
  56955. /** Packer Layout Constant 0 */
  56956. static readonly SUBUV_WRAP: number;
  56957. /** Packer Layout Constant 1 */
  56958. static readonly SUBUV_EXTEND: number;
  56959. /** Packer Layout Constant 2 */
  56960. static readonly SUBUV_COLOR: number;
  56961. /** The Name of the Texture Package */
  56962. name: string;
  56963. /** The scene scope of the TexturePacker */
  56964. scene: Scene;
  56965. /** The Meshes to target */
  56966. meshes: AbstractMesh[];
  56967. /** Arguments passed with the Constructor */
  56968. options: ITexturePackerOptions;
  56969. /** The promise that is started upon initialization */
  56970. promise: Nullable<Promise<TexturePacker | string>>;
  56971. /** The Container object for the channel sets that are generated */
  56972. sets: object;
  56973. /** The Container array for the frames that are generated */
  56974. frames: TexturePackerFrame[];
  56975. /** The expected number of textures the system is parsing. */
  56976. private _expecting;
  56977. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  56978. private _paddingValue;
  56979. /**
  56980. * Initializes a texture package series from an array of meshes or a single mesh.
  56981. * @param name The name of the package
  56982. * @param meshes The target meshes to compose the package from
  56983. * @param options The arguments that texture packer should follow while building.
  56984. * @param scene The scene which the textures are scoped to.
  56985. * @returns TexturePacker
  56986. */
  56987. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  56988. /**
  56989. * Starts the package process
  56990. * @param resolve The promises resolution function
  56991. * @returns TexturePacker
  56992. */
  56993. private _createFrames;
  56994. /**
  56995. * Calculates the Size of the Channel Sets
  56996. * @returns Vector2
  56997. */
  56998. private _calculateSize;
  56999. /**
  57000. * Calculates the UV data for the frames.
  57001. * @param baseSize the base frameSize
  57002. * @param padding the base frame padding
  57003. * @param dtSize size of the Dynamic Texture for that channel
  57004. * @param dtUnits is 1/dtSize
  57005. * @param update flag to update the input meshes
  57006. */
  57007. private _calculateMeshUVFrames;
  57008. /**
  57009. * Calculates the frames Offset.
  57010. * @param index of the frame
  57011. * @returns Vector2
  57012. */
  57013. private _getFrameOffset;
  57014. /**
  57015. * Updates a Mesh to the frame data
  57016. * @param mesh that is the target
  57017. * @param frameID or the frame index
  57018. */
  57019. private _updateMeshUV;
  57020. /**
  57021. * Updates a Meshes materials to use the texture packer channels
  57022. * @param m is the mesh to target
  57023. * @param force all channels on the packer to be set.
  57024. */
  57025. private _updateTextureReferences;
  57026. /**
  57027. * Public method to set a Mesh to a frame
  57028. * @param m that is the target
  57029. * @param frameID or the frame index
  57030. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  57031. */
  57032. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  57033. /**
  57034. * Starts the async promise to compile the texture packer.
  57035. * @returns Promise<void>
  57036. */
  57037. processAsync(): Promise<void>;
  57038. /**
  57039. * Disposes all textures associated with this packer
  57040. */
  57041. dispose(): void;
  57042. /**
  57043. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  57044. * @param imageType is the image type to use.
  57045. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  57046. */
  57047. download(imageType?: string, quality?: number): void;
  57048. /**
  57049. * Public method to load a texturePacker JSON file.
  57050. * @param data of the JSON file in string format.
  57051. */
  57052. updateFromJSON(data: string): void;
  57053. }
  57054. }
  57055. declare module BABYLON {
  57056. /**
  57057. * Enum used to define the target of a block
  57058. */
  57059. export enum NodeMaterialBlockTargets {
  57060. /** Vertex shader */
  57061. Vertex = 1,
  57062. /** Fragment shader */
  57063. Fragment = 2,
  57064. /** Neutral */
  57065. Neutral = 4,
  57066. /** Vertex and Fragment */
  57067. VertexAndFragment = 3
  57068. }
  57069. }
  57070. declare module BABYLON {
  57071. /**
  57072. * Defines the kind of connection point for node based material
  57073. */
  57074. export enum NodeMaterialBlockConnectionPointTypes {
  57075. /** Float */
  57076. Float = 1,
  57077. /** Int */
  57078. Int = 2,
  57079. /** Vector2 */
  57080. Vector2 = 4,
  57081. /** Vector3 */
  57082. Vector3 = 8,
  57083. /** Vector4 */
  57084. Vector4 = 16,
  57085. /** Color3 */
  57086. Color3 = 32,
  57087. /** Color4 */
  57088. Color4 = 64,
  57089. /** Matrix */
  57090. Matrix = 128,
  57091. /** Detect type based on connection */
  57092. AutoDetect = 1024,
  57093. /** Output type that will be defined by input type */
  57094. BasedOnInput = 2048
  57095. }
  57096. }
  57097. declare module BABYLON {
  57098. /**
  57099. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  57100. */
  57101. export enum NodeMaterialBlockConnectionPointMode {
  57102. /** Value is an uniform */
  57103. Uniform = 0,
  57104. /** Value is a mesh attribute */
  57105. Attribute = 1,
  57106. /** Value is a varying between vertex and fragment shaders */
  57107. Varying = 2,
  57108. /** Mode is undefined */
  57109. Undefined = 3
  57110. }
  57111. }
  57112. declare module BABYLON {
  57113. /**
  57114. * Enum used to define system values e.g. values automatically provided by the system
  57115. */
  57116. export enum NodeMaterialSystemValues {
  57117. /** World */
  57118. World = 1,
  57119. /** View */
  57120. View = 2,
  57121. /** Projection */
  57122. Projection = 3,
  57123. /** ViewProjection */
  57124. ViewProjection = 4,
  57125. /** WorldView */
  57126. WorldView = 5,
  57127. /** WorldViewProjection */
  57128. WorldViewProjection = 6,
  57129. /** CameraPosition */
  57130. CameraPosition = 7,
  57131. /** Fog Color */
  57132. FogColor = 8,
  57133. /** Delta time */
  57134. DeltaTime = 9
  57135. }
  57136. }
  57137. declare module BABYLON {
  57138. /**
  57139. * Root class for all node material optimizers
  57140. */
  57141. export class NodeMaterialOptimizer {
  57142. /**
  57143. * Function used to optimize a NodeMaterial graph
  57144. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  57145. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  57146. */
  57147. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  57148. }
  57149. }
  57150. declare module BABYLON {
  57151. /**
  57152. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  57153. */
  57154. export class TransformBlock extends NodeMaterialBlock {
  57155. /**
  57156. * Defines the value to use to complement W value to transform it to a Vector4
  57157. */
  57158. complementW: number;
  57159. /**
  57160. * Defines the value to use to complement z value to transform it to a Vector4
  57161. */
  57162. complementZ: number;
  57163. /**
  57164. * Creates a new TransformBlock
  57165. * @param name defines the block name
  57166. */
  57167. constructor(name: string);
  57168. /**
  57169. * Gets the current class name
  57170. * @returns the class name
  57171. */
  57172. getClassName(): string;
  57173. /**
  57174. * Gets the vector input
  57175. */
  57176. get vector(): NodeMaterialConnectionPoint;
  57177. /**
  57178. * Gets the output component
  57179. */
  57180. get output(): NodeMaterialConnectionPoint;
  57181. /**
  57182. * Gets the xyz output component
  57183. */
  57184. get xyz(): NodeMaterialConnectionPoint;
  57185. /**
  57186. * Gets the matrix transform input
  57187. */
  57188. get transform(): NodeMaterialConnectionPoint;
  57189. protected _buildBlock(state: NodeMaterialBuildState): this;
  57190. serialize(): any;
  57191. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57192. protected _dumpPropertiesCode(): string;
  57193. }
  57194. }
  57195. declare module BABYLON {
  57196. /**
  57197. * Block used to output the vertex position
  57198. */
  57199. export class VertexOutputBlock extends NodeMaterialBlock {
  57200. /**
  57201. * Creates a new VertexOutputBlock
  57202. * @param name defines the block name
  57203. */
  57204. constructor(name: string);
  57205. /**
  57206. * Gets the current class name
  57207. * @returns the class name
  57208. */
  57209. getClassName(): string;
  57210. /**
  57211. * Gets the vector input component
  57212. */
  57213. get vector(): NodeMaterialConnectionPoint;
  57214. protected _buildBlock(state: NodeMaterialBuildState): this;
  57215. }
  57216. }
  57217. declare module BABYLON {
  57218. /**
  57219. * Block used to output the final color
  57220. */
  57221. export class FragmentOutputBlock extends NodeMaterialBlock {
  57222. /**
  57223. * Create a new FragmentOutputBlock
  57224. * @param name defines the block name
  57225. */
  57226. constructor(name: string);
  57227. /**
  57228. * Gets the current class name
  57229. * @returns the class name
  57230. */
  57231. getClassName(): string;
  57232. /**
  57233. * Gets the rgba input component
  57234. */
  57235. get rgba(): NodeMaterialConnectionPoint;
  57236. /**
  57237. * Gets the rgb input component
  57238. */
  57239. get rgb(): NodeMaterialConnectionPoint;
  57240. /**
  57241. * Gets the a input component
  57242. */
  57243. get a(): NodeMaterialConnectionPoint;
  57244. protected _buildBlock(state: NodeMaterialBuildState): this;
  57245. }
  57246. }
  57247. declare module BABYLON {
  57248. /**
  57249. * Block used to read a reflection texture from a sampler
  57250. */
  57251. export class ReflectionTextureBlock extends NodeMaterialBlock {
  57252. private _define3DName;
  57253. private _defineCubicName;
  57254. private _defineExplicitName;
  57255. private _defineProjectionName;
  57256. private _defineLocalCubicName;
  57257. private _defineSphericalName;
  57258. private _definePlanarName;
  57259. private _defineEquirectangularName;
  57260. private _defineMirroredEquirectangularFixedName;
  57261. private _defineEquirectangularFixedName;
  57262. private _defineSkyboxName;
  57263. private _cubeSamplerName;
  57264. private _2DSamplerName;
  57265. private _positionUVWName;
  57266. private _directionWName;
  57267. private _reflectionCoordsName;
  57268. private _reflection2DCoordsName;
  57269. private _reflectionColorName;
  57270. private _reflectionMatrixName;
  57271. /**
  57272. * Gets or sets the texture associated with the node
  57273. */
  57274. texture: Nullable<BaseTexture>;
  57275. /**
  57276. * Create a new TextureBlock
  57277. * @param name defines the block name
  57278. */
  57279. constructor(name: string);
  57280. /**
  57281. * Gets the current class name
  57282. * @returns the class name
  57283. */
  57284. getClassName(): string;
  57285. /**
  57286. * Gets the world position input component
  57287. */
  57288. get position(): NodeMaterialConnectionPoint;
  57289. /**
  57290. * Gets the world position input component
  57291. */
  57292. get worldPosition(): NodeMaterialConnectionPoint;
  57293. /**
  57294. * Gets the world normal input component
  57295. */
  57296. get worldNormal(): NodeMaterialConnectionPoint;
  57297. /**
  57298. * Gets the world input component
  57299. */
  57300. get world(): NodeMaterialConnectionPoint;
  57301. /**
  57302. * Gets the camera (or eye) position component
  57303. */
  57304. get cameraPosition(): NodeMaterialConnectionPoint;
  57305. /**
  57306. * Gets the view input component
  57307. */
  57308. get view(): NodeMaterialConnectionPoint;
  57309. /**
  57310. * Gets the rgb output component
  57311. */
  57312. get rgb(): NodeMaterialConnectionPoint;
  57313. /**
  57314. * Gets the r output component
  57315. */
  57316. get r(): NodeMaterialConnectionPoint;
  57317. /**
  57318. * Gets the g output component
  57319. */
  57320. get g(): NodeMaterialConnectionPoint;
  57321. /**
  57322. * Gets the b output component
  57323. */
  57324. get b(): NodeMaterialConnectionPoint;
  57325. autoConfigure(material: NodeMaterial): void;
  57326. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57327. isReady(): boolean;
  57328. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57329. private _injectVertexCode;
  57330. private _writeOutput;
  57331. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57332. protected _dumpPropertiesCode(): string;
  57333. serialize(): any;
  57334. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57335. }
  57336. }
  57337. declare module BABYLON {
  57338. /**
  57339. * Interface used to configure the node material editor
  57340. */
  57341. export interface INodeMaterialEditorOptions {
  57342. /** Define the URl to load node editor script */
  57343. editorURL?: string;
  57344. }
  57345. /** @hidden */
  57346. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  57347. NORMAL: boolean;
  57348. TANGENT: boolean;
  57349. UV1: boolean;
  57350. /** BONES */
  57351. NUM_BONE_INFLUENCERS: number;
  57352. BonesPerMesh: number;
  57353. BONETEXTURE: boolean;
  57354. /** MORPH TARGETS */
  57355. MORPHTARGETS: boolean;
  57356. MORPHTARGETS_NORMAL: boolean;
  57357. MORPHTARGETS_TANGENT: boolean;
  57358. MORPHTARGETS_UV: boolean;
  57359. NUM_MORPH_INFLUENCERS: number;
  57360. /** IMAGE PROCESSING */
  57361. IMAGEPROCESSING: boolean;
  57362. VIGNETTE: boolean;
  57363. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57364. VIGNETTEBLENDMODEOPAQUE: boolean;
  57365. TONEMAPPING: boolean;
  57366. TONEMAPPING_ACES: boolean;
  57367. CONTRAST: boolean;
  57368. EXPOSURE: boolean;
  57369. COLORCURVES: boolean;
  57370. COLORGRADING: boolean;
  57371. COLORGRADING3D: boolean;
  57372. SAMPLER3DGREENDEPTH: boolean;
  57373. SAMPLER3DBGRMAP: boolean;
  57374. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57375. /** MISC. */
  57376. BUMPDIRECTUV: number;
  57377. constructor();
  57378. setValue(name: string, value: boolean): void;
  57379. }
  57380. /**
  57381. * Class used to configure NodeMaterial
  57382. */
  57383. export interface INodeMaterialOptions {
  57384. /**
  57385. * Defines if blocks should emit comments
  57386. */
  57387. emitComments: boolean;
  57388. }
  57389. /**
  57390. * Class used to create a node based material built by assembling shader blocks
  57391. */
  57392. export class NodeMaterial extends PushMaterial {
  57393. private static _BuildIdGenerator;
  57394. private _options;
  57395. private _vertexCompilationState;
  57396. private _fragmentCompilationState;
  57397. private _sharedData;
  57398. private _buildId;
  57399. private _buildWasSuccessful;
  57400. private _cachedWorldViewMatrix;
  57401. private _cachedWorldViewProjectionMatrix;
  57402. private _optimizers;
  57403. private _animationFrame;
  57404. /** Define the Url to load node editor script */
  57405. static EditorURL: string;
  57406. /** Define the Url to load snippets */
  57407. static SnippetUrl: string;
  57408. private BJSNODEMATERIALEDITOR;
  57409. /** Get the inspector from bundle or global */
  57410. private _getGlobalNodeMaterialEditor;
  57411. /**
  57412. * Gets or sets data used by visual editor
  57413. * @see https://nme.babylonjs.com
  57414. */
  57415. editorData: any;
  57416. /**
  57417. * 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)
  57418. */
  57419. ignoreAlpha: boolean;
  57420. /**
  57421. * Defines the maximum number of lights that can be used in the material
  57422. */
  57423. maxSimultaneousLights: number;
  57424. /**
  57425. * Observable raised when the material is built
  57426. */
  57427. onBuildObservable: Observable<NodeMaterial>;
  57428. /**
  57429. * Gets or sets the root nodes of the material vertex shader
  57430. */
  57431. _vertexOutputNodes: NodeMaterialBlock[];
  57432. /**
  57433. * Gets or sets the root nodes of the material fragment (pixel) shader
  57434. */
  57435. _fragmentOutputNodes: NodeMaterialBlock[];
  57436. /** Gets or sets options to control the node material overall behavior */
  57437. get options(): INodeMaterialOptions;
  57438. set options(options: INodeMaterialOptions);
  57439. /**
  57440. * Default configuration related to image processing available in the standard Material.
  57441. */
  57442. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57443. /**
  57444. * Gets the image processing configuration used either in this material.
  57445. */
  57446. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57447. /**
  57448. * Sets the Default image processing configuration used either in the this material.
  57449. *
  57450. * If sets to null, the scene one is in use.
  57451. */
  57452. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57453. /**
  57454. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57455. */
  57456. attachedBlocks: NodeMaterialBlock[];
  57457. /**
  57458. * Create a new node based material
  57459. * @param name defines the material name
  57460. * @param scene defines the hosting scene
  57461. * @param options defines creation option
  57462. */
  57463. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57464. /**
  57465. * Gets the current class name of the material e.g. "NodeMaterial"
  57466. * @returns the class name
  57467. */
  57468. getClassName(): string;
  57469. /**
  57470. * Keep track of the image processing observer to allow dispose and replace.
  57471. */
  57472. private _imageProcessingObserver;
  57473. /**
  57474. * Attaches a new image processing configuration to the Standard Material.
  57475. * @param configuration
  57476. */
  57477. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57478. /**
  57479. * Get a block by its name
  57480. * @param name defines the name of the block to retrieve
  57481. * @returns the required block or null if not found
  57482. */
  57483. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57484. /**
  57485. * Get a block by its name
  57486. * @param predicate defines the predicate used to find the good candidate
  57487. * @returns the required block or null if not found
  57488. */
  57489. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57490. /**
  57491. * Get an input block by its name
  57492. * @param predicate defines the predicate used to find the good candidate
  57493. * @returns the required input block or null if not found
  57494. */
  57495. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57496. /**
  57497. * Gets the list of input blocks attached to this material
  57498. * @returns an array of InputBlocks
  57499. */
  57500. getInputBlocks(): InputBlock[];
  57501. /**
  57502. * Adds a new optimizer to the list of optimizers
  57503. * @param optimizer defines the optimizers to add
  57504. * @returns the current material
  57505. */
  57506. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57507. /**
  57508. * Remove an optimizer from the list of optimizers
  57509. * @param optimizer defines the optimizers to remove
  57510. * @returns the current material
  57511. */
  57512. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57513. /**
  57514. * Add a new block to the list of output nodes
  57515. * @param node defines the node to add
  57516. * @returns the current material
  57517. */
  57518. addOutputNode(node: NodeMaterialBlock): this;
  57519. /**
  57520. * Remove a block from the list of root nodes
  57521. * @param node defines the node to remove
  57522. * @returns the current material
  57523. */
  57524. removeOutputNode(node: NodeMaterialBlock): this;
  57525. private _addVertexOutputNode;
  57526. private _removeVertexOutputNode;
  57527. private _addFragmentOutputNode;
  57528. private _removeFragmentOutputNode;
  57529. /**
  57530. * Specifies if the material will require alpha blending
  57531. * @returns a boolean specifying if alpha blending is needed
  57532. */
  57533. needAlphaBlending(): boolean;
  57534. /**
  57535. * Specifies if this material should be rendered in alpha test mode
  57536. * @returns a boolean specifying if an alpha test is needed.
  57537. */
  57538. needAlphaTesting(): boolean;
  57539. private _initializeBlock;
  57540. private _resetDualBlocks;
  57541. /**
  57542. * Remove a block from the current node material
  57543. * @param block defines the block to remove
  57544. */
  57545. removeBlock(block: NodeMaterialBlock): void;
  57546. /**
  57547. * Build the material and generates the inner effect
  57548. * @param verbose defines if the build should log activity
  57549. */
  57550. build(verbose?: boolean): void;
  57551. /**
  57552. * Runs an otpimization phase to try to improve the shader code
  57553. */
  57554. optimize(): void;
  57555. private _prepareDefinesForAttributes;
  57556. /**
  57557. * Get if the submesh is ready to be used and all its information available.
  57558. * Child classes can use it to update shaders
  57559. * @param mesh defines the mesh to check
  57560. * @param subMesh defines which submesh to check
  57561. * @param useInstances specifies that instances should be used
  57562. * @returns a boolean indicating that the submesh is ready or not
  57563. */
  57564. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57565. /**
  57566. * Get a string representing the shaders built by the current node graph
  57567. */
  57568. get compiledShaders(): string;
  57569. /**
  57570. * Binds the world matrix to the material
  57571. * @param world defines the world transformation matrix
  57572. */
  57573. bindOnlyWorldMatrix(world: Matrix): void;
  57574. /**
  57575. * Binds the submesh to this material by preparing the effect and shader to draw
  57576. * @param world defines the world transformation matrix
  57577. * @param mesh defines the mesh containing the submesh
  57578. * @param subMesh defines the submesh to bind the material to
  57579. */
  57580. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57581. /**
  57582. * Gets the active textures from the material
  57583. * @returns an array of textures
  57584. */
  57585. getActiveTextures(): BaseTexture[];
  57586. /**
  57587. * Gets the list of texture blocks
  57588. * @returns an array of texture blocks
  57589. */
  57590. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  57591. /**
  57592. * Specifies if the material uses a texture
  57593. * @param texture defines the texture to check against the material
  57594. * @returns a boolean specifying if the material uses the texture
  57595. */
  57596. hasTexture(texture: BaseTexture): boolean;
  57597. /**
  57598. * Disposes the material
  57599. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  57600. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  57601. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  57602. */
  57603. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  57604. /** Creates the node editor window. */
  57605. private _createNodeEditor;
  57606. /**
  57607. * Launch the node material editor
  57608. * @param config Define the configuration of the editor
  57609. * @return a promise fulfilled when the node editor is visible
  57610. */
  57611. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  57612. /**
  57613. * Clear the current material
  57614. */
  57615. clear(): void;
  57616. /**
  57617. * Clear the current material and set it to a default state
  57618. */
  57619. setToDefault(): void;
  57620. /**
  57621. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  57622. * @param url defines the url to load from
  57623. * @returns a promise that will fullfil when the material is fully loaded
  57624. */
  57625. loadAsync(url: string): Promise<void>;
  57626. private _gatherBlocks;
  57627. /**
  57628. * Generate a string containing the code declaration required to create an equivalent of this material
  57629. * @returns a string
  57630. */
  57631. generateCode(): string;
  57632. /**
  57633. * Serializes this material in a JSON representation
  57634. * @returns the serialized material object
  57635. */
  57636. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  57637. private _restoreConnections;
  57638. /**
  57639. * Clear the current graph and load a new one from a serialization object
  57640. * @param source defines the JSON representation of the material
  57641. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57642. */
  57643. loadFromSerialization(source: any, rootUrl?: string): void;
  57644. /**
  57645. * Makes a duplicate of the current material.
  57646. * @param name - name to use for the new material.
  57647. */
  57648. clone(name: string): NodeMaterial;
  57649. /**
  57650. * Creates a node material from parsed material data
  57651. * @param source defines the JSON representation of the material
  57652. * @param scene defines the hosting scene
  57653. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57654. * @returns a new node material
  57655. */
  57656. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  57657. /**
  57658. * Creates a node material from a snippet saved in a remote file
  57659. * @param name defines the name of the material to create
  57660. * @param url defines the url to load from
  57661. * @param scene defines the hosting scene
  57662. * @returns a promise that will resolve to the new node material
  57663. */
  57664. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  57665. /**
  57666. * Creates a node material from a snippet saved by the node material editor
  57667. * @param snippetId defines the snippet to load
  57668. * @param scene defines the hosting scene
  57669. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57670. * @returns a promise that will resolve to the new node material
  57671. */
  57672. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  57673. /**
  57674. * Creates a new node material set to default basic configuration
  57675. * @param name defines the name of the material
  57676. * @param scene defines the hosting scene
  57677. * @returns a new NodeMaterial
  57678. */
  57679. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  57680. }
  57681. }
  57682. declare module BABYLON {
  57683. /**
  57684. * Block used to read a texture from a sampler
  57685. */
  57686. export class TextureBlock extends NodeMaterialBlock {
  57687. private _defineName;
  57688. private _linearDefineName;
  57689. private _tempTextureRead;
  57690. private _samplerName;
  57691. private _transformedUVName;
  57692. private _textureTransformName;
  57693. private _textureInfoName;
  57694. private _mainUVName;
  57695. private _mainUVDefineName;
  57696. /**
  57697. * Gets or sets the texture associated with the node
  57698. */
  57699. texture: Nullable<Texture>;
  57700. /**
  57701. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  57702. */
  57703. convertToGammaSpace: boolean;
  57704. /**
  57705. * Create a new TextureBlock
  57706. * @param name defines the block name
  57707. */
  57708. constructor(name: string);
  57709. /**
  57710. * Gets the current class name
  57711. * @returns the class name
  57712. */
  57713. getClassName(): string;
  57714. /**
  57715. * Gets the uv input component
  57716. */
  57717. get uv(): NodeMaterialConnectionPoint;
  57718. /**
  57719. * Gets the rgba output component
  57720. */
  57721. get rgba(): NodeMaterialConnectionPoint;
  57722. /**
  57723. * Gets the rgb output component
  57724. */
  57725. get rgb(): NodeMaterialConnectionPoint;
  57726. /**
  57727. * Gets the r output component
  57728. */
  57729. get r(): NodeMaterialConnectionPoint;
  57730. /**
  57731. * Gets the g output component
  57732. */
  57733. get g(): NodeMaterialConnectionPoint;
  57734. /**
  57735. * Gets the b output component
  57736. */
  57737. get b(): NodeMaterialConnectionPoint;
  57738. /**
  57739. * Gets the a output component
  57740. */
  57741. get a(): NodeMaterialConnectionPoint;
  57742. get target(): NodeMaterialBlockTargets;
  57743. autoConfigure(material: NodeMaterial): void;
  57744. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57745. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57746. isReady(): boolean;
  57747. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57748. private get _isMixed();
  57749. private _injectVertexCode;
  57750. private _writeTextureRead;
  57751. private _writeOutput;
  57752. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57753. protected _dumpPropertiesCode(): string;
  57754. serialize(): any;
  57755. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57756. }
  57757. }
  57758. declare module BABYLON {
  57759. /**
  57760. * Class used to store shared data between 2 NodeMaterialBuildState
  57761. */
  57762. export class NodeMaterialBuildStateSharedData {
  57763. /**
  57764. * Gets the list of emitted varyings
  57765. */
  57766. temps: string[];
  57767. /**
  57768. * Gets the list of emitted varyings
  57769. */
  57770. varyings: string[];
  57771. /**
  57772. * Gets the varying declaration string
  57773. */
  57774. varyingDeclaration: string;
  57775. /**
  57776. * Input blocks
  57777. */
  57778. inputBlocks: InputBlock[];
  57779. /**
  57780. * Input blocks
  57781. */
  57782. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  57783. /**
  57784. * Bindable blocks (Blocks that need to set data to the effect)
  57785. */
  57786. bindableBlocks: NodeMaterialBlock[];
  57787. /**
  57788. * List of blocks that can provide a compilation fallback
  57789. */
  57790. blocksWithFallbacks: NodeMaterialBlock[];
  57791. /**
  57792. * List of blocks that can provide a define update
  57793. */
  57794. blocksWithDefines: NodeMaterialBlock[];
  57795. /**
  57796. * List of blocks that can provide a repeatable content
  57797. */
  57798. repeatableContentBlocks: NodeMaterialBlock[];
  57799. /**
  57800. * List of blocks that can provide a dynamic list of uniforms
  57801. */
  57802. dynamicUniformBlocks: NodeMaterialBlock[];
  57803. /**
  57804. * List of blocks that can block the isReady function for the material
  57805. */
  57806. blockingBlocks: NodeMaterialBlock[];
  57807. /**
  57808. * Gets the list of animated inputs
  57809. */
  57810. animatedInputs: InputBlock[];
  57811. /**
  57812. * Build Id used to avoid multiple recompilations
  57813. */
  57814. buildId: number;
  57815. /** List of emitted variables */
  57816. variableNames: {
  57817. [key: string]: number;
  57818. };
  57819. /** List of emitted defines */
  57820. defineNames: {
  57821. [key: string]: number;
  57822. };
  57823. /** Should emit comments? */
  57824. emitComments: boolean;
  57825. /** Emit build activity */
  57826. verbose: boolean;
  57827. /** Gets or sets the hosting scene */
  57828. scene: Scene;
  57829. /**
  57830. * Gets the compilation hints emitted at compilation time
  57831. */
  57832. hints: {
  57833. needWorldViewMatrix: boolean;
  57834. needWorldViewProjectionMatrix: boolean;
  57835. needAlphaBlending: boolean;
  57836. needAlphaTesting: boolean;
  57837. };
  57838. /**
  57839. * List of compilation checks
  57840. */
  57841. checks: {
  57842. emitVertex: boolean;
  57843. emitFragment: boolean;
  57844. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  57845. };
  57846. /** Creates a new shared data */
  57847. constructor();
  57848. /**
  57849. * Emits console errors and exceptions if there is a failing check
  57850. */
  57851. emitErrors(): void;
  57852. }
  57853. }
  57854. declare module BABYLON {
  57855. /**
  57856. * Class used to store node based material build state
  57857. */
  57858. export class NodeMaterialBuildState {
  57859. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  57860. supportUniformBuffers: boolean;
  57861. /**
  57862. * Gets the list of emitted attributes
  57863. */
  57864. attributes: string[];
  57865. /**
  57866. * Gets the list of emitted uniforms
  57867. */
  57868. uniforms: string[];
  57869. /**
  57870. * Gets the list of emitted constants
  57871. */
  57872. constants: string[];
  57873. /**
  57874. * Gets the list of emitted samplers
  57875. */
  57876. samplers: string[];
  57877. /**
  57878. * Gets the list of emitted functions
  57879. */
  57880. functions: {
  57881. [key: string]: string;
  57882. };
  57883. /**
  57884. * Gets the list of emitted extensions
  57885. */
  57886. extensions: {
  57887. [key: string]: string;
  57888. };
  57889. /**
  57890. * Gets the target of the compilation state
  57891. */
  57892. target: NodeMaterialBlockTargets;
  57893. /**
  57894. * Gets the list of emitted counters
  57895. */
  57896. counters: {
  57897. [key: string]: number;
  57898. };
  57899. /**
  57900. * Shared data between multiple NodeMaterialBuildState instances
  57901. */
  57902. sharedData: NodeMaterialBuildStateSharedData;
  57903. /** @hidden */
  57904. _vertexState: NodeMaterialBuildState;
  57905. /** @hidden */
  57906. _attributeDeclaration: string;
  57907. /** @hidden */
  57908. _uniformDeclaration: string;
  57909. /** @hidden */
  57910. _constantDeclaration: string;
  57911. /** @hidden */
  57912. _samplerDeclaration: string;
  57913. /** @hidden */
  57914. _varyingTransfer: string;
  57915. private _repeatableContentAnchorIndex;
  57916. /** @hidden */
  57917. _builtCompilationString: string;
  57918. /**
  57919. * Gets the emitted compilation strings
  57920. */
  57921. compilationString: string;
  57922. /**
  57923. * Finalize the compilation strings
  57924. * @param state defines the current compilation state
  57925. */
  57926. finalize(state: NodeMaterialBuildState): void;
  57927. /** @hidden */
  57928. get _repeatableContentAnchor(): string;
  57929. /** @hidden */
  57930. _getFreeVariableName(prefix: string): string;
  57931. /** @hidden */
  57932. _getFreeDefineName(prefix: string): string;
  57933. /** @hidden */
  57934. _excludeVariableName(name: string): void;
  57935. /** @hidden */
  57936. _emit2DSampler(name: string): void;
  57937. /** @hidden */
  57938. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  57939. /** @hidden */
  57940. _emitExtension(name: string, extension: string): void;
  57941. /** @hidden */
  57942. _emitFunction(name: string, code: string, comments: string): void;
  57943. /** @hidden */
  57944. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  57945. replaceStrings?: {
  57946. search: RegExp;
  57947. replace: string;
  57948. }[];
  57949. repeatKey?: string;
  57950. }): string;
  57951. /** @hidden */
  57952. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  57953. repeatKey?: string;
  57954. removeAttributes?: boolean;
  57955. removeUniforms?: boolean;
  57956. removeVaryings?: boolean;
  57957. removeIfDef?: boolean;
  57958. replaceStrings?: {
  57959. search: RegExp;
  57960. replace: string;
  57961. }[];
  57962. }, storeKey?: string): void;
  57963. /** @hidden */
  57964. _registerTempVariable(name: string): boolean;
  57965. /** @hidden */
  57966. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  57967. /** @hidden */
  57968. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  57969. /** @hidden */
  57970. _emitFloat(value: number): string;
  57971. }
  57972. }
  57973. declare module BABYLON {
  57974. /**
  57975. * Defines a block that can be used inside a node based material
  57976. */
  57977. export class NodeMaterialBlock {
  57978. private _buildId;
  57979. private _buildTarget;
  57980. private _target;
  57981. private _isFinalMerger;
  57982. private _isInput;
  57983. protected _isUnique: boolean;
  57984. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  57985. inputsAreExclusive: boolean;
  57986. /** @hidden */
  57987. _codeVariableName: string;
  57988. /** @hidden */
  57989. _inputs: NodeMaterialConnectionPoint[];
  57990. /** @hidden */
  57991. _outputs: NodeMaterialConnectionPoint[];
  57992. /** @hidden */
  57993. _preparationId: number;
  57994. /**
  57995. * Gets or sets the name of the block
  57996. */
  57997. name: string;
  57998. /**
  57999. * Gets or sets the unique id of the node
  58000. */
  58001. uniqueId: number;
  58002. /**
  58003. * Gets or sets the comments associated with this block
  58004. */
  58005. comments: string;
  58006. /**
  58007. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  58008. */
  58009. get isUnique(): boolean;
  58010. /**
  58011. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  58012. */
  58013. get isFinalMerger(): boolean;
  58014. /**
  58015. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  58016. */
  58017. get isInput(): boolean;
  58018. /**
  58019. * Gets or sets the build Id
  58020. */
  58021. get buildId(): number;
  58022. set buildId(value: number);
  58023. /**
  58024. * Gets or sets the target of the block
  58025. */
  58026. get target(): NodeMaterialBlockTargets;
  58027. set target(value: NodeMaterialBlockTargets);
  58028. /**
  58029. * Gets the list of input points
  58030. */
  58031. get inputs(): NodeMaterialConnectionPoint[];
  58032. /** Gets the list of output points */
  58033. get outputs(): NodeMaterialConnectionPoint[];
  58034. /**
  58035. * Find an input by its name
  58036. * @param name defines the name of the input to look for
  58037. * @returns the input or null if not found
  58038. */
  58039. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58040. /**
  58041. * Find an output by its name
  58042. * @param name defines the name of the outputto look for
  58043. * @returns the output or null if not found
  58044. */
  58045. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58046. /**
  58047. * Creates a new NodeMaterialBlock
  58048. * @param name defines the block name
  58049. * @param target defines the target of that block (Vertex by default)
  58050. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  58051. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  58052. */
  58053. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  58054. /**
  58055. * Initialize the block and prepare the context for build
  58056. * @param state defines the state that will be used for the build
  58057. */
  58058. initialize(state: NodeMaterialBuildState): void;
  58059. /**
  58060. * Bind data to effect. Will only be called for blocks with isBindable === true
  58061. * @param effect defines the effect to bind data to
  58062. * @param nodeMaterial defines the hosting NodeMaterial
  58063. * @param mesh defines the mesh that will be rendered
  58064. */
  58065. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58066. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  58067. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  58068. protected _writeFloat(value: number): string;
  58069. /**
  58070. * Gets the current class name e.g. "NodeMaterialBlock"
  58071. * @returns the class name
  58072. */
  58073. getClassName(): string;
  58074. /**
  58075. * Register a new input. Must be called inside a block constructor
  58076. * @param name defines the connection point name
  58077. * @param type defines the connection point type
  58078. * @param isOptional defines a boolean indicating that this input can be omitted
  58079. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58080. * @returns the current block
  58081. */
  58082. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  58083. /**
  58084. * Register a new output. Must be called inside a block constructor
  58085. * @param name defines the connection point name
  58086. * @param type defines the connection point type
  58087. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58088. * @returns the current block
  58089. */
  58090. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  58091. /**
  58092. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  58093. * @param forOutput defines an optional connection point to check compatibility with
  58094. * @returns the first available input or null
  58095. */
  58096. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  58097. /**
  58098. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  58099. * @param forBlock defines an optional block to check compatibility with
  58100. * @returns the first available input or null
  58101. */
  58102. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  58103. /**
  58104. * Gets the sibling of the given output
  58105. * @param current defines the current output
  58106. * @returns the next output in the list or null
  58107. */
  58108. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  58109. /**
  58110. * Connect current block with another block
  58111. * @param other defines the block to connect with
  58112. * @param options define the various options to help pick the right connections
  58113. * @returns the current block
  58114. */
  58115. connectTo(other: NodeMaterialBlock, options?: {
  58116. input?: string;
  58117. output?: string;
  58118. outputSwizzle?: string;
  58119. }): this | undefined;
  58120. protected _buildBlock(state: NodeMaterialBuildState): void;
  58121. /**
  58122. * Add uniforms, samplers and uniform buffers at compilation time
  58123. * @param state defines the state to update
  58124. * @param nodeMaterial defines the node material requesting the update
  58125. * @param defines defines the material defines to update
  58126. * @param uniformBuffers defines the list of uniform buffer names
  58127. */
  58128. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58129. /**
  58130. * Add potential fallbacks if shader compilation fails
  58131. * @param mesh defines the mesh to be rendered
  58132. * @param fallbacks defines the current prioritized list of fallbacks
  58133. */
  58134. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58135. /**
  58136. * Initialize defines for shader compilation
  58137. * @param mesh defines the mesh to be rendered
  58138. * @param nodeMaterial defines the node material requesting the update
  58139. * @param defines defines the material defines to update
  58140. * @param useInstances specifies that instances should be used
  58141. */
  58142. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58143. /**
  58144. * Update defines for shader compilation
  58145. * @param mesh defines the mesh to be rendered
  58146. * @param nodeMaterial defines the node material requesting the update
  58147. * @param defines defines the material defines to update
  58148. * @param useInstances specifies that instances should be used
  58149. */
  58150. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58151. /**
  58152. * Lets the block try to connect some inputs automatically
  58153. * @param material defines the hosting NodeMaterial
  58154. */
  58155. autoConfigure(material: NodeMaterial): void;
  58156. /**
  58157. * Function called when a block is declared as repeatable content generator
  58158. * @param vertexShaderState defines the current compilation state for the vertex shader
  58159. * @param fragmentShaderState defines the current compilation state for the fragment shader
  58160. * @param mesh defines the mesh to be rendered
  58161. * @param defines defines the material defines to update
  58162. */
  58163. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58164. /**
  58165. * Checks if the block is ready
  58166. * @param mesh defines the mesh to be rendered
  58167. * @param nodeMaterial defines the node material requesting the update
  58168. * @param defines defines the material defines to update
  58169. * @param useInstances specifies that instances should be used
  58170. * @returns true if the block is ready
  58171. */
  58172. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  58173. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  58174. private _processBuild;
  58175. /**
  58176. * Compile the current node and generate the shader code
  58177. * @param state defines the current compilation state (uniforms, samplers, current string)
  58178. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  58179. * @returns true if already built
  58180. */
  58181. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  58182. protected _inputRename(name: string): string;
  58183. protected _outputRename(name: string): string;
  58184. protected _dumpPropertiesCode(): string;
  58185. /** @hidden */
  58186. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  58187. /** @hidden */
  58188. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  58189. /**
  58190. * Clone the current block to a new identical block
  58191. * @param scene defines the hosting scene
  58192. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58193. * @returns a copy of the current block
  58194. */
  58195. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  58196. /**
  58197. * Serializes this block in a JSON representation
  58198. * @returns the serialized block object
  58199. */
  58200. serialize(): any;
  58201. /** @hidden */
  58202. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58203. /**
  58204. * Release resources
  58205. */
  58206. dispose(): void;
  58207. }
  58208. }
  58209. declare module BABYLON {
  58210. /**
  58211. * Enum defining the type of animations supported by InputBlock
  58212. */
  58213. export enum AnimatedInputBlockTypes {
  58214. /** No animation */
  58215. None = 0,
  58216. /** Time based animation. Will only work for floats */
  58217. Time = 1
  58218. }
  58219. }
  58220. declare module BABYLON {
  58221. /**
  58222. * Block used to expose an input value
  58223. */
  58224. export class InputBlock extends NodeMaterialBlock {
  58225. private _mode;
  58226. private _associatedVariableName;
  58227. private _storedValue;
  58228. private _valueCallback;
  58229. private _type;
  58230. private _animationType;
  58231. /** Gets or set a value used to limit the range of float values */
  58232. min: number;
  58233. /** Gets or set a value used to limit the range of float values */
  58234. max: number;
  58235. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  58236. isBoolean: boolean;
  58237. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  58238. matrixMode: number;
  58239. /** @hidden */
  58240. _systemValue: Nullable<NodeMaterialSystemValues>;
  58241. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  58242. visibleInInspector: boolean;
  58243. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  58244. isConstant: boolean;
  58245. /** Gets or sets the group to use to display this block in the Inspector */
  58246. groupInInspector: string;
  58247. /** Gets an observable raised when the value is changed */
  58248. onValueChangedObservable: Observable<InputBlock>;
  58249. /**
  58250. * Gets or sets the connection point type (default is float)
  58251. */
  58252. get type(): NodeMaterialBlockConnectionPointTypes;
  58253. /**
  58254. * Creates a new InputBlock
  58255. * @param name defines the block name
  58256. * @param target defines the target of that block (Vertex by default)
  58257. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  58258. */
  58259. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  58260. /**
  58261. * Gets the output component
  58262. */
  58263. get output(): NodeMaterialConnectionPoint;
  58264. /**
  58265. * Set the source of this connection point to a vertex attribute
  58266. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  58267. * @returns the current connection point
  58268. */
  58269. setAsAttribute(attributeName?: string): InputBlock;
  58270. /**
  58271. * Set the source of this connection point to a system value
  58272. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  58273. * @returns the current connection point
  58274. */
  58275. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  58276. /**
  58277. * Gets or sets the value of that point.
  58278. * Please note that this value will be ignored if valueCallback is defined
  58279. */
  58280. get value(): any;
  58281. set value(value: any);
  58282. /**
  58283. * Gets or sets a callback used to get the value of that point.
  58284. * Please note that setting this value will force the connection point to ignore the value property
  58285. */
  58286. get valueCallback(): () => any;
  58287. set valueCallback(value: () => any);
  58288. /**
  58289. * Gets or sets the associated variable name in the shader
  58290. */
  58291. get associatedVariableName(): string;
  58292. set associatedVariableName(value: string);
  58293. /** Gets or sets the type of animation applied to the input */
  58294. get animationType(): AnimatedInputBlockTypes;
  58295. set animationType(value: AnimatedInputBlockTypes);
  58296. /**
  58297. * Gets a boolean indicating that this connection point not defined yet
  58298. */
  58299. get isUndefined(): boolean;
  58300. /**
  58301. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  58302. * In this case the connection point name must be the name of the uniform to use.
  58303. * Can only be set on inputs
  58304. */
  58305. get isUniform(): boolean;
  58306. set isUniform(value: boolean);
  58307. /**
  58308. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  58309. * In this case the connection point name must be the name of the attribute to use
  58310. * Can only be set on inputs
  58311. */
  58312. get isAttribute(): boolean;
  58313. set isAttribute(value: boolean);
  58314. /**
  58315. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  58316. * Can only be set on exit points
  58317. */
  58318. get isVarying(): boolean;
  58319. set isVarying(value: boolean);
  58320. /**
  58321. * Gets a boolean indicating that the current connection point is a system value
  58322. */
  58323. get isSystemValue(): boolean;
  58324. /**
  58325. * Gets or sets the current well known value or null if not defined as a system value
  58326. */
  58327. get systemValue(): Nullable<NodeMaterialSystemValues>;
  58328. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  58329. /**
  58330. * Gets the current class name
  58331. * @returns the class name
  58332. */
  58333. getClassName(): string;
  58334. /**
  58335. * Animate the input if animationType !== None
  58336. * @param scene defines the rendering scene
  58337. */
  58338. animate(scene: Scene): void;
  58339. private _emitDefine;
  58340. initialize(state: NodeMaterialBuildState): void;
  58341. /**
  58342. * Set the input block to its default value (based on its type)
  58343. */
  58344. setDefaultValue(): void;
  58345. private _emitConstant;
  58346. private _emit;
  58347. /** @hidden */
  58348. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  58349. /** @hidden */
  58350. _transmit(effect: Effect, scene: Scene): void;
  58351. protected _buildBlock(state: NodeMaterialBuildState): void;
  58352. protected _dumpPropertiesCode(): string;
  58353. dispose(): void;
  58354. serialize(): any;
  58355. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58356. }
  58357. }
  58358. declare module BABYLON {
  58359. /**
  58360. * Enum used to define the compatibility state between two connection points
  58361. */
  58362. export enum NodeMaterialConnectionPointCompatibilityStates {
  58363. /** Points are compatibles */
  58364. Compatible = 0,
  58365. /** Points are incompatible because of their types */
  58366. TypeIncompatible = 1,
  58367. /** Points are incompatible because of their targets (vertex vs fragment) */
  58368. TargetIncompatible = 2
  58369. }
  58370. /**
  58371. * Defines the direction of a connection point
  58372. */
  58373. export enum NodeMaterialConnectionPointDirection {
  58374. /** Input */
  58375. Input = 0,
  58376. /** Output */
  58377. Output = 1
  58378. }
  58379. /**
  58380. * Defines a connection point for a block
  58381. */
  58382. export class NodeMaterialConnectionPoint {
  58383. /** @hidden */
  58384. _ownerBlock: NodeMaterialBlock;
  58385. /** @hidden */
  58386. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  58387. private _endpoints;
  58388. private _associatedVariableName;
  58389. private _direction;
  58390. /** @hidden */
  58391. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58392. /** @hidden */
  58393. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58394. private _type;
  58395. /** @hidden */
  58396. _enforceAssociatedVariableName: boolean;
  58397. /** Gets the direction of the point */
  58398. get direction(): NodeMaterialConnectionPointDirection;
  58399. /**
  58400. * Gets or sets the additional types supported by this connection point
  58401. */
  58402. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58403. /**
  58404. * Gets or sets the additional types excluded by this connection point
  58405. */
  58406. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58407. /**
  58408. * Observable triggered when this point is connected
  58409. */
  58410. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58411. /**
  58412. * Gets or sets the associated variable name in the shader
  58413. */
  58414. get associatedVariableName(): string;
  58415. set associatedVariableName(value: string);
  58416. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  58417. get innerType(): NodeMaterialBlockConnectionPointTypes;
  58418. /**
  58419. * Gets or sets the connection point type (default is float)
  58420. */
  58421. get type(): NodeMaterialBlockConnectionPointTypes;
  58422. set type(value: NodeMaterialBlockConnectionPointTypes);
  58423. /**
  58424. * Gets or sets the connection point name
  58425. */
  58426. name: string;
  58427. /**
  58428. * Gets or sets a boolean indicating that this connection point can be omitted
  58429. */
  58430. isOptional: boolean;
  58431. /**
  58432. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58433. */
  58434. define: string;
  58435. /** @hidden */
  58436. _prioritizeVertex: boolean;
  58437. private _target;
  58438. /** Gets or sets the target of that connection point */
  58439. get target(): NodeMaterialBlockTargets;
  58440. set target(value: NodeMaterialBlockTargets);
  58441. /**
  58442. * Gets a boolean indicating that the current point is connected
  58443. */
  58444. get isConnected(): boolean;
  58445. /**
  58446. * Gets a boolean indicating that the current point is connected to an input block
  58447. */
  58448. get isConnectedToInputBlock(): boolean;
  58449. /**
  58450. * Gets a the connected input block (if any)
  58451. */
  58452. get connectInputBlock(): Nullable<InputBlock>;
  58453. /** Get the other side of the connection (if any) */
  58454. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58455. /** Get the block that owns this connection point */
  58456. get ownerBlock(): NodeMaterialBlock;
  58457. /** Get the block connected on the other side of this connection (if any) */
  58458. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58459. /** Get the block connected on the endpoints of this connection (if any) */
  58460. get connectedBlocks(): Array<NodeMaterialBlock>;
  58461. /** Gets the list of connected endpoints */
  58462. get endpoints(): NodeMaterialConnectionPoint[];
  58463. /** Gets a boolean indicating if that output point is connected to at least one input */
  58464. get hasEndpoints(): boolean;
  58465. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58466. get isConnectedInVertexShader(): boolean;
  58467. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58468. get isConnectedInFragmentShader(): boolean;
  58469. /**
  58470. * Creates a new connection point
  58471. * @param name defines the connection point name
  58472. * @param ownerBlock defines the block hosting this connection point
  58473. * @param direction defines the direction of the connection point
  58474. */
  58475. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58476. /**
  58477. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58478. * @returns the class name
  58479. */
  58480. getClassName(): string;
  58481. /**
  58482. * Gets a boolean indicating if the current point can be connected to another point
  58483. * @param connectionPoint defines the other connection point
  58484. * @returns a boolean
  58485. */
  58486. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58487. /**
  58488. * Gets a number indicating if the current point can be connected to another point
  58489. * @param connectionPoint defines the other connection point
  58490. * @returns a number defining the compatibility state
  58491. */
  58492. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58493. /**
  58494. * Connect this point to another connection point
  58495. * @param connectionPoint defines the other connection point
  58496. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58497. * @returns the current connection point
  58498. */
  58499. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58500. /**
  58501. * Disconnect this point from one of his endpoint
  58502. * @param endpoint defines the other connection point
  58503. * @returns the current connection point
  58504. */
  58505. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58506. /**
  58507. * Serializes this point in a JSON representation
  58508. * @returns the serialized point object
  58509. */
  58510. serialize(): any;
  58511. /**
  58512. * Release resources
  58513. */
  58514. dispose(): void;
  58515. }
  58516. }
  58517. declare module BABYLON {
  58518. /**
  58519. * Block used to add support for vertex skinning (bones)
  58520. */
  58521. export class BonesBlock extends NodeMaterialBlock {
  58522. /**
  58523. * Creates a new BonesBlock
  58524. * @param name defines the block name
  58525. */
  58526. constructor(name: string);
  58527. /**
  58528. * Initialize the block and prepare the context for build
  58529. * @param state defines the state that will be used for the build
  58530. */
  58531. initialize(state: NodeMaterialBuildState): void;
  58532. /**
  58533. * Gets the current class name
  58534. * @returns the class name
  58535. */
  58536. getClassName(): string;
  58537. /**
  58538. * Gets the matrix indices input component
  58539. */
  58540. get matricesIndices(): NodeMaterialConnectionPoint;
  58541. /**
  58542. * Gets the matrix weights input component
  58543. */
  58544. get matricesWeights(): NodeMaterialConnectionPoint;
  58545. /**
  58546. * Gets the extra matrix indices input component
  58547. */
  58548. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  58549. /**
  58550. * Gets the extra matrix weights input component
  58551. */
  58552. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  58553. /**
  58554. * Gets the world input component
  58555. */
  58556. get world(): NodeMaterialConnectionPoint;
  58557. /**
  58558. * Gets the output component
  58559. */
  58560. get output(): NodeMaterialConnectionPoint;
  58561. autoConfigure(material: NodeMaterial): void;
  58562. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58563. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58564. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58565. protected _buildBlock(state: NodeMaterialBuildState): this;
  58566. }
  58567. }
  58568. declare module BABYLON {
  58569. /**
  58570. * Block used to add support for instances
  58571. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  58572. */
  58573. export class InstancesBlock extends NodeMaterialBlock {
  58574. /**
  58575. * Creates a new InstancesBlock
  58576. * @param name defines the block name
  58577. */
  58578. constructor(name: string);
  58579. /**
  58580. * Gets the current class name
  58581. * @returns the class name
  58582. */
  58583. getClassName(): string;
  58584. /**
  58585. * Gets the first world row input component
  58586. */
  58587. get world0(): NodeMaterialConnectionPoint;
  58588. /**
  58589. * Gets the second world row input component
  58590. */
  58591. get world1(): NodeMaterialConnectionPoint;
  58592. /**
  58593. * Gets the third world row input component
  58594. */
  58595. get world2(): NodeMaterialConnectionPoint;
  58596. /**
  58597. * Gets the forth world row input component
  58598. */
  58599. get world3(): NodeMaterialConnectionPoint;
  58600. /**
  58601. * Gets the world input component
  58602. */
  58603. get world(): NodeMaterialConnectionPoint;
  58604. /**
  58605. * Gets the output component
  58606. */
  58607. get output(): NodeMaterialConnectionPoint;
  58608. /**
  58609. * Gets the isntanceID component
  58610. */
  58611. get instanceID(): NodeMaterialConnectionPoint;
  58612. autoConfigure(material: NodeMaterial): void;
  58613. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58614. protected _buildBlock(state: NodeMaterialBuildState): this;
  58615. }
  58616. }
  58617. declare module BABYLON {
  58618. /**
  58619. * Block used to add morph targets support to vertex shader
  58620. */
  58621. export class MorphTargetsBlock extends NodeMaterialBlock {
  58622. private _repeatableContentAnchor;
  58623. /**
  58624. * Create a new MorphTargetsBlock
  58625. * @param name defines the block name
  58626. */
  58627. constructor(name: string);
  58628. /**
  58629. * Gets the current class name
  58630. * @returns the class name
  58631. */
  58632. getClassName(): string;
  58633. /**
  58634. * Gets the position input component
  58635. */
  58636. get position(): NodeMaterialConnectionPoint;
  58637. /**
  58638. * Gets the normal input component
  58639. */
  58640. get normal(): NodeMaterialConnectionPoint;
  58641. /**
  58642. * Gets the tangent input component
  58643. */
  58644. get tangent(): NodeMaterialConnectionPoint;
  58645. /**
  58646. * Gets the tangent input component
  58647. */
  58648. get uv(): NodeMaterialConnectionPoint;
  58649. /**
  58650. * Gets the position output component
  58651. */
  58652. get positionOutput(): NodeMaterialConnectionPoint;
  58653. /**
  58654. * Gets the normal output component
  58655. */
  58656. get normalOutput(): NodeMaterialConnectionPoint;
  58657. /**
  58658. * Gets the tangent output component
  58659. */
  58660. get tangentOutput(): NodeMaterialConnectionPoint;
  58661. /**
  58662. * Gets the tangent output component
  58663. */
  58664. get uvOutput(): NodeMaterialConnectionPoint;
  58665. initialize(state: NodeMaterialBuildState): void;
  58666. autoConfigure(material: NodeMaterial): void;
  58667. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58668. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58669. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58670. protected _buildBlock(state: NodeMaterialBuildState): this;
  58671. }
  58672. }
  58673. declare module BABYLON {
  58674. /**
  58675. * Block used to get data information from a light
  58676. */
  58677. export class LightInformationBlock extends NodeMaterialBlock {
  58678. private _lightDataUniformName;
  58679. private _lightColorUniformName;
  58680. private _lightTypeDefineName;
  58681. /**
  58682. * Gets or sets the light associated with this block
  58683. */
  58684. light: Nullable<Light>;
  58685. /**
  58686. * Creates a new LightInformationBlock
  58687. * @param name defines the block name
  58688. */
  58689. constructor(name: string);
  58690. /**
  58691. * Gets the current class name
  58692. * @returns the class name
  58693. */
  58694. getClassName(): string;
  58695. /**
  58696. * Gets the world position input component
  58697. */
  58698. get worldPosition(): NodeMaterialConnectionPoint;
  58699. /**
  58700. * Gets the direction output component
  58701. */
  58702. get direction(): NodeMaterialConnectionPoint;
  58703. /**
  58704. * Gets the direction output component
  58705. */
  58706. get color(): NodeMaterialConnectionPoint;
  58707. /**
  58708. * Gets the direction output component
  58709. */
  58710. get intensity(): NodeMaterialConnectionPoint;
  58711. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58712. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58713. protected _buildBlock(state: NodeMaterialBuildState): this;
  58714. serialize(): any;
  58715. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58716. }
  58717. }
  58718. declare module BABYLON {
  58719. /**
  58720. * Block used to add image processing support to fragment shader
  58721. */
  58722. export class ImageProcessingBlock extends NodeMaterialBlock {
  58723. /**
  58724. * Create a new ImageProcessingBlock
  58725. * @param name defines the block name
  58726. */
  58727. constructor(name: string);
  58728. /**
  58729. * Gets the current class name
  58730. * @returns the class name
  58731. */
  58732. getClassName(): string;
  58733. /**
  58734. * Gets the color input component
  58735. */
  58736. get color(): NodeMaterialConnectionPoint;
  58737. /**
  58738. * Gets the output component
  58739. */
  58740. get output(): NodeMaterialConnectionPoint;
  58741. /**
  58742. * Initialize the block and prepare the context for build
  58743. * @param state defines the state that will be used for the build
  58744. */
  58745. initialize(state: NodeMaterialBuildState): void;
  58746. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  58747. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58748. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58749. protected _buildBlock(state: NodeMaterialBuildState): this;
  58750. }
  58751. }
  58752. declare module BABYLON {
  58753. /**
  58754. * Block used to pertub normals based on a normal map
  58755. */
  58756. export class PerturbNormalBlock extends NodeMaterialBlock {
  58757. private _tangentSpaceParameterName;
  58758. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58759. invertX: boolean;
  58760. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  58761. invertY: boolean;
  58762. /**
  58763. * Create a new PerturbNormalBlock
  58764. * @param name defines the block name
  58765. */
  58766. constructor(name: string);
  58767. /**
  58768. * Gets the current class name
  58769. * @returns the class name
  58770. */
  58771. getClassName(): string;
  58772. /**
  58773. * Gets the world position input component
  58774. */
  58775. get worldPosition(): NodeMaterialConnectionPoint;
  58776. /**
  58777. * Gets the world normal input component
  58778. */
  58779. get worldNormal(): NodeMaterialConnectionPoint;
  58780. /**
  58781. * Gets the world tangent input component
  58782. */
  58783. get worldTangent(): NodeMaterialConnectionPoint;
  58784. /**
  58785. * Gets the uv input component
  58786. */
  58787. get uv(): NodeMaterialConnectionPoint;
  58788. /**
  58789. * Gets the normal map color input component
  58790. */
  58791. get normalMapColor(): NodeMaterialConnectionPoint;
  58792. /**
  58793. * Gets the strength input component
  58794. */
  58795. get strength(): NodeMaterialConnectionPoint;
  58796. /**
  58797. * Gets the output component
  58798. */
  58799. get output(): NodeMaterialConnectionPoint;
  58800. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58801. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58802. autoConfigure(material: NodeMaterial): void;
  58803. protected _buildBlock(state: NodeMaterialBuildState): this;
  58804. protected _dumpPropertiesCode(): string;
  58805. serialize(): any;
  58806. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58807. }
  58808. }
  58809. declare module BABYLON {
  58810. /**
  58811. * Block used to discard a pixel if a value is smaller than a cutoff
  58812. */
  58813. export class DiscardBlock extends NodeMaterialBlock {
  58814. /**
  58815. * Create a new DiscardBlock
  58816. * @param name defines the block name
  58817. */
  58818. constructor(name: string);
  58819. /**
  58820. * Gets the current class name
  58821. * @returns the class name
  58822. */
  58823. getClassName(): string;
  58824. /**
  58825. * Gets the color input component
  58826. */
  58827. get value(): NodeMaterialConnectionPoint;
  58828. /**
  58829. * Gets the cutoff input component
  58830. */
  58831. get cutoff(): NodeMaterialConnectionPoint;
  58832. protected _buildBlock(state: NodeMaterialBuildState): this;
  58833. }
  58834. }
  58835. declare module BABYLON {
  58836. /**
  58837. * Block used to test if the fragment shader is front facing
  58838. */
  58839. export class FrontFacingBlock extends NodeMaterialBlock {
  58840. /**
  58841. * Creates a new FrontFacingBlock
  58842. * @param name defines the block name
  58843. */
  58844. constructor(name: string);
  58845. /**
  58846. * Gets the current class name
  58847. * @returns the class name
  58848. */
  58849. getClassName(): string;
  58850. /**
  58851. * Gets the output component
  58852. */
  58853. get output(): NodeMaterialConnectionPoint;
  58854. protected _buildBlock(state: NodeMaterialBuildState): this;
  58855. }
  58856. }
  58857. declare module BABYLON {
  58858. /**
  58859. * Block used to get the derivative value on x and y of a given input
  58860. */
  58861. export class DerivativeBlock extends NodeMaterialBlock {
  58862. /**
  58863. * Create a new DerivativeBlock
  58864. * @param name defines the block name
  58865. */
  58866. constructor(name: string);
  58867. /**
  58868. * Gets the current class name
  58869. * @returns the class name
  58870. */
  58871. getClassName(): string;
  58872. /**
  58873. * Gets the input component
  58874. */
  58875. get input(): NodeMaterialConnectionPoint;
  58876. /**
  58877. * Gets the derivative output on x
  58878. */
  58879. get dx(): NodeMaterialConnectionPoint;
  58880. /**
  58881. * Gets the derivative output on y
  58882. */
  58883. get dy(): NodeMaterialConnectionPoint;
  58884. protected _buildBlock(state: NodeMaterialBuildState): this;
  58885. }
  58886. }
  58887. declare module BABYLON {
  58888. /**
  58889. * Block used to add support for scene fog
  58890. */
  58891. export class FogBlock extends NodeMaterialBlock {
  58892. private _fogDistanceName;
  58893. private _fogParameters;
  58894. /**
  58895. * Create a new FogBlock
  58896. * @param name defines the block name
  58897. */
  58898. constructor(name: string);
  58899. /**
  58900. * Gets the current class name
  58901. * @returns the class name
  58902. */
  58903. getClassName(): string;
  58904. /**
  58905. * Gets the world position input component
  58906. */
  58907. get worldPosition(): NodeMaterialConnectionPoint;
  58908. /**
  58909. * Gets the view input component
  58910. */
  58911. get view(): NodeMaterialConnectionPoint;
  58912. /**
  58913. * Gets the color input component
  58914. */
  58915. get input(): NodeMaterialConnectionPoint;
  58916. /**
  58917. * Gets the fog color input component
  58918. */
  58919. get fogColor(): NodeMaterialConnectionPoint;
  58920. /**
  58921. * Gets the output component
  58922. */
  58923. get output(): NodeMaterialConnectionPoint;
  58924. autoConfigure(material: NodeMaterial): void;
  58925. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58926. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58927. protected _buildBlock(state: NodeMaterialBuildState): this;
  58928. }
  58929. }
  58930. declare module BABYLON {
  58931. /**
  58932. * Block used to add light in the fragment shader
  58933. */
  58934. export class LightBlock extends NodeMaterialBlock {
  58935. private _lightId;
  58936. /**
  58937. * Gets or sets the light associated with this block
  58938. */
  58939. light: Nullable<Light>;
  58940. /**
  58941. * Create a new LightBlock
  58942. * @param name defines the block name
  58943. */
  58944. constructor(name: string);
  58945. /**
  58946. * Gets the current class name
  58947. * @returns the class name
  58948. */
  58949. getClassName(): string;
  58950. /**
  58951. * Gets the world position input component
  58952. */
  58953. get worldPosition(): NodeMaterialConnectionPoint;
  58954. /**
  58955. * Gets the world normal input component
  58956. */
  58957. get worldNormal(): NodeMaterialConnectionPoint;
  58958. /**
  58959. * Gets the camera (or eye) position component
  58960. */
  58961. get cameraPosition(): NodeMaterialConnectionPoint;
  58962. /**
  58963. * Gets the glossiness component
  58964. */
  58965. get glossiness(): NodeMaterialConnectionPoint;
  58966. /**
  58967. * Gets the glossinness power component
  58968. */
  58969. get glossPower(): NodeMaterialConnectionPoint;
  58970. /**
  58971. * Gets the diffuse color component
  58972. */
  58973. get diffuseColor(): NodeMaterialConnectionPoint;
  58974. /**
  58975. * Gets the specular color component
  58976. */
  58977. get specularColor(): NodeMaterialConnectionPoint;
  58978. /**
  58979. * Gets the diffuse output component
  58980. */
  58981. get diffuseOutput(): NodeMaterialConnectionPoint;
  58982. /**
  58983. * Gets the specular output component
  58984. */
  58985. get specularOutput(): NodeMaterialConnectionPoint;
  58986. /**
  58987. * Gets the shadow output component
  58988. */
  58989. get shadow(): NodeMaterialConnectionPoint;
  58990. autoConfigure(material: NodeMaterial): void;
  58991. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58992. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58993. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58994. private _injectVertexCode;
  58995. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58996. serialize(): any;
  58997. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58998. }
  58999. }
  59000. declare module BABYLON {
  59001. /**
  59002. * Block used to multiply 2 values
  59003. */
  59004. export class MultiplyBlock extends NodeMaterialBlock {
  59005. /**
  59006. * Creates a new MultiplyBlock
  59007. * @param name defines the block name
  59008. */
  59009. constructor(name: string);
  59010. /**
  59011. * Gets the current class name
  59012. * @returns the class name
  59013. */
  59014. getClassName(): string;
  59015. /**
  59016. * Gets the left operand input component
  59017. */
  59018. get left(): NodeMaterialConnectionPoint;
  59019. /**
  59020. * Gets the right operand input component
  59021. */
  59022. get right(): NodeMaterialConnectionPoint;
  59023. /**
  59024. * Gets the output component
  59025. */
  59026. get output(): NodeMaterialConnectionPoint;
  59027. protected _buildBlock(state: NodeMaterialBuildState): this;
  59028. }
  59029. }
  59030. declare module BABYLON {
  59031. /**
  59032. * Block used to add 2 vectors
  59033. */
  59034. export class AddBlock extends NodeMaterialBlock {
  59035. /**
  59036. * Creates a new AddBlock
  59037. * @param name defines the block name
  59038. */
  59039. constructor(name: string);
  59040. /**
  59041. * Gets the current class name
  59042. * @returns the class name
  59043. */
  59044. getClassName(): string;
  59045. /**
  59046. * Gets the left operand input component
  59047. */
  59048. get left(): NodeMaterialConnectionPoint;
  59049. /**
  59050. * Gets the right operand input component
  59051. */
  59052. get right(): NodeMaterialConnectionPoint;
  59053. /**
  59054. * Gets the output component
  59055. */
  59056. get output(): NodeMaterialConnectionPoint;
  59057. protected _buildBlock(state: NodeMaterialBuildState): this;
  59058. }
  59059. }
  59060. declare module BABYLON {
  59061. /**
  59062. * Block used to scale a vector by a float
  59063. */
  59064. export class ScaleBlock extends NodeMaterialBlock {
  59065. /**
  59066. * Creates a new ScaleBlock
  59067. * @param name defines the block name
  59068. */
  59069. constructor(name: string);
  59070. /**
  59071. * Gets the current class name
  59072. * @returns the class name
  59073. */
  59074. getClassName(): string;
  59075. /**
  59076. * Gets the input component
  59077. */
  59078. get input(): NodeMaterialConnectionPoint;
  59079. /**
  59080. * Gets the factor input component
  59081. */
  59082. get factor(): NodeMaterialConnectionPoint;
  59083. /**
  59084. * Gets the output component
  59085. */
  59086. get output(): NodeMaterialConnectionPoint;
  59087. protected _buildBlock(state: NodeMaterialBuildState): this;
  59088. }
  59089. }
  59090. declare module BABYLON {
  59091. /**
  59092. * Block used to clamp a float
  59093. */
  59094. export class ClampBlock extends NodeMaterialBlock {
  59095. /** Gets or sets the minimum range */
  59096. minimum: number;
  59097. /** Gets or sets the maximum range */
  59098. maximum: number;
  59099. /**
  59100. * Creates a new ClampBlock
  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 value input component
  59111. */
  59112. get value(): NodeMaterialConnectionPoint;
  59113. /**
  59114. * Gets the output component
  59115. */
  59116. get output(): NodeMaterialConnectionPoint;
  59117. protected _buildBlock(state: NodeMaterialBuildState): this;
  59118. protected _dumpPropertiesCode(): string;
  59119. serialize(): any;
  59120. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59121. }
  59122. }
  59123. declare module BABYLON {
  59124. /**
  59125. * Block used to apply a cross product between 2 vectors
  59126. */
  59127. export class CrossBlock extends NodeMaterialBlock {
  59128. /**
  59129. * Creates a new CrossBlock
  59130. * @param name defines the block name
  59131. */
  59132. constructor(name: string);
  59133. /**
  59134. * Gets the current class name
  59135. * @returns the class name
  59136. */
  59137. getClassName(): string;
  59138. /**
  59139. * Gets the left operand input component
  59140. */
  59141. get left(): NodeMaterialConnectionPoint;
  59142. /**
  59143. * Gets the right operand input component
  59144. */
  59145. get right(): NodeMaterialConnectionPoint;
  59146. /**
  59147. * Gets the output component
  59148. */
  59149. get output(): NodeMaterialConnectionPoint;
  59150. protected _buildBlock(state: NodeMaterialBuildState): this;
  59151. }
  59152. }
  59153. declare module BABYLON {
  59154. /**
  59155. * Block used to apply a dot product between 2 vectors
  59156. */
  59157. export class DotBlock extends NodeMaterialBlock {
  59158. /**
  59159. * Creates a new DotBlock
  59160. * @param name defines the block name
  59161. */
  59162. constructor(name: string);
  59163. /**
  59164. * Gets the current class name
  59165. * @returns the class name
  59166. */
  59167. getClassName(): string;
  59168. /**
  59169. * Gets the left operand input component
  59170. */
  59171. get left(): NodeMaterialConnectionPoint;
  59172. /**
  59173. * Gets the right operand input component
  59174. */
  59175. get right(): NodeMaterialConnectionPoint;
  59176. /**
  59177. * Gets the output component
  59178. */
  59179. get output(): NodeMaterialConnectionPoint;
  59180. protected _buildBlock(state: NodeMaterialBuildState): this;
  59181. }
  59182. }
  59183. declare module BABYLON {
  59184. /**
  59185. * Block used to remap a float from a range to a new one
  59186. */
  59187. export class RemapBlock extends NodeMaterialBlock {
  59188. /**
  59189. * Gets or sets the source range
  59190. */
  59191. sourceRange: Vector2;
  59192. /**
  59193. * Gets or sets the target range
  59194. */
  59195. targetRange: Vector2;
  59196. /**
  59197. * Creates a new RemapBlock
  59198. * @param name defines the block name
  59199. */
  59200. constructor(name: string);
  59201. /**
  59202. * Gets the current class name
  59203. * @returns the class name
  59204. */
  59205. getClassName(): string;
  59206. /**
  59207. * Gets the input component
  59208. */
  59209. get input(): NodeMaterialConnectionPoint;
  59210. /**
  59211. * Gets the source min input component
  59212. */
  59213. get sourceMin(): NodeMaterialConnectionPoint;
  59214. /**
  59215. * Gets the source max input component
  59216. */
  59217. get sourceMax(): NodeMaterialConnectionPoint;
  59218. /**
  59219. * Gets the target min input component
  59220. */
  59221. get targetMin(): NodeMaterialConnectionPoint;
  59222. /**
  59223. * Gets the target max input component
  59224. */
  59225. get targetMax(): NodeMaterialConnectionPoint;
  59226. /**
  59227. * Gets the output component
  59228. */
  59229. get output(): NodeMaterialConnectionPoint;
  59230. protected _buildBlock(state: NodeMaterialBuildState): this;
  59231. protected _dumpPropertiesCode(): string;
  59232. serialize(): any;
  59233. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59234. }
  59235. }
  59236. declare module BABYLON {
  59237. /**
  59238. * Block used to normalize a vector
  59239. */
  59240. export class NormalizeBlock extends NodeMaterialBlock {
  59241. /**
  59242. * Creates a new NormalizeBlock
  59243. * @param name defines the block name
  59244. */
  59245. constructor(name: string);
  59246. /**
  59247. * Gets the current class name
  59248. * @returns the class name
  59249. */
  59250. getClassName(): string;
  59251. /**
  59252. * Gets the input component
  59253. */
  59254. get input(): NodeMaterialConnectionPoint;
  59255. /**
  59256. * Gets the output component
  59257. */
  59258. get output(): NodeMaterialConnectionPoint;
  59259. protected _buildBlock(state: NodeMaterialBuildState): this;
  59260. }
  59261. }
  59262. declare module BABYLON {
  59263. /**
  59264. * Operations supported by the Trigonometry block
  59265. */
  59266. export enum TrigonometryBlockOperations {
  59267. /** Cos */
  59268. Cos = 0,
  59269. /** Sin */
  59270. Sin = 1,
  59271. /** Abs */
  59272. Abs = 2,
  59273. /** Exp */
  59274. Exp = 3,
  59275. /** Exp2 */
  59276. Exp2 = 4,
  59277. /** Round */
  59278. Round = 5,
  59279. /** Floor */
  59280. Floor = 6,
  59281. /** Ceiling */
  59282. Ceiling = 7,
  59283. /** Square root */
  59284. Sqrt = 8,
  59285. /** Log */
  59286. Log = 9,
  59287. /** Tangent */
  59288. Tan = 10,
  59289. /** Arc tangent */
  59290. ArcTan = 11,
  59291. /** Arc cosinus */
  59292. ArcCos = 12,
  59293. /** Arc sinus */
  59294. ArcSin = 13,
  59295. /** Fraction */
  59296. Fract = 14,
  59297. /** Sign */
  59298. Sign = 15,
  59299. /** To radians (from degrees) */
  59300. Radians = 16,
  59301. /** To degrees (from radians) */
  59302. Degrees = 17
  59303. }
  59304. /**
  59305. * Block used to apply trigonometry operation to floats
  59306. */
  59307. export class TrigonometryBlock extends NodeMaterialBlock {
  59308. /**
  59309. * Gets or sets the operation applied by the block
  59310. */
  59311. operation: TrigonometryBlockOperations;
  59312. /**
  59313. * Creates a new TrigonometryBlock
  59314. * @param name defines the block name
  59315. */
  59316. constructor(name: string);
  59317. /**
  59318. * Gets the current class name
  59319. * @returns the class name
  59320. */
  59321. getClassName(): string;
  59322. /**
  59323. * Gets the input component
  59324. */
  59325. get input(): NodeMaterialConnectionPoint;
  59326. /**
  59327. * Gets the output component
  59328. */
  59329. get output(): NodeMaterialConnectionPoint;
  59330. protected _buildBlock(state: NodeMaterialBuildState): this;
  59331. serialize(): any;
  59332. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59333. protected _dumpPropertiesCode(): string;
  59334. }
  59335. }
  59336. declare module BABYLON {
  59337. /**
  59338. * Block used to create a Color3/4 out of individual inputs (one for each component)
  59339. */
  59340. export class ColorMergerBlock extends NodeMaterialBlock {
  59341. /**
  59342. * Create a new ColorMergerBlock
  59343. * @param name defines the block name
  59344. */
  59345. constructor(name: string);
  59346. /**
  59347. * Gets the current class name
  59348. * @returns the class name
  59349. */
  59350. getClassName(): string;
  59351. /**
  59352. * Gets the rgb component (input)
  59353. */
  59354. get rgbIn(): NodeMaterialConnectionPoint;
  59355. /**
  59356. * Gets the r component (input)
  59357. */
  59358. get r(): NodeMaterialConnectionPoint;
  59359. /**
  59360. * Gets the g component (input)
  59361. */
  59362. get g(): NodeMaterialConnectionPoint;
  59363. /**
  59364. * Gets the b component (input)
  59365. */
  59366. get b(): NodeMaterialConnectionPoint;
  59367. /**
  59368. * Gets the a component (input)
  59369. */
  59370. get a(): NodeMaterialConnectionPoint;
  59371. /**
  59372. * Gets the rgba component (output)
  59373. */
  59374. get rgba(): NodeMaterialConnectionPoint;
  59375. /**
  59376. * Gets the rgb component (output)
  59377. */
  59378. get rgbOut(): NodeMaterialConnectionPoint;
  59379. /**
  59380. * Gets the rgb component (output)
  59381. * @deprecated Please use rgbOut instead.
  59382. */
  59383. get rgb(): NodeMaterialConnectionPoint;
  59384. protected _buildBlock(state: NodeMaterialBuildState): this;
  59385. }
  59386. }
  59387. declare module BABYLON {
  59388. /**
  59389. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  59390. */
  59391. export class VectorMergerBlock extends NodeMaterialBlock {
  59392. /**
  59393. * Create a new VectorMergerBlock
  59394. * @param name defines the block name
  59395. */
  59396. constructor(name: string);
  59397. /**
  59398. * Gets the current class name
  59399. * @returns the class name
  59400. */
  59401. getClassName(): string;
  59402. /**
  59403. * Gets the xyz component (input)
  59404. */
  59405. get xyzIn(): NodeMaterialConnectionPoint;
  59406. /**
  59407. * Gets the xy component (input)
  59408. */
  59409. get xyIn(): NodeMaterialConnectionPoint;
  59410. /**
  59411. * Gets the x component (input)
  59412. */
  59413. get x(): NodeMaterialConnectionPoint;
  59414. /**
  59415. * Gets the y component (input)
  59416. */
  59417. get y(): NodeMaterialConnectionPoint;
  59418. /**
  59419. * Gets the z component (input)
  59420. */
  59421. get z(): NodeMaterialConnectionPoint;
  59422. /**
  59423. * Gets the w component (input)
  59424. */
  59425. get w(): NodeMaterialConnectionPoint;
  59426. /**
  59427. * Gets the xyzw component (output)
  59428. */
  59429. get xyzw(): NodeMaterialConnectionPoint;
  59430. /**
  59431. * Gets the xyz component (output)
  59432. */
  59433. get xyzOut(): NodeMaterialConnectionPoint;
  59434. /**
  59435. * Gets the xy component (output)
  59436. */
  59437. get xyOut(): NodeMaterialConnectionPoint;
  59438. /**
  59439. * Gets the xy component (output)
  59440. * @deprecated Please use xyOut instead.
  59441. */
  59442. get xy(): NodeMaterialConnectionPoint;
  59443. /**
  59444. * Gets the xyz component (output)
  59445. * @deprecated Please use xyzOut instead.
  59446. */
  59447. get xyz(): NodeMaterialConnectionPoint;
  59448. protected _buildBlock(state: NodeMaterialBuildState): this;
  59449. }
  59450. }
  59451. declare module BABYLON {
  59452. /**
  59453. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  59454. */
  59455. export class ColorSplitterBlock extends NodeMaterialBlock {
  59456. /**
  59457. * Create a new ColorSplitterBlock
  59458. * @param name defines the block name
  59459. */
  59460. constructor(name: string);
  59461. /**
  59462. * Gets the current class name
  59463. * @returns the class name
  59464. */
  59465. getClassName(): string;
  59466. /**
  59467. * Gets the rgba component (input)
  59468. */
  59469. get rgba(): NodeMaterialConnectionPoint;
  59470. /**
  59471. * Gets the rgb component (input)
  59472. */
  59473. get rgbIn(): NodeMaterialConnectionPoint;
  59474. /**
  59475. * Gets the rgb component (output)
  59476. */
  59477. get rgbOut(): NodeMaterialConnectionPoint;
  59478. /**
  59479. * Gets the r component (output)
  59480. */
  59481. get r(): NodeMaterialConnectionPoint;
  59482. /**
  59483. * Gets the g component (output)
  59484. */
  59485. get g(): NodeMaterialConnectionPoint;
  59486. /**
  59487. * Gets the b component (output)
  59488. */
  59489. get b(): NodeMaterialConnectionPoint;
  59490. /**
  59491. * Gets the a component (output)
  59492. */
  59493. get a(): NodeMaterialConnectionPoint;
  59494. protected _inputRename(name: string): string;
  59495. protected _outputRename(name: string): string;
  59496. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59497. }
  59498. }
  59499. declare module BABYLON {
  59500. /**
  59501. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  59502. */
  59503. export class VectorSplitterBlock extends NodeMaterialBlock {
  59504. /**
  59505. * Create a new VectorSplitterBlock
  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 xyzw component (input)
  59516. */
  59517. get xyzw(): NodeMaterialConnectionPoint;
  59518. /**
  59519. * Gets the xyz component (input)
  59520. */
  59521. get xyzIn(): NodeMaterialConnectionPoint;
  59522. /**
  59523. * Gets the xy component (input)
  59524. */
  59525. get xyIn(): NodeMaterialConnectionPoint;
  59526. /**
  59527. * Gets the xyz component (output)
  59528. */
  59529. get xyzOut(): NodeMaterialConnectionPoint;
  59530. /**
  59531. * Gets the xy component (output)
  59532. */
  59533. get xyOut(): NodeMaterialConnectionPoint;
  59534. /**
  59535. * Gets the x component (output)
  59536. */
  59537. get x(): NodeMaterialConnectionPoint;
  59538. /**
  59539. * Gets the y component (output)
  59540. */
  59541. get y(): NodeMaterialConnectionPoint;
  59542. /**
  59543. * Gets the z component (output)
  59544. */
  59545. get z(): NodeMaterialConnectionPoint;
  59546. /**
  59547. * Gets the w component (output)
  59548. */
  59549. get w(): NodeMaterialConnectionPoint;
  59550. protected _inputRename(name: string): string;
  59551. protected _outputRename(name: string): string;
  59552. protected _buildBlock(state: NodeMaterialBuildState): this;
  59553. }
  59554. }
  59555. declare module BABYLON {
  59556. /**
  59557. * Block used to lerp between 2 values
  59558. */
  59559. export class LerpBlock extends NodeMaterialBlock {
  59560. /**
  59561. * Creates a new LerpBlock
  59562. * @param name defines the block name
  59563. */
  59564. constructor(name: string);
  59565. /**
  59566. * Gets the current class name
  59567. * @returns the class name
  59568. */
  59569. getClassName(): string;
  59570. /**
  59571. * Gets the left operand input component
  59572. */
  59573. get left(): NodeMaterialConnectionPoint;
  59574. /**
  59575. * Gets the right operand input component
  59576. */
  59577. get right(): NodeMaterialConnectionPoint;
  59578. /**
  59579. * Gets the gradient operand input component
  59580. */
  59581. get gradient(): NodeMaterialConnectionPoint;
  59582. /**
  59583. * Gets the output component
  59584. */
  59585. get output(): NodeMaterialConnectionPoint;
  59586. protected _buildBlock(state: NodeMaterialBuildState): this;
  59587. }
  59588. }
  59589. declare module BABYLON {
  59590. /**
  59591. * Block used to divide 2 vectors
  59592. */
  59593. export class DivideBlock extends NodeMaterialBlock {
  59594. /**
  59595. * Creates a new DivideBlock
  59596. * @param name defines the block name
  59597. */
  59598. constructor(name: string);
  59599. /**
  59600. * Gets the current class name
  59601. * @returns the class name
  59602. */
  59603. getClassName(): string;
  59604. /**
  59605. * Gets the left operand input component
  59606. */
  59607. get left(): NodeMaterialConnectionPoint;
  59608. /**
  59609. * Gets the right operand input component
  59610. */
  59611. get right(): NodeMaterialConnectionPoint;
  59612. /**
  59613. * Gets the output component
  59614. */
  59615. get output(): NodeMaterialConnectionPoint;
  59616. protected _buildBlock(state: NodeMaterialBuildState): this;
  59617. }
  59618. }
  59619. declare module BABYLON {
  59620. /**
  59621. * Block used to subtract 2 vectors
  59622. */
  59623. export class SubtractBlock extends NodeMaterialBlock {
  59624. /**
  59625. * Creates a new SubtractBlock
  59626. * @param name defines the block name
  59627. */
  59628. constructor(name: string);
  59629. /**
  59630. * Gets the current class name
  59631. * @returns the class name
  59632. */
  59633. getClassName(): string;
  59634. /**
  59635. * Gets the left operand input component
  59636. */
  59637. get left(): NodeMaterialConnectionPoint;
  59638. /**
  59639. * Gets the right operand input component
  59640. */
  59641. get right(): NodeMaterialConnectionPoint;
  59642. /**
  59643. * Gets the output component
  59644. */
  59645. get output(): NodeMaterialConnectionPoint;
  59646. protected _buildBlock(state: NodeMaterialBuildState): this;
  59647. }
  59648. }
  59649. declare module BABYLON {
  59650. /**
  59651. * Block used to step a value
  59652. */
  59653. export class StepBlock extends NodeMaterialBlock {
  59654. /**
  59655. * Creates a new StepBlock
  59656. * @param name defines the block name
  59657. */
  59658. constructor(name: string);
  59659. /**
  59660. * Gets the current class name
  59661. * @returns the class name
  59662. */
  59663. getClassName(): string;
  59664. /**
  59665. * Gets the value operand input component
  59666. */
  59667. get value(): NodeMaterialConnectionPoint;
  59668. /**
  59669. * Gets the edge operand input component
  59670. */
  59671. get edge(): NodeMaterialConnectionPoint;
  59672. /**
  59673. * Gets the output component
  59674. */
  59675. get output(): NodeMaterialConnectionPoint;
  59676. protected _buildBlock(state: NodeMaterialBuildState): this;
  59677. }
  59678. }
  59679. declare module BABYLON {
  59680. /**
  59681. * Block used to get the opposite (1 - x) of a value
  59682. */
  59683. export class OneMinusBlock extends NodeMaterialBlock {
  59684. /**
  59685. * Creates a new OneMinusBlock
  59686. * @param name defines the block name
  59687. */
  59688. constructor(name: string);
  59689. /**
  59690. * Gets the current class name
  59691. * @returns the class name
  59692. */
  59693. getClassName(): string;
  59694. /**
  59695. * Gets the input component
  59696. */
  59697. get input(): NodeMaterialConnectionPoint;
  59698. /**
  59699. * Gets the output component
  59700. */
  59701. get output(): NodeMaterialConnectionPoint;
  59702. protected _buildBlock(state: NodeMaterialBuildState): this;
  59703. }
  59704. }
  59705. declare module BABYLON {
  59706. /**
  59707. * Block used to get the view direction
  59708. */
  59709. export class ViewDirectionBlock extends NodeMaterialBlock {
  59710. /**
  59711. * Creates a new ViewDirectionBlock
  59712. * @param name defines the block name
  59713. */
  59714. constructor(name: string);
  59715. /**
  59716. * Gets the current class name
  59717. * @returns the class name
  59718. */
  59719. getClassName(): string;
  59720. /**
  59721. * Gets the world position component
  59722. */
  59723. get worldPosition(): NodeMaterialConnectionPoint;
  59724. /**
  59725. * Gets the camera position component
  59726. */
  59727. get cameraPosition(): NodeMaterialConnectionPoint;
  59728. /**
  59729. * Gets the output component
  59730. */
  59731. get output(): NodeMaterialConnectionPoint;
  59732. autoConfigure(material: NodeMaterial): void;
  59733. protected _buildBlock(state: NodeMaterialBuildState): this;
  59734. }
  59735. }
  59736. declare module BABYLON {
  59737. /**
  59738. * Block used to compute fresnel value
  59739. */
  59740. export class FresnelBlock extends NodeMaterialBlock {
  59741. /**
  59742. * Create a new FresnelBlock
  59743. * @param name defines the block name
  59744. */
  59745. constructor(name: string);
  59746. /**
  59747. * Gets the current class name
  59748. * @returns the class name
  59749. */
  59750. getClassName(): string;
  59751. /**
  59752. * Gets the world normal input component
  59753. */
  59754. get worldNormal(): NodeMaterialConnectionPoint;
  59755. /**
  59756. * Gets the view direction input component
  59757. */
  59758. get viewDirection(): NodeMaterialConnectionPoint;
  59759. /**
  59760. * Gets the bias input component
  59761. */
  59762. get bias(): NodeMaterialConnectionPoint;
  59763. /**
  59764. * Gets the camera (or eye) position component
  59765. */
  59766. get power(): NodeMaterialConnectionPoint;
  59767. /**
  59768. * Gets the fresnel output component
  59769. */
  59770. get fresnel(): NodeMaterialConnectionPoint;
  59771. autoConfigure(material: NodeMaterial): void;
  59772. protected _buildBlock(state: NodeMaterialBuildState): this;
  59773. }
  59774. }
  59775. declare module BABYLON {
  59776. /**
  59777. * Block used to get the max of 2 values
  59778. */
  59779. export class MaxBlock extends NodeMaterialBlock {
  59780. /**
  59781. * Creates a new MaxBlock
  59782. * @param name defines the block name
  59783. */
  59784. constructor(name: string);
  59785. /**
  59786. * Gets the current class name
  59787. * @returns the class name
  59788. */
  59789. getClassName(): string;
  59790. /**
  59791. * Gets the left operand input component
  59792. */
  59793. get left(): NodeMaterialConnectionPoint;
  59794. /**
  59795. * Gets the right operand input component
  59796. */
  59797. get right(): NodeMaterialConnectionPoint;
  59798. /**
  59799. * Gets the output component
  59800. */
  59801. get output(): NodeMaterialConnectionPoint;
  59802. protected _buildBlock(state: NodeMaterialBuildState): this;
  59803. }
  59804. }
  59805. declare module BABYLON {
  59806. /**
  59807. * Block used to get the min of 2 values
  59808. */
  59809. export class MinBlock extends NodeMaterialBlock {
  59810. /**
  59811. * Creates a new MinBlock
  59812. * @param name defines the block name
  59813. */
  59814. constructor(name: string);
  59815. /**
  59816. * Gets the current class name
  59817. * @returns the class name
  59818. */
  59819. getClassName(): string;
  59820. /**
  59821. * Gets the left operand input component
  59822. */
  59823. get left(): NodeMaterialConnectionPoint;
  59824. /**
  59825. * Gets the right operand input component
  59826. */
  59827. get right(): NodeMaterialConnectionPoint;
  59828. /**
  59829. * Gets the output component
  59830. */
  59831. get output(): NodeMaterialConnectionPoint;
  59832. protected _buildBlock(state: NodeMaterialBuildState): this;
  59833. }
  59834. }
  59835. declare module BABYLON {
  59836. /**
  59837. * Block used to get the distance between 2 values
  59838. */
  59839. export class DistanceBlock extends NodeMaterialBlock {
  59840. /**
  59841. * Creates a new DistanceBlock
  59842. * @param name defines the block name
  59843. */
  59844. constructor(name: string);
  59845. /**
  59846. * Gets the current class name
  59847. * @returns the class name
  59848. */
  59849. getClassName(): string;
  59850. /**
  59851. * Gets the left operand input component
  59852. */
  59853. get left(): NodeMaterialConnectionPoint;
  59854. /**
  59855. * Gets the right operand input component
  59856. */
  59857. get right(): NodeMaterialConnectionPoint;
  59858. /**
  59859. * Gets the output component
  59860. */
  59861. get output(): NodeMaterialConnectionPoint;
  59862. protected _buildBlock(state: NodeMaterialBuildState): this;
  59863. }
  59864. }
  59865. declare module BABYLON {
  59866. /**
  59867. * Block used to get the length of a vector
  59868. */
  59869. export class LengthBlock extends NodeMaterialBlock {
  59870. /**
  59871. * Creates a new LengthBlock
  59872. * @param name defines the block name
  59873. */
  59874. constructor(name: string);
  59875. /**
  59876. * Gets the current class name
  59877. * @returns the class name
  59878. */
  59879. getClassName(): string;
  59880. /**
  59881. * Gets the value input component
  59882. */
  59883. get value(): NodeMaterialConnectionPoint;
  59884. /**
  59885. * Gets the output component
  59886. */
  59887. get output(): NodeMaterialConnectionPoint;
  59888. protected _buildBlock(state: NodeMaterialBuildState): this;
  59889. }
  59890. }
  59891. declare module BABYLON {
  59892. /**
  59893. * Block used to get negative version of a value (i.e. x * -1)
  59894. */
  59895. export class NegateBlock extends NodeMaterialBlock {
  59896. /**
  59897. * Creates a new NegateBlock
  59898. * @param name defines the block name
  59899. */
  59900. constructor(name: string);
  59901. /**
  59902. * Gets the current class name
  59903. * @returns the class name
  59904. */
  59905. getClassName(): string;
  59906. /**
  59907. * Gets the value input component
  59908. */
  59909. get value(): NodeMaterialConnectionPoint;
  59910. /**
  59911. * Gets the output component
  59912. */
  59913. get output(): NodeMaterialConnectionPoint;
  59914. protected _buildBlock(state: NodeMaterialBuildState): this;
  59915. }
  59916. }
  59917. declare module BABYLON {
  59918. /**
  59919. * Block used to get the value of the first parameter raised to the power of the second
  59920. */
  59921. export class PowBlock extends NodeMaterialBlock {
  59922. /**
  59923. * Creates a new PowBlock
  59924. * @param name defines the block name
  59925. */
  59926. constructor(name: string);
  59927. /**
  59928. * Gets the current class name
  59929. * @returns the class name
  59930. */
  59931. getClassName(): string;
  59932. /**
  59933. * Gets the value operand input component
  59934. */
  59935. get value(): NodeMaterialConnectionPoint;
  59936. /**
  59937. * Gets the power operand input component
  59938. */
  59939. get power(): NodeMaterialConnectionPoint;
  59940. /**
  59941. * Gets the output component
  59942. */
  59943. get output(): NodeMaterialConnectionPoint;
  59944. protected _buildBlock(state: NodeMaterialBuildState): this;
  59945. }
  59946. }
  59947. declare module BABYLON {
  59948. /**
  59949. * Block used to get a random number
  59950. */
  59951. export class RandomNumberBlock extends NodeMaterialBlock {
  59952. /**
  59953. * Creates a new RandomNumberBlock
  59954. * @param name defines the block name
  59955. */
  59956. constructor(name: string);
  59957. /**
  59958. * Gets the current class name
  59959. * @returns the class name
  59960. */
  59961. getClassName(): string;
  59962. /**
  59963. * Gets the seed input component
  59964. */
  59965. get seed(): NodeMaterialConnectionPoint;
  59966. /**
  59967. * Gets the output component
  59968. */
  59969. get output(): NodeMaterialConnectionPoint;
  59970. protected _buildBlock(state: NodeMaterialBuildState): this;
  59971. }
  59972. }
  59973. declare module BABYLON {
  59974. /**
  59975. * Block used to compute arc tangent of 2 values
  59976. */
  59977. export class ArcTan2Block extends NodeMaterialBlock {
  59978. /**
  59979. * Creates a new ArcTan2Block
  59980. * @param name defines the block name
  59981. */
  59982. constructor(name: string);
  59983. /**
  59984. * Gets the current class name
  59985. * @returns the class name
  59986. */
  59987. getClassName(): string;
  59988. /**
  59989. * Gets the x operand input component
  59990. */
  59991. get x(): NodeMaterialConnectionPoint;
  59992. /**
  59993. * Gets the y operand input component
  59994. */
  59995. get y(): NodeMaterialConnectionPoint;
  59996. /**
  59997. * Gets the output component
  59998. */
  59999. get output(): NodeMaterialConnectionPoint;
  60000. protected _buildBlock(state: NodeMaterialBuildState): this;
  60001. }
  60002. }
  60003. declare module BABYLON {
  60004. /**
  60005. * Block used to smooth step a value
  60006. */
  60007. export class SmoothStepBlock extends NodeMaterialBlock {
  60008. /**
  60009. * Creates a new SmoothStepBlock
  60010. * @param name defines the block name
  60011. */
  60012. constructor(name: string);
  60013. /**
  60014. * Gets the current class name
  60015. * @returns the class name
  60016. */
  60017. getClassName(): string;
  60018. /**
  60019. * Gets the value operand input component
  60020. */
  60021. get value(): NodeMaterialConnectionPoint;
  60022. /**
  60023. * Gets the first edge operand input component
  60024. */
  60025. get edge0(): NodeMaterialConnectionPoint;
  60026. /**
  60027. * Gets the second edge operand input component
  60028. */
  60029. get edge1(): NodeMaterialConnectionPoint;
  60030. /**
  60031. * Gets the output component
  60032. */
  60033. get output(): NodeMaterialConnectionPoint;
  60034. protected _buildBlock(state: NodeMaterialBuildState): this;
  60035. }
  60036. }
  60037. declare module BABYLON {
  60038. /**
  60039. * Block used to get the reciprocal (1 / x) of a value
  60040. */
  60041. export class ReciprocalBlock extends NodeMaterialBlock {
  60042. /**
  60043. * Creates a new ReciprocalBlock
  60044. * @param name defines the block name
  60045. */
  60046. constructor(name: string);
  60047. /**
  60048. * Gets the current class name
  60049. * @returns the class name
  60050. */
  60051. getClassName(): string;
  60052. /**
  60053. * Gets the input component
  60054. */
  60055. get input(): NodeMaterialConnectionPoint;
  60056. /**
  60057. * Gets the output component
  60058. */
  60059. get output(): NodeMaterialConnectionPoint;
  60060. protected _buildBlock(state: NodeMaterialBuildState): this;
  60061. }
  60062. }
  60063. declare module BABYLON {
  60064. /**
  60065. * Block used to replace a color by another one
  60066. */
  60067. export class ReplaceColorBlock extends NodeMaterialBlock {
  60068. /**
  60069. * Creates a new ReplaceColorBlock
  60070. * @param name defines the block name
  60071. */
  60072. constructor(name: string);
  60073. /**
  60074. * Gets the current class name
  60075. * @returns the class name
  60076. */
  60077. getClassName(): string;
  60078. /**
  60079. * Gets the value input component
  60080. */
  60081. get value(): NodeMaterialConnectionPoint;
  60082. /**
  60083. * Gets the reference input component
  60084. */
  60085. get reference(): NodeMaterialConnectionPoint;
  60086. /**
  60087. * Gets the distance input component
  60088. */
  60089. get distance(): NodeMaterialConnectionPoint;
  60090. /**
  60091. * Gets the replacement input component
  60092. */
  60093. get replacement(): NodeMaterialConnectionPoint;
  60094. /**
  60095. * Gets the output component
  60096. */
  60097. get output(): NodeMaterialConnectionPoint;
  60098. protected _buildBlock(state: NodeMaterialBuildState): this;
  60099. }
  60100. }
  60101. declare module BABYLON {
  60102. /**
  60103. * Block used to posterize a value
  60104. * @see https://en.wikipedia.org/wiki/Posterization
  60105. */
  60106. export class PosterizeBlock extends NodeMaterialBlock {
  60107. /**
  60108. * Creates a new PosterizeBlock
  60109. * @param name defines the block name
  60110. */
  60111. constructor(name: string);
  60112. /**
  60113. * Gets the current class name
  60114. * @returns the class name
  60115. */
  60116. getClassName(): string;
  60117. /**
  60118. * Gets the value input component
  60119. */
  60120. get value(): NodeMaterialConnectionPoint;
  60121. /**
  60122. * Gets the steps input component
  60123. */
  60124. get steps(): NodeMaterialConnectionPoint;
  60125. /**
  60126. * Gets the output component
  60127. */
  60128. get output(): NodeMaterialConnectionPoint;
  60129. protected _buildBlock(state: NodeMaterialBuildState): this;
  60130. }
  60131. }
  60132. declare module BABYLON {
  60133. /**
  60134. * Operations supported by the Wave block
  60135. */
  60136. export enum WaveBlockKind {
  60137. /** SawTooth */
  60138. SawTooth = 0,
  60139. /** Square */
  60140. Square = 1,
  60141. /** Triangle */
  60142. Triangle = 2
  60143. }
  60144. /**
  60145. * Block used to apply wave operation to floats
  60146. */
  60147. export class WaveBlock extends NodeMaterialBlock {
  60148. /**
  60149. * Gets or sets the kibnd of wave to be applied by the block
  60150. */
  60151. kind: WaveBlockKind;
  60152. /**
  60153. * Creates a new WaveBlock
  60154. * @param name defines the block name
  60155. */
  60156. constructor(name: string);
  60157. /**
  60158. * Gets the current class name
  60159. * @returns the class name
  60160. */
  60161. getClassName(): string;
  60162. /**
  60163. * Gets the input component
  60164. */
  60165. get input(): NodeMaterialConnectionPoint;
  60166. /**
  60167. * Gets the output component
  60168. */
  60169. get output(): NodeMaterialConnectionPoint;
  60170. protected _buildBlock(state: NodeMaterialBuildState): this;
  60171. serialize(): any;
  60172. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60173. }
  60174. }
  60175. declare module BABYLON {
  60176. /**
  60177. * Class used to store a color step for the GradientBlock
  60178. */
  60179. export class GradientBlockColorStep {
  60180. /**
  60181. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60182. */
  60183. step: number;
  60184. /**
  60185. * Gets or sets the color associated with this step
  60186. */
  60187. color: Color3;
  60188. /**
  60189. * Creates a new GradientBlockColorStep
  60190. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  60191. * @param color defines the color associated with this step
  60192. */
  60193. constructor(
  60194. /**
  60195. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60196. */
  60197. step: number,
  60198. /**
  60199. * Gets or sets the color associated with this step
  60200. */
  60201. color: Color3);
  60202. }
  60203. /**
  60204. * Block used to return a color from a gradient based on an input value between 0 and 1
  60205. */
  60206. export class GradientBlock extends NodeMaterialBlock {
  60207. /**
  60208. * Gets or sets the list of color steps
  60209. */
  60210. colorSteps: GradientBlockColorStep[];
  60211. /**
  60212. * Creates a new GradientBlock
  60213. * @param name defines the block name
  60214. */
  60215. constructor(name: string);
  60216. /**
  60217. * Gets the current class name
  60218. * @returns the class name
  60219. */
  60220. getClassName(): string;
  60221. /**
  60222. * Gets the gradient input component
  60223. */
  60224. get gradient(): NodeMaterialConnectionPoint;
  60225. /**
  60226. * Gets the output component
  60227. */
  60228. get output(): NodeMaterialConnectionPoint;
  60229. private _writeColorConstant;
  60230. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60231. serialize(): any;
  60232. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60233. protected _dumpPropertiesCode(): string;
  60234. }
  60235. }
  60236. declare module BABYLON {
  60237. /**
  60238. * Block used to normalize lerp between 2 values
  60239. */
  60240. export class NLerpBlock extends NodeMaterialBlock {
  60241. /**
  60242. * Creates a new NLerpBlock
  60243. * @param name defines the block name
  60244. */
  60245. constructor(name: string);
  60246. /**
  60247. * Gets the current class name
  60248. * @returns the class name
  60249. */
  60250. getClassName(): string;
  60251. /**
  60252. * Gets the left operand input component
  60253. */
  60254. get left(): NodeMaterialConnectionPoint;
  60255. /**
  60256. * Gets the right operand input component
  60257. */
  60258. get right(): NodeMaterialConnectionPoint;
  60259. /**
  60260. * Gets the gradient operand input component
  60261. */
  60262. get gradient(): NodeMaterialConnectionPoint;
  60263. /**
  60264. * Gets the output component
  60265. */
  60266. get output(): NodeMaterialConnectionPoint;
  60267. protected _buildBlock(state: NodeMaterialBuildState): this;
  60268. }
  60269. }
  60270. declare module BABYLON {
  60271. /**
  60272. * block used to Generate a Worley Noise 3D Noise Pattern
  60273. */
  60274. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  60275. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60276. manhattanDistance: boolean;
  60277. /**
  60278. * Creates a new WorleyNoise3DBlock
  60279. * @param name defines the block name
  60280. */
  60281. constructor(name: string);
  60282. /**
  60283. * Gets the current class name
  60284. * @returns the class name
  60285. */
  60286. getClassName(): string;
  60287. /**
  60288. * Gets the seed input component
  60289. */
  60290. get seed(): NodeMaterialConnectionPoint;
  60291. /**
  60292. * Gets the jitter input component
  60293. */
  60294. get jitter(): NodeMaterialConnectionPoint;
  60295. /**
  60296. * Gets the output component
  60297. */
  60298. get output(): NodeMaterialConnectionPoint;
  60299. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60300. /**
  60301. * Exposes the properties to the UI?
  60302. */
  60303. protected _dumpPropertiesCode(): string;
  60304. /**
  60305. * Exposes the properties to the Seralize?
  60306. */
  60307. serialize(): any;
  60308. /**
  60309. * Exposes the properties to the deseralize?
  60310. */
  60311. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60312. }
  60313. }
  60314. declare module BABYLON {
  60315. /**
  60316. * block used to Generate a Simplex Perlin 3d Noise Pattern
  60317. */
  60318. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  60319. /**
  60320. * Creates a new SimplexPerlin3DBlock
  60321. * @param name defines the block name
  60322. */
  60323. constructor(name: string);
  60324. /**
  60325. * Gets the current class name
  60326. * @returns the class name
  60327. */
  60328. getClassName(): string;
  60329. /**
  60330. * Gets the seed operand input component
  60331. */
  60332. get seed(): NodeMaterialConnectionPoint;
  60333. /**
  60334. * Gets the output component
  60335. */
  60336. get output(): NodeMaterialConnectionPoint;
  60337. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60338. }
  60339. }
  60340. declare module BABYLON {
  60341. /**
  60342. * Block used to blend normals
  60343. */
  60344. export class NormalBlendBlock extends NodeMaterialBlock {
  60345. /**
  60346. * Creates a new NormalBlendBlock
  60347. * @param name defines the block name
  60348. */
  60349. constructor(name: string);
  60350. /**
  60351. * Gets the current class name
  60352. * @returns the class name
  60353. */
  60354. getClassName(): string;
  60355. /**
  60356. * Gets the first input component
  60357. */
  60358. get normalMap0(): NodeMaterialConnectionPoint;
  60359. /**
  60360. * Gets the second input component
  60361. */
  60362. get normalMap1(): NodeMaterialConnectionPoint;
  60363. /**
  60364. * Gets the output component
  60365. */
  60366. get output(): NodeMaterialConnectionPoint;
  60367. protected _buildBlock(state: NodeMaterialBuildState): this;
  60368. }
  60369. }
  60370. declare module BABYLON {
  60371. /**
  60372. * Block used to rotate a 2d vector by a given angle
  60373. */
  60374. export class Rotate2dBlock extends NodeMaterialBlock {
  60375. /**
  60376. * Creates a new Rotate2dBlock
  60377. * @param name defines the block name
  60378. */
  60379. constructor(name: string);
  60380. /**
  60381. * Gets the current class name
  60382. * @returns the class name
  60383. */
  60384. getClassName(): string;
  60385. /**
  60386. * Gets the input vector
  60387. */
  60388. get input(): NodeMaterialConnectionPoint;
  60389. /**
  60390. * Gets the input angle
  60391. */
  60392. get angle(): NodeMaterialConnectionPoint;
  60393. /**
  60394. * Gets the output component
  60395. */
  60396. get output(): NodeMaterialConnectionPoint;
  60397. autoConfigure(material: NodeMaterial): void;
  60398. protected _buildBlock(state: NodeMaterialBuildState): this;
  60399. }
  60400. }
  60401. declare module BABYLON {
  60402. /**
  60403. * Block used to get the reflected vector from a direction and a normal
  60404. */
  60405. export class ReflectBlock extends NodeMaterialBlock {
  60406. /**
  60407. * Creates a new ReflectBlock
  60408. * @param name defines the block name
  60409. */
  60410. constructor(name: string);
  60411. /**
  60412. * Gets the current class name
  60413. * @returns the class name
  60414. */
  60415. getClassName(): string;
  60416. /**
  60417. * Gets the incident component
  60418. */
  60419. get incident(): NodeMaterialConnectionPoint;
  60420. /**
  60421. * Gets the normal component
  60422. */
  60423. get normal(): NodeMaterialConnectionPoint;
  60424. /**
  60425. * Gets the output component
  60426. */
  60427. get output(): NodeMaterialConnectionPoint;
  60428. protected _buildBlock(state: NodeMaterialBuildState): this;
  60429. }
  60430. }
  60431. declare module BABYLON {
  60432. /**
  60433. * Block used to get the refracted vector from a direction and a normal
  60434. */
  60435. export class RefractBlock extends NodeMaterialBlock {
  60436. /**
  60437. * Creates a new RefractBlock
  60438. * @param name defines the block name
  60439. */
  60440. constructor(name: string);
  60441. /**
  60442. * Gets the current class name
  60443. * @returns the class name
  60444. */
  60445. getClassName(): string;
  60446. /**
  60447. * Gets the incident component
  60448. */
  60449. get incident(): NodeMaterialConnectionPoint;
  60450. /**
  60451. * Gets the normal component
  60452. */
  60453. get normal(): NodeMaterialConnectionPoint;
  60454. /**
  60455. * Gets the index of refraction component
  60456. */
  60457. get ior(): NodeMaterialConnectionPoint;
  60458. /**
  60459. * Gets the output component
  60460. */
  60461. get output(): NodeMaterialConnectionPoint;
  60462. protected _buildBlock(state: NodeMaterialBuildState): this;
  60463. }
  60464. }
  60465. declare module BABYLON {
  60466. /**
  60467. * Block used to desaturate a color
  60468. */
  60469. export class DesaturateBlock extends NodeMaterialBlock {
  60470. /**
  60471. * Creates a new DesaturateBlock
  60472. * @param name defines the block name
  60473. */
  60474. constructor(name: string);
  60475. /**
  60476. * Gets the current class name
  60477. * @returns the class name
  60478. */
  60479. getClassName(): string;
  60480. /**
  60481. * Gets the color operand input component
  60482. */
  60483. get color(): NodeMaterialConnectionPoint;
  60484. /**
  60485. * Gets the level operand input component
  60486. */
  60487. get level(): NodeMaterialConnectionPoint;
  60488. /**
  60489. * Gets the output component
  60490. */
  60491. get output(): NodeMaterialConnectionPoint;
  60492. protected _buildBlock(state: NodeMaterialBuildState): this;
  60493. }
  60494. }
  60495. declare module BABYLON {
  60496. /**
  60497. * Effect Render Options
  60498. */
  60499. export interface IEffectRendererOptions {
  60500. /**
  60501. * Defines the vertices positions.
  60502. */
  60503. positions?: number[];
  60504. /**
  60505. * Defines the indices.
  60506. */
  60507. indices?: number[];
  60508. }
  60509. /**
  60510. * Helper class to render one or more effects
  60511. */
  60512. export class EffectRenderer {
  60513. private engine;
  60514. private static _DefaultOptions;
  60515. private _vertexBuffers;
  60516. private _indexBuffer;
  60517. private _ringBufferIndex;
  60518. private _ringScreenBuffer;
  60519. private _fullscreenViewport;
  60520. private _getNextFrameBuffer;
  60521. /**
  60522. * Creates an effect renderer
  60523. * @param engine the engine to use for rendering
  60524. * @param options defines the options of the effect renderer
  60525. */
  60526. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60527. /**
  60528. * Sets the current viewport in normalized coordinates 0-1
  60529. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60530. */
  60531. setViewport(viewport?: Viewport): void;
  60532. /**
  60533. * Binds the embedded attributes buffer to the effect.
  60534. * @param effect Defines the effect to bind the attributes for
  60535. */
  60536. bindBuffers(effect: Effect): void;
  60537. /**
  60538. * Sets the current effect wrapper to use during draw.
  60539. * The effect needs to be ready before calling this api.
  60540. * This also sets the default full screen position attribute.
  60541. * @param effectWrapper Defines the effect to draw with
  60542. */
  60543. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60544. /**
  60545. * Draws a full screen quad.
  60546. */
  60547. draw(): void;
  60548. /**
  60549. * renders one or more effects to a specified texture
  60550. * @param effectWrappers list of effects to renderer
  60551. * @param outputTexture texture to draw to, if null it will render to the screen
  60552. */
  60553. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  60554. /**
  60555. * Disposes of the effect renderer
  60556. */
  60557. dispose(): void;
  60558. }
  60559. /**
  60560. * Options to create an EffectWrapper
  60561. */
  60562. interface EffectWrapperCreationOptions {
  60563. /**
  60564. * Engine to use to create the effect
  60565. */
  60566. engine: ThinEngine;
  60567. /**
  60568. * Fragment shader for the effect
  60569. */
  60570. fragmentShader: string;
  60571. /**
  60572. * Vertex shader for the effect
  60573. */
  60574. vertexShader?: string;
  60575. /**
  60576. * Attributes to use in the shader
  60577. */
  60578. attributeNames?: Array<string>;
  60579. /**
  60580. * Uniforms to use in the shader
  60581. */
  60582. uniformNames?: Array<string>;
  60583. /**
  60584. * Texture sampler names to use in the shader
  60585. */
  60586. samplerNames?: Array<string>;
  60587. /**
  60588. * The friendly name of the effect displayed in Spector.
  60589. */
  60590. name?: string;
  60591. }
  60592. /**
  60593. * Wraps an effect to be used for rendering
  60594. */
  60595. export class EffectWrapper {
  60596. /**
  60597. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60598. */
  60599. onApplyObservable: Observable<{}>;
  60600. /**
  60601. * The underlying effect
  60602. */
  60603. effect: Effect;
  60604. /**
  60605. * Creates an effect to be renderer
  60606. * @param creationOptions options to create the effect
  60607. */
  60608. constructor(creationOptions: EffectWrapperCreationOptions);
  60609. /**
  60610. * Disposes of the effect wrapper
  60611. */
  60612. dispose(): void;
  60613. }
  60614. }
  60615. declare module BABYLON {
  60616. /**
  60617. * Helper class to push actions to a pool of workers.
  60618. */
  60619. export class WorkerPool implements IDisposable {
  60620. private _workerInfos;
  60621. private _pendingActions;
  60622. /**
  60623. * Constructor
  60624. * @param workers Array of workers to use for actions
  60625. */
  60626. constructor(workers: Array<Worker>);
  60627. /**
  60628. * Terminates all workers and clears any pending actions.
  60629. */
  60630. dispose(): void;
  60631. /**
  60632. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60633. * pended until a worker has completed its action.
  60634. * @param action The action to perform. Call onComplete when the action is complete.
  60635. */
  60636. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60637. private _execute;
  60638. }
  60639. }
  60640. declare module BABYLON {
  60641. /**
  60642. * Configuration for Draco compression
  60643. */
  60644. export interface IDracoCompressionConfiguration {
  60645. /**
  60646. * Configuration for the decoder.
  60647. */
  60648. decoder: {
  60649. /**
  60650. * The url to the WebAssembly module.
  60651. */
  60652. wasmUrl?: string;
  60653. /**
  60654. * The url to the WebAssembly binary.
  60655. */
  60656. wasmBinaryUrl?: string;
  60657. /**
  60658. * The url to the fallback JavaScript module.
  60659. */
  60660. fallbackUrl?: string;
  60661. };
  60662. }
  60663. /**
  60664. * Draco compression (https://google.github.io/draco/)
  60665. *
  60666. * This class wraps the Draco module.
  60667. *
  60668. * **Encoder**
  60669. *
  60670. * The encoder is not currently implemented.
  60671. *
  60672. * **Decoder**
  60673. *
  60674. * 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.
  60675. *
  60676. * To update the configuration, use the following code:
  60677. * ```javascript
  60678. * DracoCompression.Configuration = {
  60679. * decoder: {
  60680. * wasmUrl: "<url to the WebAssembly library>",
  60681. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  60682. * fallbackUrl: "<url to the fallback JavaScript library>",
  60683. * }
  60684. * };
  60685. * ```
  60686. *
  60687. * 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.
  60688. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  60689. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  60690. *
  60691. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  60692. * ```javascript
  60693. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  60694. * ```
  60695. *
  60696. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  60697. */
  60698. export class DracoCompression implements IDisposable {
  60699. private _workerPoolPromise?;
  60700. private _decoderModulePromise?;
  60701. /**
  60702. * The configuration. Defaults to the following urls:
  60703. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  60704. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  60705. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  60706. */
  60707. static Configuration: IDracoCompressionConfiguration;
  60708. /**
  60709. * Returns true if the decoder configuration is available.
  60710. */
  60711. static get DecoderAvailable(): boolean;
  60712. /**
  60713. * Default number of workers to create when creating the draco compression object.
  60714. */
  60715. static DefaultNumWorkers: number;
  60716. private static GetDefaultNumWorkers;
  60717. private static _Default;
  60718. /**
  60719. * Default instance for the draco compression object.
  60720. */
  60721. static get Default(): DracoCompression;
  60722. /**
  60723. * Constructor
  60724. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60725. */
  60726. constructor(numWorkers?: number);
  60727. /**
  60728. * Stop all async operations and release resources.
  60729. */
  60730. dispose(): void;
  60731. /**
  60732. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  60733. * @returns a promise that resolves when ready
  60734. */
  60735. whenReadyAsync(): Promise<void>;
  60736. /**
  60737. * Decode Draco compressed mesh data to vertex data.
  60738. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  60739. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  60740. * @returns A promise that resolves with the decoded vertex data
  60741. */
  60742. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  60743. [kind: string]: number;
  60744. }): Promise<VertexData>;
  60745. }
  60746. }
  60747. declare module BABYLON {
  60748. /**
  60749. * Class for building Constructive Solid Geometry
  60750. */
  60751. export class CSG {
  60752. private polygons;
  60753. /**
  60754. * The world matrix
  60755. */
  60756. matrix: Matrix;
  60757. /**
  60758. * Stores the position
  60759. */
  60760. position: Vector3;
  60761. /**
  60762. * Stores the rotation
  60763. */
  60764. rotation: Vector3;
  60765. /**
  60766. * Stores the rotation quaternion
  60767. */
  60768. rotationQuaternion: Nullable<Quaternion>;
  60769. /**
  60770. * Stores the scaling vector
  60771. */
  60772. scaling: Vector3;
  60773. /**
  60774. * Convert the Mesh to CSG
  60775. * @param mesh The Mesh to convert to CSG
  60776. * @returns A new CSG from the Mesh
  60777. */
  60778. static FromMesh(mesh: Mesh): CSG;
  60779. /**
  60780. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  60781. * @param polygons Polygons used to construct a CSG solid
  60782. */
  60783. private static FromPolygons;
  60784. /**
  60785. * Clones, or makes a deep copy, of the CSG
  60786. * @returns A new CSG
  60787. */
  60788. clone(): CSG;
  60789. /**
  60790. * Unions this CSG with another CSG
  60791. * @param csg The CSG to union against this CSG
  60792. * @returns The unioned CSG
  60793. */
  60794. union(csg: CSG): CSG;
  60795. /**
  60796. * Unions this CSG with another CSG in place
  60797. * @param csg The CSG to union against this CSG
  60798. */
  60799. unionInPlace(csg: CSG): void;
  60800. /**
  60801. * Subtracts this CSG with another CSG
  60802. * @param csg The CSG to subtract against this CSG
  60803. * @returns A new CSG
  60804. */
  60805. subtract(csg: CSG): CSG;
  60806. /**
  60807. * Subtracts this CSG with another CSG in place
  60808. * @param csg The CSG to subtact against this CSG
  60809. */
  60810. subtractInPlace(csg: CSG): void;
  60811. /**
  60812. * Intersect this CSG with another CSG
  60813. * @param csg The CSG to intersect against this CSG
  60814. * @returns A new CSG
  60815. */
  60816. intersect(csg: CSG): CSG;
  60817. /**
  60818. * Intersects this CSG with another CSG in place
  60819. * @param csg The CSG to intersect against this CSG
  60820. */
  60821. intersectInPlace(csg: CSG): void;
  60822. /**
  60823. * Return a new CSG solid with solid and empty space switched. This solid is
  60824. * not modified.
  60825. * @returns A new CSG solid with solid and empty space switched
  60826. */
  60827. inverse(): CSG;
  60828. /**
  60829. * Inverses the CSG in place
  60830. */
  60831. inverseInPlace(): void;
  60832. /**
  60833. * This is used to keep meshes transformations so they can be restored
  60834. * when we build back a Babylon Mesh
  60835. * NB : All CSG operations are performed in world coordinates
  60836. * @param csg The CSG to copy the transform attributes from
  60837. * @returns This CSG
  60838. */
  60839. copyTransformAttributes(csg: CSG): CSG;
  60840. /**
  60841. * Build Raw mesh from CSG
  60842. * Coordinates here are in world space
  60843. * @param name The name of the mesh geometry
  60844. * @param scene The Scene
  60845. * @param keepSubMeshes Specifies if the submeshes should be kept
  60846. * @returns A new Mesh
  60847. */
  60848. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60849. /**
  60850. * Build Mesh from CSG taking material and transforms into account
  60851. * @param name The name of the Mesh
  60852. * @param material The material of the Mesh
  60853. * @param scene The Scene
  60854. * @param keepSubMeshes Specifies if submeshes should be kept
  60855. * @returns The new Mesh
  60856. */
  60857. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60858. }
  60859. }
  60860. declare module BABYLON {
  60861. /**
  60862. * Class used to create a trail following a mesh
  60863. */
  60864. export class TrailMesh extends Mesh {
  60865. private _generator;
  60866. private _autoStart;
  60867. private _running;
  60868. private _diameter;
  60869. private _length;
  60870. private _sectionPolygonPointsCount;
  60871. private _sectionVectors;
  60872. private _sectionNormalVectors;
  60873. private _beforeRenderObserver;
  60874. /**
  60875. * @constructor
  60876. * @param name The value used by scene.getMeshByName() to do a lookup.
  60877. * @param generator The mesh or transform node to generate a trail.
  60878. * @param scene The scene to add this mesh to.
  60879. * @param diameter Diameter of trailing mesh. Default is 1.
  60880. * @param length Length of trailing mesh. Default is 60.
  60881. * @param autoStart Automatically start trailing mesh. Default true.
  60882. */
  60883. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  60884. /**
  60885. * "TrailMesh"
  60886. * @returns "TrailMesh"
  60887. */
  60888. getClassName(): string;
  60889. private _createMesh;
  60890. /**
  60891. * Start trailing mesh.
  60892. */
  60893. start(): void;
  60894. /**
  60895. * Stop trailing mesh.
  60896. */
  60897. stop(): void;
  60898. /**
  60899. * Update trailing mesh geometry.
  60900. */
  60901. update(): void;
  60902. /**
  60903. * Returns a new TrailMesh object.
  60904. * @param name is a string, the name given to the new mesh
  60905. * @param newGenerator use new generator object for cloned trail mesh
  60906. * @returns a new mesh
  60907. */
  60908. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  60909. /**
  60910. * Serializes this trail mesh
  60911. * @param serializationObject object to write serialization to
  60912. */
  60913. serialize(serializationObject: any): void;
  60914. /**
  60915. * Parses a serialized trail mesh
  60916. * @param parsedMesh the serialized mesh
  60917. * @param scene the scene to create the trail mesh in
  60918. * @returns the created trail mesh
  60919. */
  60920. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  60921. }
  60922. }
  60923. declare module BABYLON {
  60924. /**
  60925. * Class containing static functions to help procedurally build meshes
  60926. */
  60927. export class TiledBoxBuilder {
  60928. /**
  60929. * Creates a box mesh
  60930. * 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)
  60931. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60932. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60933. * * 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
  60934. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60935. * @param name defines the name of the mesh
  60936. * @param options defines the options used to create the mesh
  60937. * @param scene defines the hosting scene
  60938. * @returns the box mesh
  60939. */
  60940. static CreateTiledBox(name: string, options: {
  60941. pattern?: number;
  60942. width?: number;
  60943. height?: number;
  60944. depth?: number;
  60945. tileSize?: number;
  60946. tileWidth?: number;
  60947. tileHeight?: number;
  60948. alignHorizontal?: number;
  60949. alignVertical?: number;
  60950. faceUV?: Vector4[];
  60951. faceColors?: Color4[];
  60952. sideOrientation?: number;
  60953. updatable?: boolean;
  60954. }, scene?: Nullable<Scene>): Mesh;
  60955. }
  60956. }
  60957. declare module BABYLON {
  60958. /**
  60959. * Class containing static functions to help procedurally build meshes
  60960. */
  60961. export class TorusKnotBuilder {
  60962. /**
  60963. * Creates a torus knot mesh
  60964. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60965. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60966. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60967. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60968. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60969. * * 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
  60970. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60971. * @param name defines the name of the mesh
  60972. * @param options defines the options used to create the mesh
  60973. * @param scene defines the hosting scene
  60974. * @returns the torus knot mesh
  60975. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60976. */
  60977. static CreateTorusKnot(name: string, options: {
  60978. radius?: number;
  60979. tube?: number;
  60980. radialSegments?: number;
  60981. tubularSegments?: number;
  60982. p?: number;
  60983. q?: number;
  60984. updatable?: boolean;
  60985. sideOrientation?: number;
  60986. frontUVs?: Vector4;
  60987. backUVs?: Vector4;
  60988. }, scene: any): Mesh;
  60989. }
  60990. }
  60991. declare module BABYLON {
  60992. /**
  60993. * Polygon
  60994. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  60995. */
  60996. export class Polygon {
  60997. /**
  60998. * Creates a rectangle
  60999. * @param xmin bottom X coord
  61000. * @param ymin bottom Y coord
  61001. * @param xmax top X coord
  61002. * @param ymax top Y coord
  61003. * @returns points that make the resulting rectation
  61004. */
  61005. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  61006. /**
  61007. * Creates a circle
  61008. * @param radius radius of circle
  61009. * @param cx scale in x
  61010. * @param cy scale in y
  61011. * @param numberOfSides number of sides that make up the circle
  61012. * @returns points that make the resulting circle
  61013. */
  61014. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  61015. /**
  61016. * Creates a polygon from input string
  61017. * @param input Input polygon data
  61018. * @returns the parsed points
  61019. */
  61020. static Parse(input: string): Vector2[];
  61021. /**
  61022. * Starts building a polygon from x and y coordinates
  61023. * @param x x coordinate
  61024. * @param y y coordinate
  61025. * @returns the started path2
  61026. */
  61027. static StartingAt(x: number, y: number): Path2;
  61028. }
  61029. /**
  61030. * Builds a polygon
  61031. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  61032. */
  61033. export class PolygonMeshBuilder {
  61034. private _points;
  61035. private _outlinepoints;
  61036. private _holes;
  61037. private _name;
  61038. private _scene;
  61039. private _epoints;
  61040. private _eholes;
  61041. private _addToepoint;
  61042. /**
  61043. * Babylon reference to the earcut plugin.
  61044. */
  61045. bjsEarcut: any;
  61046. /**
  61047. * Creates a PolygonMeshBuilder
  61048. * @param name name of the builder
  61049. * @param contours Path of the polygon
  61050. * @param scene scene to add to when creating the mesh
  61051. * @param earcutInjection can be used to inject your own earcut reference
  61052. */
  61053. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  61054. /**
  61055. * Adds a whole within the polygon
  61056. * @param hole Array of points defining the hole
  61057. * @returns this
  61058. */
  61059. addHole(hole: Vector2[]): PolygonMeshBuilder;
  61060. /**
  61061. * Creates the polygon
  61062. * @param updatable If the mesh should be updatable
  61063. * @param depth The depth of the mesh created
  61064. * @returns the created mesh
  61065. */
  61066. build(updatable?: boolean, depth?: number): Mesh;
  61067. /**
  61068. * Creates the polygon
  61069. * @param depth The depth of the mesh created
  61070. * @returns the created VertexData
  61071. */
  61072. buildVertexData(depth?: number): VertexData;
  61073. /**
  61074. * Adds a side to the polygon
  61075. * @param positions points that make the polygon
  61076. * @param normals normals of the polygon
  61077. * @param uvs uvs of the polygon
  61078. * @param indices indices of the polygon
  61079. * @param bounds bounds of the polygon
  61080. * @param points points of the polygon
  61081. * @param depth depth of the polygon
  61082. * @param flip flip of the polygon
  61083. */
  61084. private addSide;
  61085. }
  61086. }
  61087. declare module BABYLON {
  61088. /**
  61089. * Class containing static functions to help procedurally build meshes
  61090. */
  61091. export class PolygonBuilder {
  61092. /**
  61093. * Creates a polygon mesh
  61094. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61095. * * 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
  61096. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61098. * * 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)
  61099. * * Remember you can only change the shape positions, not their number when updating a polygon
  61100. * @param name defines the name of the mesh
  61101. * @param options defines the options used to create the mesh
  61102. * @param scene defines the hosting scene
  61103. * @param earcutInjection can be used to inject your own earcut reference
  61104. * @returns the polygon mesh
  61105. */
  61106. static CreatePolygon(name: string, options: {
  61107. shape: Vector3[];
  61108. holes?: Vector3[][];
  61109. depth?: number;
  61110. faceUV?: Vector4[];
  61111. faceColors?: Color4[];
  61112. updatable?: boolean;
  61113. sideOrientation?: number;
  61114. frontUVs?: Vector4;
  61115. backUVs?: Vector4;
  61116. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61117. /**
  61118. * Creates an extruded polygon mesh, with depth in the Y direction.
  61119. * * 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)
  61120. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61121. * @param name defines the name of the mesh
  61122. * @param options defines the options used to create the mesh
  61123. * @param scene defines the hosting scene
  61124. * @param earcutInjection can be used to inject your own earcut reference
  61125. * @returns the polygon mesh
  61126. */
  61127. static ExtrudePolygon(name: string, options: {
  61128. shape: Vector3[];
  61129. holes?: Vector3[][];
  61130. depth?: number;
  61131. faceUV?: Vector4[];
  61132. faceColors?: Color4[];
  61133. updatable?: boolean;
  61134. sideOrientation?: number;
  61135. frontUVs?: Vector4;
  61136. backUVs?: Vector4;
  61137. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61138. }
  61139. }
  61140. declare module BABYLON {
  61141. /**
  61142. * Class containing static functions to help procedurally build meshes
  61143. */
  61144. export class LatheBuilder {
  61145. /**
  61146. * Creates lathe mesh.
  61147. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61148. * * 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
  61149. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61150. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61151. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61152. * * 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
  61153. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61154. * * 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
  61155. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61156. * * 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
  61157. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61158. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61159. * @param name defines the name of the mesh
  61160. * @param options defines the options used to create the mesh
  61161. * @param scene defines the hosting scene
  61162. * @returns the lathe mesh
  61163. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61164. */
  61165. static CreateLathe(name: string, options: {
  61166. shape: Vector3[];
  61167. radius?: number;
  61168. tessellation?: number;
  61169. clip?: number;
  61170. arc?: number;
  61171. closed?: boolean;
  61172. updatable?: boolean;
  61173. sideOrientation?: number;
  61174. frontUVs?: Vector4;
  61175. backUVs?: Vector4;
  61176. cap?: number;
  61177. invertUV?: boolean;
  61178. }, scene?: Nullable<Scene>): Mesh;
  61179. }
  61180. }
  61181. declare module BABYLON {
  61182. /**
  61183. * Class containing static functions to help procedurally build meshes
  61184. */
  61185. export class TiledPlaneBuilder {
  61186. /**
  61187. * Creates a tiled plane mesh
  61188. * * The parameter `pattern` will, depending on value, do nothing or
  61189. * * * flip (reflect about central vertical) alternate tiles across and up
  61190. * * * flip every tile on alternate rows
  61191. * * * rotate (180 degs) alternate tiles across and up
  61192. * * * rotate every tile on alternate rows
  61193. * * * flip and rotate alternate tiles across and up
  61194. * * * flip and rotate every tile on alternate rows
  61195. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  61196. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  61197. * * 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
  61198. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61199. * * 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)
  61200. * * 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)
  61201. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61202. * @param name defines the name of the mesh
  61203. * @param options defines the options used to create the mesh
  61204. * @param scene defines the hosting scene
  61205. * @returns the box mesh
  61206. */
  61207. static CreateTiledPlane(name: string, options: {
  61208. pattern?: number;
  61209. tileSize?: number;
  61210. tileWidth?: number;
  61211. tileHeight?: number;
  61212. size?: number;
  61213. width?: number;
  61214. height?: number;
  61215. alignHorizontal?: number;
  61216. alignVertical?: number;
  61217. sideOrientation?: number;
  61218. frontUVs?: Vector4;
  61219. backUVs?: Vector4;
  61220. updatable?: boolean;
  61221. }, scene?: Nullable<Scene>): Mesh;
  61222. }
  61223. }
  61224. declare module BABYLON {
  61225. /**
  61226. * Class containing static functions to help procedurally build meshes
  61227. */
  61228. export class TubeBuilder {
  61229. /**
  61230. * Creates a tube mesh.
  61231. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61232. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61233. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61234. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61235. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61236. * * 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)
  61237. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61238. * * 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
  61239. * * 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
  61240. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61241. * * 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
  61242. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61244. * @param name defines the name of the mesh
  61245. * @param options defines the options used to create the mesh
  61246. * @param scene defines the hosting scene
  61247. * @returns the tube mesh
  61248. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61249. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61250. */
  61251. static CreateTube(name: string, options: {
  61252. path: Vector3[];
  61253. radius?: number;
  61254. tessellation?: number;
  61255. radiusFunction?: {
  61256. (i: number, distance: number): number;
  61257. };
  61258. cap?: number;
  61259. arc?: number;
  61260. updatable?: boolean;
  61261. sideOrientation?: number;
  61262. frontUVs?: Vector4;
  61263. backUVs?: Vector4;
  61264. instance?: Mesh;
  61265. invertUV?: boolean;
  61266. }, scene?: Nullable<Scene>): Mesh;
  61267. }
  61268. }
  61269. declare module BABYLON {
  61270. /**
  61271. * Class containing static functions to help procedurally build meshes
  61272. */
  61273. export class IcoSphereBuilder {
  61274. /**
  61275. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61276. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61277. * * 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`)
  61278. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61279. * * 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
  61280. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61281. * * 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
  61282. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61283. * @param name defines the name of the mesh
  61284. * @param options defines the options used to create the mesh
  61285. * @param scene defines the hosting scene
  61286. * @returns the icosahedron mesh
  61287. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61288. */
  61289. static CreateIcoSphere(name: string, options: {
  61290. radius?: number;
  61291. radiusX?: number;
  61292. radiusY?: number;
  61293. radiusZ?: number;
  61294. flat?: boolean;
  61295. subdivisions?: number;
  61296. sideOrientation?: number;
  61297. frontUVs?: Vector4;
  61298. backUVs?: Vector4;
  61299. updatable?: boolean;
  61300. }, scene?: Nullable<Scene>): Mesh;
  61301. }
  61302. }
  61303. declare module BABYLON {
  61304. /**
  61305. * Class containing static functions to help procedurally build meshes
  61306. */
  61307. export class DecalBuilder {
  61308. /**
  61309. * Creates a decal mesh.
  61310. * 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
  61311. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61312. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61313. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61314. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61315. * @param name defines the name of the mesh
  61316. * @param sourceMesh defines the mesh where the decal must be applied
  61317. * @param options defines the options used to create the mesh
  61318. * @param scene defines the hosting scene
  61319. * @returns the decal mesh
  61320. * @see https://doc.babylonjs.com/how_to/decals
  61321. */
  61322. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61323. position?: Vector3;
  61324. normal?: Vector3;
  61325. size?: Vector3;
  61326. angle?: number;
  61327. }): Mesh;
  61328. }
  61329. }
  61330. declare module BABYLON {
  61331. /**
  61332. * Class containing static functions to help procedurally build meshes
  61333. */
  61334. export class MeshBuilder {
  61335. /**
  61336. * Creates a box mesh
  61337. * * The parameter `size` sets the size (float) of each box side (default 1)
  61338. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  61339. * * 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)
  61340. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61341. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61342. * * 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
  61343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61344. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61345. * @param name defines the name of the mesh
  61346. * @param options defines the options used to create the mesh
  61347. * @param scene defines the hosting scene
  61348. * @returns the box mesh
  61349. */
  61350. static CreateBox(name: string, options: {
  61351. size?: number;
  61352. width?: number;
  61353. height?: number;
  61354. depth?: number;
  61355. faceUV?: Vector4[];
  61356. faceColors?: Color4[];
  61357. sideOrientation?: number;
  61358. frontUVs?: Vector4;
  61359. backUVs?: Vector4;
  61360. wrap?: boolean;
  61361. topBaseAt?: number;
  61362. bottomBaseAt?: number;
  61363. updatable?: boolean;
  61364. }, scene?: Nullable<Scene>): Mesh;
  61365. /**
  61366. * Creates a tiled box mesh
  61367. * * faceTiles sets the pattern, tile size and number of tiles for a face
  61368. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61369. * @param name defines the name of the mesh
  61370. * @param options defines the options used to create the mesh
  61371. * @param scene defines the hosting scene
  61372. * @returns the tiled box mesh
  61373. */
  61374. static CreateTiledBox(name: string, options: {
  61375. pattern?: number;
  61376. size?: number;
  61377. width?: number;
  61378. height?: number;
  61379. depth: number;
  61380. tileSize?: number;
  61381. tileWidth?: number;
  61382. tileHeight?: number;
  61383. faceUV?: Vector4[];
  61384. faceColors?: Color4[];
  61385. alignHorizontal?: number;
  61386. alignVertical?: number;
  61387. sideOrientation?: number;
  61388. updatable?: boolean;
  61389. }, scene?: Nullable<Scene>): Mesh;
  61390. /**
  61391. * Creates a sphere mesh
  61392. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  61393. * * 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`)
  61394. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  61395. * * 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
  61396. * * 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)
  61397. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61398. * * 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
  61399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61400. * @param name defines the name of the mesh
  61401. * @param options defines the options used to create the mesh
  61402. * @param scene defines the hosting scene
  61403. * @returns the sphere mesh
  61404. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  61405. */
  61406. static CreateSphere(name: string, options: {
  61407. segments?: number;
  61408. diameter?: number;
  61409. diameterX?: number;
  61410. diameterY?: number;
  61411. diameterZ?: number;
  61412. arc?: number;
  61413. slice?: number;
  61414. sideOrientation?: number;
  61415. frontUVs?: Vector4;
  61416. backUVs?: Vector4;
  61417. updatable?: boolean;
  61418. }, scene?: Nullable<Scene>): Mesh;
  61419. /**
  61420. * Creates a plane polygonal mesh. By default, this is a disc
  61421. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61422. * * 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
  61423. * * 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
  61424. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61425. * * 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
  61426. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61427. * @param name defines the name of the mesh
  61428. * @param options defines the options used to create the mesh
  61429. * @param scene defines the hosting scene
  61430. * @returns the plane polygonal mesh
  61431. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61432. */
  61433. static CreateDisc(name: string, options: {
  61434. radius?: number;
  61435. tessellation?: number;
  61436. arc?: number;
  61437. updatable?: boolean;
  61438. sideOrientation?: number;
  61439. frontUVs?: Vector4;
  61440. backUVs?: Vector4;
  61441. }, scene?: Nullable<Scene>): Mesh;
  61442. /**
  61443. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61444. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61445. * * 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`)
  61446. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61447. * * 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
  61448. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61449. * * 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
  61450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61451. * @param name defines the name of the mesh
  61452. * @param options defines the options used to create the mesh
  61453. * @param scene defines the hosting scene
  61454. * @returns the icosahedron mesh
  61455. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61456. */
  61457. static CreateIcoSphere(name: string, options: {
  61458. radius?: number;
  61459. radiusX?: number;
  61460. radiusY?: number;
  61461. radiusZ?: number;
  61462. flat?: boolean;
  61463. subdivisions?: number;
  61464. sideOrientation?: number;
  61465. frontUVs?: Vector4;
  61466. backUVs?: Vector4;
  61467. updatable?: boolean;
  61468. }, scene?: Nullable<Scene>): Mesh;
  61469. /**
  61470. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61471. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61472. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61473. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61474. * * 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
  61475. * * 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
  61476. * * 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
  61477. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61478. * * 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
  61479. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61480. * * 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
  61481. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61482. * * 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
  61483. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61484. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61485. * @param name defines the name of the mesh
  61486. * @param options defines the options used to create the mesh
  61487. * @param scene defines the hosting scene
  61488. * @returns the ribbon mesh
  61489. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61490. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61491. */
  61492. static CreateRibbon(name: string, options: {
  61493. pathArray: Vector3[][];
  61494. closeArray?: boolean;
  61495. closePath?: boolean;
  61496. offset?: number;
  61497. updatable?: boolean;
  61498. sideOrientation?: number;
  61499. frontUVs?: Vector4;
  61500. backUVs?: Vector4;
  61501. instance?: Mesh;
  61502. invertUV?: boolean;
  61503. uvs?: Vector2[];
  61504. colors?: Color4[];
  61505. }, scene?: Nullable<Scene>): Mesh;
  61506. /**
  61507. * Creates a cylinder or a cone mesh
  61508. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61509. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61510. * * 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.
  61511. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61512. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61513. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61514. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61515. * * 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).
  61516. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61517. * * 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).
  61518. * * 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
  61519. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61520. * * 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
  61521. * * 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.
  61522. * * If `enclose` is false, a ring surface is one element.
  61523. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61524. * * 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
  61525. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61526. * * 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
  61527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61528. * @param name defines the name of the mesh
  61529. * @param options defines the options used to create the mesh
  61530. * @param scene defines the hosting scene
  61531. * @returns the cylinder mesh
  61532. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61533. */
  61534. static CreateCylinder(name: string, options: {
  61535. height?: number;
  61536. diameterTop?: number;
  61537. diameterBottom?: number;
  61538. diameter?: number;
  61539. tessellation?: number;
  61540. subdivisions?: number;
  61541. arc?: number;
  61542. faceColors?: Color4[];
  61543. faceUV?: Vector4[];
  61544. updatable?: boolean;
  61545. hasRings?: boolean;
  61546. enclose?: boolean;
  61547. cap?: number;
  61548. sideOrientation?: number;
  61549. frontUVs?: Vector4;
  61550. backUVs?: Vector4;
  61551. }, scene?: Nullable<Scene>): Mesh;
  61552. /**
  61553. * Creates a torus mesh
  61554. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61555. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61556. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61557. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61558. * * 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
  61559. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61560. * @param name defines the name of the mesh
  61561. * @param options defines the options used to create the mesh
  61562. * @param scene defines the hosting scene
  61563. * @returns the torus mesh
  61564. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61565. */
  61566. static CreateTorus(name: string, options: {
  61567. diameter?: number;
  61568. thickness?: number;
  61569. tessellation?: number;
  61570. updatable?: boolean;
  61571. sideOrientation?: number;
  61572. frontUVs?: Vector4;
  61573. backUVs?: Vector4;
  61574. }, scene?: Nullable<Scene>): Mesh;
  61575. /**
  61576. * Creates a torus knot mesh
  61577. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61578. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61579. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61580. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61581. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61582. * * 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
  61583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61584. * @param name defines the name of the mesh
  61585. * @param options defines the options used to create the mesh
  61586. * @param scene defines the hosting scene
  61587. * @returns the torus knot mesh
  61588. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61589. */
  61590. static CreateTorusKnot(name: string, options: {
  61591. radius?: number;
  61592. tube?: number;
  61593. radialSegments?: number;
  61594. tubularSegments?: number;
  61595. p?: number;
  61596. q?: number;
  61597. updatable?: boolean;
  61598. sideOrientation?: number;
  61599. frontUVs?: Vector4;
  61600. backUVs?: Vector4;
  61601. }, scene?: Nullable<Scene>): Mesh;
  61602. /**
  61603. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61604. * * 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
  61605. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61606. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61607. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61608. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61609. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61610. * * 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
  61611. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61613. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61614. * @param name defines the name of the new line system
  61615. * @param options defines the options used to create the line system
  61616. * @param scene defines the hosting scene
  61617. * @returns a new line system mesh
  61618. */
  61619. static CreateLineSystem(name: string, options: {
  61620. lines: Vector3[][];
  61621. updatable?: boolean;
  61622. instance?: Nullable<LinesMesh>;
  61623. colors?: Nullable<Color4[][]>;
  61624. useVertexAlpha?: boolean;
  61625. }, scene: Nullable<Scene>): LinesMesh;
  61626. /**
  61627. * Creates a line mesh
  61628. * 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
  61629. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61630. * * The parameter `points` is an array successive Vector3
  61631. * * 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
  61632. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61633. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61634. * * When updating an instance, remember that only point positions can change, not the number of points
  61635. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61636. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  61637. * @param name defines the name of the new line system
  61638. * @param options defines the options used to create the line system
  61639. * @param scene defines the hosting scene
  61640. * @returns a new line mesh
  61641. */
  61642. static CreateLines(name: string, options: {
  61643. points: Vector3[];
  61644. updatable?: boolean;
  61645. instance?: Nullable<LinesMesh>;
  61646. colors?: Color4[];
  61647. useVertexAlpha?: boolean;
  61648. }, scene?: Nullable<Scene>): LinesMesh;
  61649. /**
  61650. * Creates a dashed line mesh
  61651. * * 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
  61652. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61653. * * The parameter `points` is an array successive Vector3
  61654. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  61655. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  61656. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  61657. * * 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
  61658. * * When updating an instance, remember that only point positions can change, not the number of points
  61659. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61660. * @param name defines the name of the mesh
  61661. * @param options defines the options used to create the mesh
  61662. * @param scene defines the hosting scene
  61663. * @returns the dashed line mesh
  61664. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  61665. */
  61666. static CreateDashedLines(name: string, options: {
  61667. points: Vector3[];
  61668. dashSize?: number;
  61669. gapSize?: number;
  61670. dashNb?: number;
  61671. updatable?: boolean;
  61672. instance?: LinesMesh;
  61673. }, scene?: Nullable<Scene>): LinesMesh;
  61674. /**
  61675. * 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.
  61676. * * 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.
  61677. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61678. * * 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.
  61679. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61680. * * 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
  61681. * * 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
  61682. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61683. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61684. * * 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
  61685. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61687. * @param name defines the name of the mesh
  61688. * @param options defines the options used to create the mesh
  61689. * @param scene defines the hosting scene
  61690. * @returns the extruded shape mesh
  61691. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61692. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61693. */
  61694. static ExtrudeShape(name: string, options: {
  61695. shape: Vector3[];
  61696. path: Vector3[];
  61697. scale?: number;
  61698. rotation?: number;
  61699. cap?: number;
  61700. updatable?: boolean;
  61701. sideOrientation?: number;
  61702. frontUVs?: Vector4;
  61703. backUVs?: Vector4;
  61704. instance?: Mesh;
  61705. invertUV?: boolean;
  61706. }, scene?: Nullable<Scene>): Mesh;
  61707. /**
  61708. * Creates an custom extruded shape mesh.
  61709. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61710. * * 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.
  61711. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61712. * * 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
  61713. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61714. * * 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
  61715. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61716. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61717. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61718. * * 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
  61719. * * 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
  61720. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61721. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61722. * * 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
  61723. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61725. * @param name defines the name of the mesh
  61726. * @param options defines the options used to create the mesh
  61727. * @param scene defines the hosting scene
  61728. * @returns the custom extruded shape mesh
  61729. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61730. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61731. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61732. */
  61733. static ExtrudeShapeCustom(name: string, options: {
  61734. shape: Vector3[];
  61735. path: Vector3[];
  61736. scaleFunction?: any;
  61737. rotationFunction?: any;
  61738. ribbonCloseArray?: boolean;
  61739. ribbonClosePath?: boolean;
  61740. cap?: number;
  61741. updatable?: boolean;
  61742. sideOrientation?: number;
  61743. frontUVs?: Vector4;
  61744. backUVs?: Vector4;
  61745. instance?: Mesh;
  61746. invertUV?: boolean;
  61747. }, scene?: Nullable<Scene>): Mesh;
  61748. /**
  61749. * Creates lathe mesh.
  61750. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61751. * * 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
  61752. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61753. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61754. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61755. * * 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
  61756. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61757. * * 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
  61758. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61759. * * 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
  61760. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61761. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61762. * @param name defines the name of the mesh
  61763. * @param options defines the options used to create the mesh
  61764. * @param scene defines the hosting scene
  61765. * @returns the lathe mesh
  61766. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61767. */
  61768. static CreateLathe(name: string, options: {
  61769. shape: Vector3[];
  61770. radius?: number;
  61771. tessellation?: number;
  61772. clip?: number;
  61773. arc?: number;
  61774. closed?: boolean;
  61775. updatable?: boolean;
  61776. sideOrientation?: number;
  61777. frontUVs?: Vector4;
  61778. backUVs?: Vector4;
  61779. cap?: number;
  61780. invertUV?: boolean;
  61781. }, scene?: Nullable<Scene>): Mesh;
  61782. /**
  61783. * Creates a tiled plane mesh
  61784. * * You can set a limited pattern arrangement with the tiles
  61785. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61786. * * 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
  61787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61788. * @param name defines the name of the mesh
  61789. * @param options defines the options used to create the mesh
  61790. * @param scene defines the hosting scene
  61791. * @returns the plane mesh
  61792. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61793. */
  61794. static CreateTiledPlane(name: string, options: {
  61795. pattern?: number;
  61796. tileSize?: number;
  61797. tileWidth?: number;
  61798. tileHeight?: number;
  61799. size?: number;
  61800. width?: number;
  61801. height?: number;
  61802. alignHorizontal?: number;
  61803. alignVertical?: number;
  61804. sideOrientation?: number;
  61805. frontUVs?: Vector4;
  61806. backUVs?: Vector4;
  61807. updatable?: boolean;
  61808. }, scene?: Nullable<Scene>): Mesh;
  61809. /**
  61810. * Creates a plane mesh
  61811. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  61812. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  61813. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  61814. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61815. * * 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
  61816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61817. * @param name defines the name of the mesh
  61818. * @param options defines the options used to create the mesh
  61819. * @param scene defines the hosting scene
  61820. * @returns the plane mesh
  61821. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61822. */
  61823. static CreatePlane(name: string, options: {
  61824. size?: number;
  61825. width?: number;
  61826. height?: number;
  61827. sideOrientation?: number;
  61828. frontUVs?: Vector4;
  61829. backUVs?: Vector4;
  61830. updatable?: boolean;
  61831. sourcePlane?: Plane;
  61832. }, scene?: Nullable<Scene>): Mesh;
  61833. /**
  61834. * Creates a ground mesh
  61835. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  61836. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  61837. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61838. * @param name defines the name of the mesh
  61839. * @param options defines the options used to create the mesh
  61840. * @param scene defines the hosting scene
  61841. * @returns the ground mesh
  61842. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  61843. */
  61844. static CreateGround(name: string, options: {
  61845. width?: number;
  61846. height?: number;
  61847. subdivisions?: number;
  61848. subdivisionsX?: number;
  61849. subdivisionsY?: number;
  61850. updatable?: boolean;
  61851. }, scene?: Nullable<Scene>): Mesh;
  61852. /**
  61853. * Creates a tiled ground mesh
  61854. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  61855. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  61856. * * 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
  61857. * * 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
  61858. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61859. * @param name defines the name of the mesh
  61860. * @param options defines the options used to create the mesh
  61861. * @param scene defines the hosting scene
  61862. * @returns the tiled ground mesh
  61863. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  61864. */
  61865. static CreateTiledGround(name: string, options: {
  61866. xmin: number;
  61867. zmin: number;
  61868. xmax: number;
  61869. zmax: number;
  61870. subdivisions?: {
  61871. w: number;
  61872. h: number;
  61873. };
  61874. precision?: {
  61875. w: number;
  61876. h: number;
  61877. };
  61878. updatable?: boolean;
  61879. }, scene?: Nullable<Scene>): Mesh;
  61880. /**
  61881. * Creates a ground mesh from a height map
  61882. * * The parameter `url` sets the URL of the height map image resource.
  61883. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  61884. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  61885. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  61886. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  61887. * * 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.
  61888. * * 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).
  61889. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  61890. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61891. * @param name defines the name of the mesh
  61892. * @param url defines the url to the height map
  61893. * @param options defines the options used to create the mesh
  61894. * @param scene defines the hosting scene
  61895. * @returns the ground mesh
  61896. * @see https://doc.babylonjs.com/babylon101/height_map
  61897. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  61898. */
  61899. static CreateGroundFromHeightMap(name: string, url: string, options: {
  61900. width?: number;
  61901. height?: number;
  61902. subdivisions?: number;
  61903. minHeight?: number;
  61904. maxHeight?: number;
  61905. colorFilter?: Color3;
  61906. alphaFilter?: number;
  61907. updatable?: boolean;
  61908. onReady?: (mesh: GroundMesh) => void;
  61909. }, scene?: Nullable<Scene>): GroundMesh;
  61910. /**
  61911. * Creates a polygon mesh
  61912. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61913. * * 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
  61914. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61915. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61916. * * 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)
  61917. * * Remember you can only change the shape positions, not their number when updating a polygon
  61918. * @param name defines the name of the mesh
  61919. * @param options defines the options used to create the mesh
  61920. * @param scene defines the hosting scene
  61921. * @param earcutInjection can be used to inject your own earcut reference
  61922. * @returns the polygon mesh
  61923. */
  61924. static CreatePolygon(name: string, options: {
  61925. shape: Vector3[];
  61926. holes?: Vector3[][];
  61927. depth?: number;
  61928. faceUV?: Vector4[];
  61929. faceColors?: Color4[];
  61930. updatable?: boolean;
  61931. sideOrientation?: number;
  61932. frontUVs?: Vector4;
  61933. backUVs?: Vector4;
  61934. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61935. /**
  61936. * Creates an extruded polygon mesh, with depth in the Y direction.
  61937. * * 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)
  61938. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61939. * @param name defines the name of the mesh
  61940. * @param options defines the options used to create the mesh
  61941. * @param scene defines the hosting scene
  61942. * @param earcutInjection can be used to inject your own earcut reference
  61943. * @returns the polygon mesh
  61944. */
  61945. static ExtrudePolygon(name: string, options: {
  61946. shape: Vector3[];
  61947. holes?: Vector3[][];
  61948. depth?: number;
  61949. faceUV?: Vector4[];
  61950. faceColors?: Color4[];
  61951. updatable?: boolean;
  61952. sideOrientation?: number;
  61953. frontUVs?: Vector4;
  61954. backUVs?: Vector4;
  61955. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61956. /**
  61957. * Creates a tube mesh.
  61958. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61959. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61960. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61961. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61962. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61963. * * 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)
  61964. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61965. * * 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
  61966. * * 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
  61967. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61968. * * 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
  61969. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61970. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61971. * @param name defines the name of the mesh
  61972. * @param options defines the options used to create the mesh
  61973. * @param scene defines the hosting scene
  61974. * @returns the tube mesh
  61975. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61976. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61977. */
  61978. static CreateTube(name: string, options: {
  61979. path: Vector3[];
  61980. radius?: number;
  61981. tessellation?: number;
  61982. radiusFunction?: {
  61983. (i: number, distance: number): number;
  61984. };
  61985. cap?: number;
  61986. arc?: number;
  61987. updatable?: boolean;
  61988. sideOrientation?: number;
  61989. frontUVs?: Vector4;
  61990. backUVs?: Vector4;
  61991. instance?: Mesh;
  61992. invertUV?: boolean;
  61993. }, scene?: Nullable<Scene>): Mesh;
  61994. /**
  61995. * Creates a polyhedron mesh
  61996. * * 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
  61997. * * The parameter `size` (positive float, default 1) sets the polygon size
  61998. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  61999. * * 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`
  62000. * * 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
  62001. * * 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)`)
  62002. * * 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
  62003. * * 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
  62004. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62005. * * 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
  62006. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62007. * @param name defines the name of the mesh
  62008. * @param options defines the options used to create the mesh
  62009. * @param scene defines the hosting scene
  62010. * @returns the polyhedron mesh
  62011. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  62012. */
  62013. static CreatePolyhedron(name: string, options: {
  62014. type?: number;
  62015. size?: number;
  62016. sizeX?: number;
  62017. sizeY?: number;
  62018. sizeZ?: number;
  62019. custom?: any;
  62020. faceUV?: Vector4[];
  62021. faceColors?: Color4[];
  62022. flat?: boolean;
  62023. updatable?: boolean;
  62024. sideOrientation?: number;
  62025. frontUVs?: Vector4;
  62026. backUVs?: Vector4;
  62027. }, scene?: Nullable<Scene>): Mesh;
  62028. /**
  62029. * Creates a decal mesh.
  62030. * 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
  62031. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  62032. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  62033. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  62034. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  62035. * @param name defines the name of the mesh
  62036. * @param sourceMesh defines the mesh where the decal must be applied
  62037. * @param options defines the options used to create the mesh
  62038. * @param scene defines the hosting scene
  62039. * @returns the decal mesh
  62040. * @see https://doc.babylonjs.com/how_to/decals
  62041. */
  62042. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  62043. position?: Vector3;
  62044. normal?: Vector3;
  62045. size?: Vector3;
  62046. angle?: number;
  62047. }): Mesh;
  62048. }
  62049. }
  62050. declare module BABYLON {
  62051. /**
  62052. * A simplifier interface for future simplification implementations
  62053. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62054. */
  62055. export interface ISimplifier {
  62056. /**
  62057. * Simplification of a given mesh according to the given settings.
  62058. * Since this requires computation, it is assumed that the function runs async.
  62059. * @param settings The settings of the simplification, including quality and distance
  62060. * @param successCallback A callback that will be called after the mesh was simplified.
  62061. * @param errorCallback in case of an error, this callback will be called. optional.
  62062. */
  62063. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  62064. }
  62065. /**
  62066. * Expected simplification settings.
  62067. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  62068. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62069. */
  62070. export interface ISimplificationSettings {
  62071. /**
  62072. * Gets or sets the expected quality
  62073. */
  62074. quality: number;
  62075. /**
  62076. * Gets or sets the distance when this optimized version should be used
  62077. */
  62078. distance: number;
  62079. /**
  62080. * Gets an already optimized mesh
  62081. */
  62082. optimizeMesh?: boolean;
  62083. }
  62084. /**
  62085. * Class used to specify simplification options
  62086. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62087. */
  62088. export class SimplificationSettings implements ISimplificationSettings {
  62089. /** expected quality */
  62090. quality: number;
  62091. /** distance when this optimized version should be used */
  62092. distance: number;
  62093. /** already optimized mesh */
  62094. optimizeMesh?: boolean | undefined;
  62095. /**
  62096. * Creates a SimplificationSettings
  62097. * @param quality expected quality
  62098. * @param distance distance when this optimized version should be used
  62099. * @param optimizeMesh already optimized mesh
  62100. */
  62101. constructor(
  62102. /** expected quality */
  62103. quality: number,
  62104. /** distance when this optimized version should be used */
  62105. distance: number,
  62106. /** already optimized mesh */
  62107. optimizeMesh?: boolean | undefined);
  62108. }
  62109. /**
  62110. * Interface used to define a simplification task
  62111. */
  62112. export interface ISimplificationTask {
  62113. /**
  62114. * Array of settings
  62115. */
  62116. settings: Array<ISimplificationSettings>;
  62117. /**
  62118. * Simplification type
  62119. */
  62120. simplificationType: SimplificationType;
  62121. /**
  62122. * Mesh to simplify
  62123. */
  62124. mesh: Mesh;
  62125. /**
  62126. * Callback called on success
  62127. */
  62128. successCallback?: () => void;
  62129. /**
  62130. * Defines if parallel processing can be used
  62131. */
  62132. parallelProcessing: boolean;
  62133. }
  62134. /**
  62135. * Queue used to order the simplification tasks
  62136. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62137. */
  62138. export class SimplificationQueue {
  62139. private _simplificationArray;
  62140. /**
  62141. * Gets a boolean indicating that the process is still running
  62142. */
  62143. running: boolean;
  62144. /**
  62145. * Creates a new queue
  62146. */
  62147. constructor();
  62148. /**
  62149. * Adds a new simplification task
  62150. * @param task defines a task to add
  62151. */
  62152. addTask(task: ISimplificationTask): void;
  62153. /**
  62154. * Execute next task
  62155. */
  62156. executeNext(): void;
  62157. /**
  62158. * Execute a simplification task
  62159. * @param task defines the task to run
  62160. */
  62161. runSimplification(task: ISimplificationTask): void;
  62162. private getSimplifier;
  62163. }
  62164. /**
  62165. * The implemented types of simplification
  62166. * At the moment only Quadratic Error Decimation is implemented
  62167. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62168. */
  62169. export enum SimplificationType {
  62170. /** Quadratic error decimation */
  62171. QUADRATIC = 0
  62172. }
  62173. /**
  62174. * An implementation of the Quadratic Error simplification algorithm.
  62175. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  62176. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  62177. * @author RaananW
  62178. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62179. */
  62180. export class QuadraticErrorSimplification implements ISimplifier {
  62181. private _mesh;
  62182. private triangles;
  62183. private vertices;
  62184. private references;
  62185. private _reconstructedMesh;
  62186. /** Gets or sets the number pf sync interations */
  62187. syncIterations: number;
  62188. /** Gets or sets the aggressiveness of the simplifier */
  62189. aggressiveness: number;
  62190. /** Gets or sets the number of allowed iterations for decimation */
  62191. decimationIterations: number;
  62192. /** Gets or sets the espilon to use for bounding box computation */
  62193. boundingBoxEpsilon: number;
  62194. /**
  62195. * Creates a new QuadraticErrorSimplification
  62196. * @param _mesh defines the target mesh
  62197. */
  62198. constructor(_mesh: Mesh);
  62199. /**
  62200. * Simplification of a given mesh according to the given settings.
  62201. * Since this requires computation, it is assumed that the function runs async.
  62202. * @param settings The settings of the simplification, including quality and distance
  62203. * @param successCallback A callback that will be called after the mesh was simplified.
  62204. */
  62205. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  62206. private runDecimation;
  62207. private initWithMesh;
  62208. private init;
  62209. private reconstructMesh;
  62210. private initDecimatedMesh;
  62211. private isFlipped;
  62212. private updateTriangles;
  62213. private identifyBorder;
  62214. private updateMesh;
  62215. private vertexError;
  62216. private calculateError;
  62217. }
  62218. }
  62219. declare module BABYLON {
  62220. interface Scene {
  62221. /** @hidden (Backing field) */
  62222. _simplificationQueue: SimplificationQueue;
  62223. /**
  62224. * Gets or sets the simplification queue attached to the scene
  62225. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62226. */
  62227. simplificationQueue: SimplificationQueue;
  62228. }
  62229. interface Mesh {
  62230. /**
  62231. * Simplify the mesh according to the given array of settings.
  62232. * Function will return immediately and will simplify async
  62233. * @param settings a collection of simplification settings
  62234. * @param parallelProcessing should all levels calculate parallel or one after the other
  62235. * @param simplificationType the type of simplification to run
  62236. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  62237. * @returns the current mesh
  62238. */
  62239. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  62240. }
  62241. /**
  62242. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  62243. * created in a scene
  62244. */
  62245. export class SimplicationQueueSceneComponent implements ISceneComponent {
  62246. /**
  62247. * The component name helpfull to identify the component in the list of scene components.
  62248. */
  62249. readonly name: string;
  62250. /**
  62251. * The scene the component belongs to.
  62252. */
  62253. scene: Scene;
  62254. /**
  62255. * Creates a new instance of the component for the given scene
  62256. * @param scene Defines the scene to register the component in
  62257. */
  62258. constructor(scene: Scene);
  62259. /**
  62260. * Registers the component in a given scene
  62261. */
  62262. register(): void;
  62263. /**
  62264. * Rebuilds the elements related to this component in case of
  62265. * context lost for instance.
  62266. */
  62267. rebuild(): void;
  62268. /**
  62269. * Disposes the component and the associated ressources
  62270. */
  62271. dispose(): void;
  62272. private _beforeCameraUpdate;
  62273. }
  62274. }
  62275. declare module BABYLON {
  62276. /**
  62277. * Navigation plugin interface to add navigation constrained by a navigation mesh
  62278. */
  62279. export interface INavigationEnginePlugin {
  62280. /**
  62281. * plugin name
  62282. */
  62283. name: string;
  62284. /**
  62285. * Creates a navigation mesh
  62286. * @param meshes array of all the geometry used to compute the navigatio mesh
  62287. * @param parameters bunch of parameters used to filter geometry
  62288. */
  62289. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62290. /**
  62291. * Create a navigation mesh debug mesh
  62292. * @param scene is where the mesh will be added
  62293. * @returns debug display mesh
  62294. */
  62295. createDebugNavMesh(scene: Scene): Mesh;
  62296. /**
  62297. * Get a navigation mesh constrained position, closest to the parameter position
  62298. * @param position world position
  62299. * @returns the closest point to position constrained by the navigation mesh
  62300. */
  62301. getClosestPoint(position: Vector3): Vector3;
  62302. /**
  62303. * Get a navigation mesh constrained position, closest to the parameter position
  62304. * @param position world position
  62305. * @param result output the closest point to position constrained by the navigation mesh
  62306. */
  62307. getClosestPointToRef(position: Vector3, result: Vector3): void;
  62308. /**
  62309. * Get a navigation mesh constrained position, within a particular radius
  62310. * @param position world position
  62311. * @param maxRadius the maximum distance to the constrained world position
  62312. * @returns the closest point to position constrained by the navigation mesh
  62313. */
  62314. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62315. /**
  62316. * Get a navigation mesh constrained position, within a particular radius
  62317. * @param position world position
  62318. * @param maxRadius the maximum distance to the constrained world position
  62319. * @param result output the closest point to position constrained by the navigation mesh
  62320. */
  62321. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  62322. /**
  62323. * Compute the final position from a segment made of destination-position
  62324. * @param position world position
  62325. * @param destination world position
  62326. * @returns the resulting point along the navmesh
  62327. */
  62328. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62329. /**
  62330. * Compute the final position from a segment made of destination-position
  62331. * @param position world position
  62332. * @param destination world position
  62333. * @param result output the resulting point along the navmesh
  62334. */
  62335. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  62336. /**
  62337. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62338. * @param start world position
  62339. * @param end world position
  62340. * @returns array containing world position composing the path
  62341. */
  62342. computePath(start: Vector3, end: Vector3): Vector3[];
  62343. /**
  62344. * If this plugin is supported
  62345. * @returns true if plugin is supported
  62346. */
  62347. isSupported(): boolean;
  62348. /**
  62349. * Create a new Crowd so you can add agents
  62350. * @param maxAgents the maximum agent count in the crowd
  62351. * @param maxAgentRadius the maximum radius an agent can have
  62352. * @param scene to attach the crowd to
  62353. * @returns the crowd you can add agents to
  62354. */
  62355. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62356. /**
  62357. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62358. * The queries will try to find a solution within those bounds
  62359. * default is (1,1,1)
  62360. * @param extent x,y,z value that define the extent around the queries point of reference
  62361. */
  62362. setDefaultQueryExtent(extent: Vector3): void;
  62363. /**
  62364. * Get the Bounding box extent specified by setDefaultQueryExtent
  62365. * @returns the box extent values
  62366. */
  62367. getDefaultQueryExtent(): Vector3;
  62368. /**
  62369. * build the navmesh from a previously saved state using getNavmeshData
  62370. * @param data the Uint8Array returned by getNavmeshData
  62371. */
  62372. buildFromNavmeshData(data: Uint8Array): void;
  62373. /**
  62374. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  62375. * @returns data the Uint8Array that can be saved and reused
  62376. */
  62377. getNavmeshData(): Uint8Array;
  62378. /**
  62379. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62380. * @param result output the box extent values
  62381. */
  62382. getDefaultQueryExtentToRef(result: Vector3): void;
  62383. /**
  62384. * Release all resources
  62385. */
  62386. dispose(): void;
  62387. }
  62388. /**
  62389. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  62390. */
  62391. export interface ICrowd {
  62392. /**
  62393. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62394. * You can attach anything to that node. The node position is updated in the scene update tick.
  62395. * @param pos world position that will be constrained by the navigation mesh
  62396. * @param parameters agent parameters
  62397. * @param transform hooked to the agent that will be update by the scene
  62398. * @returns agent index
  62399. */
  62400. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62401. /**
  62402. * Returns the agent position in world space
  62403. * @param index agent index returned by addAgent
  62404. * @returns world space position
  62405. */
  62406. getAgentPosition(index: number): Vector3;
  62407. /**
  62408. * Gets the agent position result in world space
  62409. * @param index agent index returned by addAgent
  62410. * @param result output world space position
  62411. */
  62412. getAgentPositionToRef(index: number, result: Vector3): void;
  62413. /**
  62414. * Gets the agent velocity in world space
  62415. * @param index agent index returned by addAgent
  62416. * @returns world space velocity
  62417. */
  62418. getAgentVelocity(index: number): Vector3;
  62419. /**
  62420. * Gets the agent velocity result in world space
  62421. * @param index agent index returned by addAgent
  62422. * @param result output world space velocity
  62423. */
  62424. getAgentVelocityToRef(index: number, result: Vector3): void;
  62425. /**
  62426. * remove a particular agent previously created
  62427. * @param index agent index returned by addAgent
  62428. */
  62429. removeAgent(index: number): void;
  62430. /**
  62431. * get the list of all agents attached to this crowd
  62432. * @returns list of agent indices
  62433. */
  62434. getAgents(): number[];
  62435. /**
  62436. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62437. * @param deltaTime in seconds
  62438. */
  62439. update(deltaTime: number): void;
  62440. /**
  62441. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62442. * @param index agent index returned by addAgent
  62443. * @param destination targeted world position
  62444. */
  62445. agentGoto(index: number, destination: Vector3): void;
  62446. /**
  62447. * Teleport the agent to a new position
  62448. * @param index agent index returned by addAgent
  62449. * @param destination targeted world position
  62450. */
  62451. agentTeleport(index: number, destination: Vector3): void;
  62452. /**
  62453. * Update agent parameters
  62454. * @param index agent index returned by addAgent
  62455. * @param parameters agent parameters
  62456. */
  62457. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62458. /**
  62459. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62460. * The queries will try to find a solution within those bounds
  62461. * default is (1,1,1)
  62462. * @param extent x,y,z value that define the extent around the queries point of reference
  62463. */
  62464. setDefaultQueryExtent(extent: Vector3): void;
  62465. /**
  62466. * Get the Bounding box extent specified by setDefaultQueryExtent
  62467. * @returns the box extent values
  62468. */
  62469. getDefaultQueryExtent(): Vector3;
  62470. /**
  62471. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62472. * @param result output the box extent values
  62473. */
  62474. getDefaultQueryExtentToRef(result: Vector3): void;
  62475. /**
  62476. * Release all resources
  62477. */
  62478. dispose(): void;
  62479. }
  62480. /**
  62481. * Configures an agent
  62482. */
  62483. export interface IAgentParameters {
  62484. /**
  62485. * Agent radius. [Limit: >= 0]
  62486. */
  62487. radius: number;
  62488. /**
  62489. * Agent height. [Limit: > 0]
  62490. */
  62491. height: number;
  62492. /**
  62493. * Maximum allowed acceleration. [Limit: >= 0]
  62494. */
  62495. maxAcceleration: number;
  62496. /**
  62497. * Maximum allowed speed. [Limit: >= 0]
  62498. */
  62499. maxSpeed: number;
  62500. /**
  62501. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62502. */
  62503. collisionQueryRange: number;
  62504. /**
  62505. * The path visibility optimization range. [Limit: > 0]
  62506. */
  62507. pathOptimizationRange: number;
  62508. /**
  62509. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62510. */
  62511. separationWeight: number;
  62512. }
  62513. /**
  62514. * Configures the navigation mesh creation
  62515. */
  62516. export interface INavMeshParameters {
  62517. /**
  62518. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62519. */
  62520. cs: number;
  62521. /**
  62522. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62523. */
  62524. ch: number;
  62525. /**
  62526. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62527. */
  62528. walkableSlopeAngle: number;
  62529. /**
  62530. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62531. * be considered walkable. [Limit: >= 3] [Units: vx]
  62532. */
  62533. walkableHeight: number;
  62534. /**
  62535. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62536. */
  62537. walkableClimb: number;
  62538. /**
  62539. * The distance to erode/shrink the walkable area of the heightfield away from
  62540. * obstructions. [Limit: >=0] [Units: vx]
  62541. */
  62542. walkableRadius: number;
  62543. /**
  62544. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62545. */
  62546. maxEdgeLen: number;
  62547. /**
  62548. * The maximum distance a simplfied contour's border edges should deviate
  62549. * the original raw contour. [Limit: >=0] [Units: vx]
  62550. */
  62551. maxSimplificationError: number;
  62552. /**
  62553. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62554. */
  62555. minRegionArea: number;
  62556. /**
  62557. * Any regions with a span count smaller than this value will, if possible,
  62558. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62559. */
  62560. mergeRegionArea: number;
  62561. /**
  62562. * The maximum number of vertices allowed for polygons generated during the
  62563. * contour to polygon conversion process. [Limit: >= 3]
  62564. */
  62565. maxVertsPerPoly: number;
  62566. /**
  62567. * Sets the sampling distance to use when generating the detail mesh.
  62568. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62569. */
  62570. detailSampleDist: number;
  62571. /**
  62572. * The maximum distance the detail mesh surface should deviate from heightfield
  62573. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62574. */
  62575. detailSampleMaxError: number;
  62576. }
  62577. }
  62578. declare module BABYLON {
  62579. /**
  62580. * RecastJS navigation plugin
  62581. */
  62582. export class RecastJSPlugin implements INavigationEnginePlugin {
  62583. /**
  62584. * Reference to the Recast library
  62585. */
  62586. bjsRECAST: any;
  62587. /**
  62588. * plugin name
  62589. */
  62590. name: string;
  62591. /**
  62592. * the first navmesh created. We might extend this to support multiple navmeshes
  62593. */
  62594. navMesh: any;
  62595. /**
  62596. * Initializes the recastJS plugin
  62597. * @param recastInjection can be used to inject your own recast reference
  62598. */
  62599. constructor(recastInjection?: any);
  62600. /**
  62601. * Creates a navigation mesh
  62602. * @param meshes array of all the geometry used to compute the navigatio mesh
  62603. * @param parameters bunch of parameters used to filter geometry
  62604. */
  62605. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62606. /**
  62607. * Create a navigation mesh debug mesh
  62608. * @param scene is where the mesh will be added
  62609. * @returns debug display mesh
  62610. */
  62611. createDebugNavMesh(scene: Scene): Mesh;
  62612. /**
  62613. * Get a navigation mesh constrained position, closest to the parameter position
  62614. * @param position world position
  62615. * @returns the closest point to position constrained by the navigation mesh
  62616. */
  62617. getClosestPoint(position: Vector3): Vector3;
  62618. /**
  62619. * Get a navigation mesh constrained position, closest to the parameter position
  62620. * @param position world position
  62621. * @param result output the closest point to position constrained by the navigation mesh
  62622. */
  62623. getClosestPointToRef(position: Vector3, result: Vector3): void;
  62624. /**
  62625. * Get a navigation mesh constrained position, within a particular radius
  62626. * @param position world position
  62627. * @param maxRadius the maximum distance to the constrained world position
  62628. * @returns the closest point to position constrained by the navigation mesh
  62629. */
  62630. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62631. /**
  62632. * Get a navigation mesh constrained position, within a particular radius
  62633. * @param position world position
  62634. * @param maxRadius the maximum distance to the constrained world position
  62635. * @param result output the closest point to position constrained by the navigation mesh
  62636. */
  62637. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  62638. /**
  62639. * Compute the final position from a segment made of destination-position
  62640. * @param position world position
  62641. * @param destination world position
  62642. * @returns the resulting point along the navmesh
  62643. */
  62644. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62645. /**
  62646. * Compute the final position from a segment made of destination-position
  62647. * @param position world position
  62648. * @param destination world position
  62649. * @param result output the resulting point along the navmesh
  62650. */
  62651. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  62652. /**
  62653. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62654. * @param start world position
  62655. * @param end world position
  62656. * @returns array containing world position composing the path
  62657. */
  62658. computePath(start: Vector3, end: Vector3): Vector3[];
  62659. /**
  62660. * Create a new Crowd so you can add agents
  62661. * @param maxAgents the maximum agent count in the crowd
  62662. * @param maxAgentRadius the maximum radius an agent can have
  62663. * @param scene to attach the crowd to
  62664. * @returns the crowd you can add agents to
  62665. */
  62666. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62667. /**
  62668. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62669. * The queries will try to find a solution within those bounds
  62670. * default is (1,1,1)
  62671. * @param extent x,y,z value that define the extent around the queries point of reference
  62672. */
  62673. setDefaultQueryExtent(extent: Vector3): void;
  62674. /**
  62675. * Get the Bounding box extent specified by setDefaultQueryExtent
  62676. * @returns the box extent values
  62677. */
  62678. getDefaultQueryExtent(): Vector3;
  62679. /**
  62680. * build the navmesh from a previously saved state using getNavmeshData
  62681. * @param data the Uint8Array returned by getNavmeshData
  62682. */
  62683. buildFromNavmeshData(data: Uint8Array): void;
  62684. /**
  62685. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  62686. * @returns data the Uint8Array that can be saved and reused
  62687. */
  62688. getNavmeshData(): Uint8Array;
  62689. /**
  62690. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62691. * @param result output the box extent values
  62692. */
  62693. getDefaultQueryExtentToRef(result: Vector3): void;
  62694. /**
  62695. * Disposes
  62696. */
  62697. dispose(): void;
  62698. /**
  62699. * If this plugin is supported
  62700. * @returns true if plugin is supported
  62701. */
  62702. isSupported(): boolean;
  62703. }
  62704. /**
  62705. * Recast detour crowd implementation
  62706. */
  62707. export class RecastJSCrowd implements ICrowd {
  62708. /**
  62709. * Recast/detour plugin
  62710. */
  62711. bjsRECASTPlugin: RecastJSPlugin;
  62712. /**
  62713. * Link to the detour crowd
  62714. */
  62715. recastCrowd: any;
  62716. /**
  62717. * One transform per agent
  62718. */
  62719. transforms: TransformNode[];
  62720. /**
  62721. * All agents created
  62722. */
  62723. agents: number[];
  62724. /**
  62725. * Link to the scene is kept to unregister the crowd from the scene
  62726. */
  62727. private _scene;
  62728. /**
  62729. * Observer for crowd updates
  62730. */
  62731. private _onBeforeAnimationsObserver;
  62732. /**
  62733. * Constructor
  62734. * @param plugin recastJS plugin
  62735. * @param maxAgents the maximum agent count in the crowd
  62736. * @param maxAgentRadius the maximum radius an agent can have
  62737. * @param scene to attach the crowd to
  62738. * @returns the crowd you can add agents to
  62739. */
  62740. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  62741. /**
  62742. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62743. * You can attach anything to that node. The node position is updated in the scene update tick.
  62744. * @param pos world position that will be constrained by the navigation mesh
  62745. * @param parameters agent parameters
  62746. * @param transform hooked to the agent that will be update by the scene
  62747. * @returns agent index
  62748. */
  62749. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62750. /**
  62751. * Returns the agent position in world space
  62752. * @param index agent index returned by addAgent
  62753. * @returns world space position
  62754. */
  62755. getAgentPosition(index: number): Vector3;
  62756. /**
  62757. * Returns the agent position result in world space
  62758. * @param index agent index returned by addAgent
  62759. * @param result output world space position
  62760. */
  62761. getAgentPositionToRef(index: number, result: Vector3): void;
  62762. /**
  62763. * Returns the agent velocity in world space
  62764. * @param index agent index returned by addAgent
  62765. * @returns world space velocity
  62766. */
  62767. getAgentVelocity(index: number): Vector3;
  62768. /**
  62769. * Returns the agent velocity result in world space
  62770. * @param index agent index returned by addAgent
  62771. * @param result output world space velocity
  62772. */
  62773. getAgentVelocityToRef(index: number, result: Vector3): void;
  62774. /**
  62775. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62776. * @param index agent index returned by addAgent
  62777. * @param destination targeted world position
  62778. */
  62779. agentGoto(index: number, destination: Vector3): void;
  62780. /**
  62781. * Teleport the agent to a new position
  62782. * @param index agent index returned by addAgent
  62783. * @param destination targeted world position
  62784. */
  62785. agentTeleport(index: number, destination: Vector3): void;
  62786. /**
  62787. * Update agent parameters
  62788. * @param index agent index returned by addAgent
  62789. * @param parameters agent parameters
  62790. */
  62791. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62792. /**
  62793. * remove a particular agent previously created
  62794. * @param index agent index returned by addAgent
  62795. */
  62796. removeAgent(index: number): void;
  62797. /**
  62798. * get the list of all agents attached to this crowd
  62799. * @returns list of agent indices
  62800. */
  62801. getAgents(): number[];
  62802. /**
  62803. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62804. * @param deltaTime in seconds
  62805. */
  62806. update(deltaTime: number): void;
  62807. /**
  62808. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62809. * The queries will try to find a solution within those bounds
  62810. * default is (1,1,1)
  62811. * @param extent x,y,z value that define the extent around the queries point of reference
  62812. */
  62813. setDefaultQueryExtent(extent: Vector3): void;
  62814. /**
  62815. * Get the Bounding box extent specified by setDefaultQueryExtent
  62816. * @returns the box extent values
  62817. */
  62818. getDefaultQueryExtent(): Vector3;
  62819. /**
  62820. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62821. * @param result output the box extent values
  62822. */
  62823. getDefaultQueryExtentToRef(result: Vector3): void;
  62824. /**
  62825. * Release all resources
  62826. */
  62827. dispose(): void;
  62828. }
  62829. }
  62830. declare module BABYLON {
  62831. /**
  62832. * Class used to enable access to IndexedDB
  62833. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62834. */
  62835. export class Database implements IOfflineProvider {
  62836. private _callbackManifestChecked;
  62837. private _currentSceneUrl;
  62838. private _db;
  62839. private _enableSceneOffline;
  62840. private _enableTexturesOffline;
  62841. private _manifestVersionFound;
  62842. private _mustUpdateRessources;
  62843. private _hasReachedQuota;
  62844. private _isSupported;
  62845. private _idbFactory;
  62846. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  62847. private static IsUASupportingBlobStorage;
  62848. /**
  62849. * Gets a boolean indicating if Database storate is enabled (off by default)
  62850. */
  62851. static IDBStorageEnabled: boolean;
  62852. /**
  62853. * Gets a boolean indicating if scene must be saved in the database
  62854. */
  62855. get enableSceneOffline(): boolean;
  62856. /**
  62857. * Gets a boolean indicating if textures must be saved in the database
  62858. */
  62859. get enableTexturesOffline(): boolean;
  62860. /**
  62861. * Creates a new Database
  62862. * @param urlToScene defines the url to load the scene
  62863. * @param callbackManifestChecked defines the callback to use when manifest is checked
  62864. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  62865. */
  62866. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  62867. private static _ParseURL;
  62868. private static _ReturnFullUrlLocation;
  62869. private _checkManifestFile;
  62870. /**
  62871. * Open the database and make it available
  62872. * @param successCallback defines the callback to call on success
  62873. * @param errorCallback defines the callback to call on error
  62874. */
  62875. open(successCallback: () => void, errorCallback: () => void): void;
  62876. /**
  62877. * Loads an image from the database
  62878. * @param url defines the url to load from
  62879. * @param image defines the target DOM image
  62880. */
  62881. loadImage(url: string, image: HTMLImageElement): void;
  62882. private _loadImageFromDBAsync;
  62883. private _saveImageIntoDBAsync;
  62884. private _checkVersionFromDB;
  62885. private _loadVersionFromDBAsync;
  62886. private _saveVersionIntoDBAsync;
  62887. /**
  62888. * Loads a file from database
  62889. * @param url defines the URL to load from
  62890. * @param sceneLoaded defines a callback to call on success
  62891. * @param progressCallBack defines a callback to call when progress changed
  62892. * @param errorCallback defines a callback to call on error
  62893. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62894. */
  62895. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62896. private _loadFileAsync;
  62897. private _saveFileAsync;
  62898. /**
  62899. * Validates if xhr data is correct
  62900. * @param xhr defines the request to validate
  62901. * @param dataType defines the expected data type
  62902. * @returns true if data is correct
  62903. */
  62904. private static _ValidateXHRData;
  62905. }
  62906. }
  62907. declare module BABYLON {
  62908. /** @hidden */
  62909. export var gpuUpdateParticlesPixelShader: {
  62910. name: string;
  62911. shader: string;
  62912. };
  62913. }
  62914. declare module BABYLON {
  62915. /** @hidden */
  62916. export var gpuUpdateParticlesVertexShader: {
  62917. name: string;
  62918. shader: string;
  62919. };
  62920. }
  62921. declare module BABYLON {
  62922. /** @hidden */
  62923. export var clipPlaneFragmentDeclaration2: {
  62924. name: string;
  62925. shader: string;
  62926. };
  62927. }
  62928. declare module BABYLON {
  62929. /** @hidden */
  62930. export var gpuRenderParticlesPixelShader: {
  62931. name: string;
  62932. shader: string;
  62933. };
  62934. }
  62935. declare module BABYLON {
  62936. /** @hidden */
  62937. export var clipPlaneVertexDeclaration2: {
  62938. name: string;
  62939. shader: string;
  62940. };
  62941. }
  62942. declare module BABYLON {
  62943. /** @hidden */
  62944. export var gpuRenderParticlesVertexShader: {
  62945. name: string;
  62946. shader: string;
  62947. };
  62948. }
  62949. declare module BABYLON {
  62950. /**
  62951. * This represents a GPU particle system in Babylon
  62952. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  62953. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  62954. */
  62955. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  62956. /**
  62957. * The layer mask we are rendering the particles through.
  62958. */
  62959. layerMask: number;
  62960. private _capacity;
  62961. private _activeCount;
  62962. private _currentActiveCount;
  62963. private _accumulatedCount;
  62964. private _renderEffect;
  62965. private _updateEffect;
  62966. private _buffer0;
  62967. private _buffer1;
  62968. private _spriteBuffer;
  62969. private _updateVAO;
  62970. private _renderVAO;
  62971. private _targetIndex;
  62972. private _sourceBuffer;
  62973. private _targetBuffer;
  62974. private _engine;
  62975. private _currentRenderId;
  62976. private _started;
  62977. private _stopped;
  62978. private _timeDelta;
  62979. private _randomTexture;
  62980. private _randomTexture2;
  62981. private _attributesStrideSize;
  62982. private _updateEffectOptions;
  62983. private _randomTextureSize;
  62984. private _actualFrame;
  62985. private readonly _rawTextureWidth;
  62986. /**
  62987. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  62988. */
  62989. static get IsSupported(): boolean;
  62990. /**
  62991. * An event triggered when the system is disposed.
  62992. */
  62993. onDisposeObservable: Observable<GPUParticleSystem>;
  62994. /**
  62995. * Gets the maximum number of particles active at the same time.
  62996. * @returns The max number of active particles.
  62997. */
  62998. getCapacity(): number;
  62999. /**
  63000. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  63001. * to override the particles.
  63002. */
  63003. forceDepthWrite: boolean;
  63004. /**
  63005. * Gets or set the number of active particles
  63006. */
  63007. get activeParticleCount(): number;
  63008. set activeParticleCount(value: number);
  63009. private _preWarmDone;
  63010. /**
  63011. * Specifies if the particles are updated in emitter local space or world space.
  63012. * This is always false for GPU particles
  63013. */
  63014. get isLocal(): boolean;
  63015. set isLocal(value: boolean);
  63016. /**
  63017. * Is this system ready to be used/rendered
  63018. * @return true if the system is ready
  63019. */
  63020. isReady(): boolean;
  63021. /**
  63022. * Gets if the system has been started. (Note: this will still be true after stop is called)
  63023. * @returns True if it has been started, otherwise false.
  63024. */
  63025. isStarted(): boolean;
  63026. /**
  63027. * Starts the particle system and begins to emit
  63028. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  63029. */
  63030. start(delay?: number): void;
  63031. /**
  63032. * Stops the particle system.
  63033. */
  63034. stop(): void;
  63035. /**
  63036. * Remove all active particles
  63037. */
  63038. reset(): void;
  63039. /**
  63040. * Returns the string "GPUParticleSystem"
  63041. * @returns a string containing the class name
  63042. */
  63043. getClassName(): string;
  63044. private _colorGradientsTexture;
  63045. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  63046. /**
  63047. * Adds a new color gradient
  63048. * @param gradient defines the gradient to use (between 0 and 1)
  63049. * @param color1 defines the color to affect to the specified gradient
  63050. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  63051. * @returns the current particle system
  63052. */
  63053. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  63054. /**
  63055. * Remove a specific color gradient
  63056. * @param gradient defines the gradient to remove
  63057. * @returns the current particle system
  63058. */
  63059. removeColorGradient(gradient: number): GPUParticleSystem;
  63060. private _angularSpeedGradientsTexture;
  63061. private _sizeGradientsTexture;
  63062. private _velocityGradientsTexture;
  63063. private _limitVelocityGradientsTexture;
  63064. private _dragGradientsTexture;
  63065. private _addFactorGradient;
  63066. /**
  63067. * Adds a new size gradient
  63068. * @param gradient defines the gradient to use (between 0 and 1)
  63069. * @param factor defines the size factor to affect to the specified gradient
  63070. * @returns the current particle system
  63071. */
  63072. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  63073. /**
  63074. * Remove a specific size gradient
  63075. * @param gradient defines the gradient to remove
  63076. * @returns the current particle system
  63077. */
  63078. removeSizeGradient(gradient: number): GPUParticleSystem;
  63079. /**
  63080. * Adds a new angular speed gradient
  63081. * @param gradient defines the gradient to use (between 0 and 1)
  63082. * @param factor defines the angular speed to affect to the specified gradient
  63083. * @returns the current particle system
  63084. */
  63085. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  63086. /**
  63087. * Remove a specific angular speed gradient
  63088. * @param gradient defines the gradient to remove
  63089. * @returns the current particle system
  63090. */
  63091. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  63092. /**
  63093. * Adds a new velocity gradient
  63094. * @param gradient defines the gradient to use (between 0 and 1)
  63095. * @param factor defines the velocity to affect to the specified gradient
  63096. * @returns the current particle system
  63097. */
  63098. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63099. /**
  63100. * Remove a specific velocity gradient
  63101. * @param gradient defines the gradient to remove
  63102. * @returns the current particle system
  63103. */
  63104. removeVelocityGradient(gradient: number): GPUParticleSystem;
  63105. /**
  63106. * Adds a new limit velocity gradient
  63107. * @param gradient defines the gradient to use (between 0 and 1)
  63108. * @param factor defines the limit velocity value to affect to the specified gradient
  63109. * @returns the current particle system
  63110. */
  63111. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63112. /**
  63113. * Remove a specific limit velocity gradient
  63114. * @param gradient defines the gradient to remove
  63115. * @returns the current particle system
  63116. */
  63117. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  63118. /**
  63119. * Adds a new drag gradient
  63120. * @param gradient defines the gradient to use (between 0 and 1)
  63121. * @param factor defines the drag value to affect to the specified gradient
  63122. * @returns the current particle system
  63123. */
  63124. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  63125. /**
  63126. * Remove a specific drag gradient
  63127. * @param gradient defines the gradient to remove
  63128. * @returns the current particle system
  63129. */
  63130. removeDragGradient(gradient: number): GPUParticleSystem;
  63131. /**
  63132. * Not supported by GPUParticleSystem
  63133. * @param gradient defines the gradient to use (between 0 and 1)
  63134. * @param factor defines the emit rate value to affect to the specified gradient
  63135. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63136. * @returns the current particle system
  63137. */
  63138. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63139. /**
  63140. * Not supported by GPUParticleSystem
  63141. * @param gradient defines the gradient to remove
  63142. * @returns the current particle system
  63143. */
  63144. removeEmitRateGradient(gradient: number): IParticleSystem;
  63145. /**
  63146. * Not supported by GPUParticleSystem
  63147. * @param gradient defines the gradient to use (between 0 and 1)
  63148. * @param factor defines the start size value to affect to the specified gradient
  63149. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63150. * @returns the current particle system
  63151. */
  63152. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63153. /**
  63154. * Not supported by GPUParticleSystem
  63155. * @param gradient defines the gradient to remove
  63156. * @returns the current particle system
  63157. */
  63158. removeStartSizeGradient(gradient: number): IParticleSystem;
  63159. /**
  63160. * Not supported by GPUParticleSystem
  63161. * @param gradient defines the gradient to use (between 0 and 1)
  63162. * @param min defines the color remap minimal range
  63163. * @param max defines the color remap maximal range
  63164. * @returns the current particle system
  63165. */
  63166. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63167. /**
  63168. * Not supported by GPUParticleSystem
  63169. * @param gradient defines the gradient to remove
  63170. * @returns the current particle system
  63171. */
  63172. removeColorRemapGradient(): IParticleSystem;
  63173. /**
  63174. * Not supported by GPUParticleSystem
  63175. * @param gradient defines the gradient to use (between 0 and 1)
  63176. * @param min defines the alpha remap minimal range
  63177. * @param max defines the alpha remap maximal range
  63178. * @returns the current particle system
  63179. */
  63180. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63181. /**
  63182. * Not supported by GPUParticleSystem
  63183. * @param gradient defines the gradient to remove
  63184. * @returns the current particle system
  63185. */
  63186. removeAlphaRemapGradient(): IParticleSystem;
  63187. /**
  63188. * Not supported by GPUParticleSystem
  63189. * @param gradient defines the gradient to use (between 0 and 1)
  63190. * @param color defines the color to affect to the specified gradient
  63191. * @returns the current particle system
  63192. */
  63193. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  63194. /**
  63195. * Not supported by GPUParticleSystem
  63196. * @param gradient defines the gradient to remove
  63197. * @returns the current particle system
  63198. */
  63199. removeRampGradient(): IParticleSystem;
  63200. /**
  63201. * Not supported by GPUParticleSystem
  63202. * @returns the list of ramp gradients
  63203. */
  63204. getRampGradients(): Nullable<Array<Color3Gradient>>;
  63205. /**
  63206. * Not supported by GPUParticleSystem
  63207. * Gets or sets a boolean indicating that ramp gradients must be used
  63208. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  63209. */
  63210. get useRampGradients(): boolean;
  63211. set useRampGradients(value: boolean);
  63212. /**
  63213. * Not supported by GPUParticleSystem
  63214. * @param gradient defines the gradient to use (between 0 and 1)
  63215. * @param factor defines the life time factor to affect to the specified gradient
  63216. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63217. * @returns the current particle system
  63218. */
  63219. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63220. /**
  63221. * Not supported by GPUParticleSystem
  63222. * @param gradient defines the gradient to remove
  63223. * @returns the current particle system
  63224. */
  63225. removeLifeTimeGradient(gradient: number): IParticleSystem;
  63226. /**
  63227. * Instantiates a GPU particle system.
  63228. * 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.
  63229. * @param name The name of the particle system
  63230. * @param options The options used to create the system
  63231. * @param scene The scene the particle system belongs to
  63232. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  63233. */
  63234. constructor(name: string, options: Partial<{
  63235. capacity: number;
  63236. randomTextureSize: number;
  63237. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  63238. protected _reset(): void;
  63239. private _createUpdateVAO;
  63240. private _createRenderVAO;
  63241. private _initialize;
  63242. /** @hidden */
  63243. _recreateUpdateEffect(): void;
  63244. /** @hidden */
  63245. _recreateRenderEffect(): void;
  63246. /**
  63247. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  63248. * @param preWarm defines if we are in the pre-warmimg phase
  63249. */
  63250. animate(preWarm?: boolean): void;
  63251. private _createFactorGradientTexture;
  63252. private _createSizeGradientTexture;
  63253. private _createAngularSpeedGradientTexture;
  63254. private _createVelocityGradientTexture;
  63255. private _createLimitVelocityGradientTexture;
  63256. private _createDragGradientTexture;
  63257. private _createColorGradientTexture;
  63258. /**
  63259. * Renders the particle system in its current state
  63260. * @param preWarm defines if the system should only update the particles but not render them
  63261. * @returns the current number of particles
  63262. */
  63263. render(preWarm?: boolean): number;
  63264. /**
  63265. * Rebuilds the particle system
  63266. */
  63267. rebuild(): void;
  63268. private _releaseBuffers;
  63269. private _releaseVAOs;
  63270. /**
  63271. * Disposes the particle system and free the associated resources
  63272. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  63273. */
  63274. dispose(disposeTexture?: boolean): void;
  63275. /**
  63276. * Clones the particle system.
  63277. * @param name The name of the cloned object
  63278. * @param newEmitter The new emitter to use
  63279. * @returns the cloned particle system
  63280. */
  63281. clone(name: string, newEmitter: any): GPUParticleSystem;
  63282. /**
  63283. * Serializes the particle system to a JSON object.
  63284. * @returns the JSON object
  63285. */
  63286. serialize(): any;
  63287. /**
  63288. * Parses a JSON object to create a GPU particle system.
  63289. * @param parsedParticleSystem The JSON object to parse
  63290. * @param scene The scene to create the particle system in
  63291. * @param rootUrl The root url to use to load external dependencies like texture
  63292. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  63293. * @returns the parsed GPU particle system
  63294. */
  63295. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  63296. }
  63297. }
  63298. declare module BABYLON {
  63299. /**
  63300. * Represents a set of particle systems working together to create a specific effect
  63301. */
  63302. export class ParticleSystemSet implements IDisposable {
  63303. /**
  63304. * Gets or sets base Assets URL
  63305. */
  63306. static BaseAssetsUrl: string;
  63307. private _emitterCreationOptions;
  63308. private _emitterNode;
  63309. /**
  63310. * Gets the particle system list
  63311. */
  63312. systems: IParticleSystem[];
  63313. /**
  63314. * Gets the emitter node used with this set
  63315. */
  63316. get emitterNode(): Nullable<TransformNode>;
  63317. /**
  63318. * Creates a new emitter mesh as a sphere
  63319. * @param options defines the options used to create the sphere
  63320. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  63321. * @param scene defines the hosting scene
  63322. */
  63323. setEmitterAsSphere(options: {
  63324. diameter: number;
  63325. segments: number;
  63326. color: Color3;
  63327. }, renderingGroupId: number, scene: Scene): void;
  63328. /**
  63329. * Starts all particle systems of the set
  63330. * @param emitter defines an optional mesh to use as emitter for the particle systems
  63331. */
  63332. start(emitter?: AbstractMesh): void;
  63333. /**
  63334. * Release all associated resources
  63335. */
  63336. dispose(): void;
  63337. /**
  63338. * Serialize the set into a JSON compatible object
  63339. * @returns a JSON compatible representation of the set
  63340. */
  63341. serialize(): any;
  63342. /**
  63343. * Parse a new ParticleSystemSet from a serialized source
  63344. * @param data defines a JSON compatible representation of the set
  63345. * @param scene defines the hosting scene
  63346. * @param gpu defines if we want GPU particles or CPU particles
  63347. * @returns a new ParticleSystemSet
  63348. */
  63349. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  63350. }
  63351. }
  63352. declare module BABYLON {
  63353. /**
  63354. * This class is made for on one-liner static method to help creating particle system set.
  63355. */
  63356. export class ParticleHelper {
  63357. /**
  63358. * Gets or sets base Assets URL
  63359. */
  63360. static BaseAssetsUrl: string;
  63361. /**
  63362. * Create a default particle system that you can tweak
  63363. * @param emitter defines the emitter to use
  63364. * @param capacity defines the system capacity (default is 500 particles)
  63365. * @param scene defines the hosting scene
  63366. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  63367. * @returns the new Particle system
  63368. */
  63369. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  63370. /**
  63371. * This is the main static method (one-liner) of this helper to create different particle systems
  63372. * @param type This string represents the type to the particle system to create
  63373. * @param scene The scene where the particle system should live
  63374. * @param gpu If the system will use gpu
  63375. * @returns the ParticleSystemSet created
  63376. */
  63377. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  63378. /**
  63379. * Static function used to export a particle system to a ParticleSystemSet variable.
  63380. * Please note that the emitter shape is not exported
  63381. * @param systems defines the particle systems to export
  63382. * @returns the created particle system set
  63383. */
  63384. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  63385. }
  63386. }
  63387. declare module BABYLON {
  63388. interface Engine {
  63389. /**
  63390. * Create an effect to use with particle systems.
  63391. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  63392. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  63393. * @param uniformsNames defines a list of attribute names
  63394. * @param samplers defines an array of string used to represent textures
  63395. * @param defines defines the string containing the defines to use to compile the shaders
  63396. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  63397. * @param onCompiled defines a function to call when the effect creation is successful
  63398. * @param onError defines a function to call when the effect creation has failed
  63399. * @returns the new Effect
  63400. */
  63401. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  63402. }
  63403. interface Mesh {
  63404. /**
  63405. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  63406. * @returns an array of IParticleSystem
  63407. */
  63408. getEmittedParticleSystems(): IParticleSystem[];
  63409. /**
  63410. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  63411. * @returns an array of IParticleSystem
  63412. */
  63413. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  63414. }
  63415. /**
  63416. * @hidden
  63417. */
  63418. export var _IDoNeedToBeInTheBuild: number;
  63419. }
  63420. declare module BABYLON {
  63421. /** Defines the 4 color options */
  63422. export enum PointColor {
  63423. /** color value */
  63424. Color = 2,
  63425. /** uv value */
  63426. UV = 1,
  63427. /** random value */
  63428. Random = 0,
  63429. /** stated value */
  63430. Stated = 3
  63431. }
  63432. /**
  63433. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  63434. * 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.
  63435. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  63436. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  63437. *
  63438. * Full documentation here : TO BE ENTERED
  63439. */
  63440. export class PointsCloudSystem implements IDisposable {
  63441. /**
  63442. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  63443. * Example : var p = SPS.particles[i];
  63444. */
  63445. particles: CloudPoint[];
  63446. /**
  63447. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  63448. */
  63449. nbParticles: number;
  63450. /**
  63451. * This a counter for your own usage. It's not set by any SPS functions.
  63452. */
  63453. counter: number;
  63454. /**
  63455. * The PCS name. This name is also given to the underlying mesh.
  63456. */
  63457. name: string;
  63458. /**
  63459. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  63460. */
  63461. mesh: Mesh;
  63462. /**
  63463. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  63464. * Please read :
  63465. */
  63466. vars: any;
  63467. /**
  63468. * @hidden
  63469. */
  63470. _size: number;
  63471. private _scene;
  63472. private _promises;
  63473. private _positions;
  63474. private _indices;
  63475. private _normals;
  63476. private _colors;
  63477. private _uvs;
  63478. private _indices32;
  63479. private _positions32;
  63480. private _colors32;
  63481. private _uvs32;
  63482. private _updatable;
  63483. private _isVisibilityBoxLocked;
  63484. private _alwaysVisible;
  63485. private _groups;
  63486. private _groupCounter;
  63487. private _computeParticleColor;
  63488. private _computeParticleTexture;
  63489. private _computeParticleRotation;
  63490. private _computeBoundingBox;
  63491. private _isReady;
  63492. /**
  63493. * Creates a PCS (Points Cloud System) object
  63494. * @param name (String) is the PCS name, this will be the underlying mesh name
  63495. * @param pointSize (number) is the size for each point
  63496. * @param scene (Scene) is the scene in which the PCS is added
  63497. * @param options defines the options of the PCS e.g.
  63498. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  63499. */
  63500. constructor(name: string, pointSize: number, scene: Scene, options?: {
  63501. updatable?: boolean;
  63502. });
  63503. /**
  63504. * Builds the PCS underlying mesh. Returns a standard Mesh.
  63505. * If no points were added to the PCS, the returned mesh is just a single point.
  63506. * @returns a promise for the created mesh
  63507. */
  63508. buildMeshAsync(): Promise<Mesh>;
  63509. /**
  63510. * @hidden
  63511. */
  63512. private _buildMesh;
  63513. private _addParticle;
  63514. private _randomUnitVector;
  63515. private _getColorIndicesForCoord;
  63516. private _setPointsColorOrUV;
  63517. private _colorFromTexture;
  63518. private _calculateDensity;
  63519. /**
  63520. * Adds points to the PCS in random positions within a unit sphere
  63521. * @param nb (positive integer) the number of particles to be created from this model
  63522. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  63523. * @returns the number of groups in the system
  63524. */
  63525. addPoints(nb: number, pointFunction?: any): number;
  63526. /**
  63527. * Adds points to the PCS from the surface of the model shape
  63528. * @param mesh is any Mesh object that will be used as a surface model for the points
  63529. * @param nb (positive integer) the number of particles to be created from this model
  63530. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63531. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63532. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63533. * @returns the number of groups in the system
  63534. */
  63535. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63536. /**
  63537. * Adds points to the PCS inside the model shape
  63538. * @param mesh is any Mesh object that will be used as a surface model for the points
  63539. * @param nb (positive integer) the number of particles to be created from this model
  63540. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63541. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63542. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63543. * @returns the number of groups in the system
  63544. */
  63545. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63546. /**
  63547. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  63548. * This method calls `updateParticle()` for each particle of the SPS.
  63549. * For an animated SPS, it is usually called within the render loop.
  63550. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  63551. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  63552. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  63553. * @returns the PCS.
  63554. */
  63555. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63556. /**
  63557. * Disposes the PCS.
  63558. */
  63559. dispose(): void;
  63560. /**
  63561. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63562. * doc :
  63563. * @returns the PCS.
  63564. */
  63565. refreshVisibleSize(): PointsCloudSystem;
  63566. /**
  63567. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63568. * @param size the size (float) of the visibility box
  63569. * note : this doesn't lock the PCS mesh bounding box.
  63570. * doc :
  63571. */
  63572. setVisibilityBox(size: number): void;
  63573. /**
  63574. * Gets whether the PCS is always visible or not
  63575. * doc :
  63576. */
  63577. get isAlwaysVisible(): boolean;
  63578. /**
  63579. * Sets the PCS as always visible or not
  63580. * doc :
  63581. */
  63582. set isAlwaysVisible(val: boolean);
  63583. /**
  63584. * Tells to `setParticles()` to compute the particle rotations or not
  63585. * Default value : false. The PCS is faster when it's set to false
  63586. * Note : particle rotations are only applied to parent particles
  63587. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63588. */
  63589. set computeParticleRotation(val: boolean);
  63590. /**
  63591. * Tells to `setParticles()` to compute the particle colors or not.
  63592. * Default value : true. The PCS is faster when it's set to false.
  63593. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63594. */
  63595. set computeParticleColor(val: boolean);
  63596. set computeParticleTexture(val: boolean);
  63597. /**
  63598. * Gets if `setParticles()` computes the particle colors or not.
  63599. * Default value : false. The PCS is faster when it's set to false.
  63600. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63601. */
  63602. get computeParticleColor(): boolean;
  63603. /**
  63604. * Gets if `setParticles()` computes the particle textures or not.
  63605. * Default value : false. The PCS is faster when it's set to false.
  63606. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  63607. */
  63608. get computeParticleTexture(): boolean;
  63609. /**
  63610. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  63611. */
  63612. set computeBoundingBox(val: boolean);
  63613. /**
  63614. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  63615. */
  63616. get computeBoundingBox(): boolean;
  63617. /**
  63618. * This function does nothing. It may be overwritten to set all the particle first values.
  63619. * The PCS doesn't call this function, you may have to call it by your own.
  63620. * doc :
  63621. */
  63622. initParticles(): void;
  63623. /**
  63624. * This function does nothing. It may be overwritten to recycle a particle
  63625. * The PCS doesn't call this function, you can to call it
  63626. * doc :
  63627. * @param particle The particle to recycle
  63628. * @returns the recycled particle
  63629. */
  63630. recycleParticle(particle: CloudPoint): CloudPoint;
  63631. /**
  63632. * Updates a particle : this function should be overwritten by the user.
  63633. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  63634. * doc :
  63635. * @example : just set a particle position or velocity and recycle conditions
  63636. * @param particle The particle to update
  63637. * @returns the updated particle
  63638. */
  63639. updateParticle(particle: CloudPoint): CloudPoint;
  63640. /**
  63641. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  63642. * This does nothing and may be overwritten by the user.
  63643. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63644. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63645. * @param update the boolean update value actually passed to setParticles()
  63646. */
  63647. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63648. /**
  63649. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  63650. * This will be passed three parameters.
  63651. * This does nothing and may be overwritten by the user.
  63652. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63653. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63654. * @param update the boolean update value actually passed to setParticles()
  63655. */
  63656. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63657. }
  63658. }
  63659. declare module BABYLON {
  63660. /**
  63661. * Represents one particle of a points cloud system.
  63662. */
  63663. export class CloudPoint {
  63664. /**
  63665. * particle global index
  63666. */
  63667. idx: number;
  63668. /**
  63669. * The color of the particle
  63670. */
  63671. color: Nullable<Color4>;
  63672. /**
  63673. * The world space position of the particle.
  63674. */
  63675. position: Vector3;
  63676. /**
  63677. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  63678. */
  63679. rotation: Vector3;
  63680. /**
  63681. * The world space rotation quaternion of the particle.
  63682. */
  63683. rotationQuaternion: Nullable<Quaternion>;
  63684. /**
  63685. * The uv of the particle.
  63686. */
  63687. uv: Nullable<Vector2>;
  63688. /**
  63689. * The current speed of the particle.
  63690. */
  63691. velocity: Vector3;
  63692. /**
  63693. * The pivot point in the particle local space.
  63694. */
  63695. pivot: Vector3;
  63696. /**
  63697. * Must the particle be translated from its pivot point in its local space ?
  63698. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  63699. * Default : false
  63700. */
  63701. translateFromPivot: boolean;
  63702. /**
  63703. * Index of this particle in the global "positions" array (Internal use)
  63704. * @hidden
  63705. */
  63706. _pos: number;
  63707. /**
  63708. * @hidden Index of this particle in the global "indices" array (Internal use)
  63709. */
  63710. _ind: number;
  63711. /**
  63712. * Group this particle belongs to
  63713. */
  63714. _group: PointsGroup;
  63715. /**
  63716. * Group id of this particle
  63717. */
  63718. groupId: number;
  63719. /**
  63720. * Index of the particle in its group id (Internal use)
  63721. */
  63722. idxInGroup: number;
  63723. /**
  63724. * @hidden Particle BoundingInfo object (Internal use)
  63725. */
  63726. _boundingInfo: BoundingInfo;
  63727. /**
  63728. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  63729. */
  63730. _pcs: PointsCloudSystem;
  63731. /**
  63732. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  63733. */
  63734. _stillInvisible: boolean;
  63735. /**
  63736. * @hidden Last computed particle rotation matrix
  63737. */
  63738. _rotationMatrix: number[];
  63739. /**
  63740. * Parent particle Id, if any.
  63741. * Default null.
  63742. */
  63743. parentId: Nullable<number>;
  63744. /**
  63745. * @hidden Internal global position in the PCS.
  63746. */
  63747. _globalPosition: Vector3;
  63748. /**
  63749. * Creates a Point Cloud object.
  63750. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  63751. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  63752. * @param group (PointsGroup) is the group the particle belongs to
  63753. * @param groupId (integer) is the group identifier in the PCS.
  63754. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  63755. * @param pcs defines the PCS it is associated to
  63756. */
  63757. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  63758. /**
  63759. * get point size
  63760. */
  63761. get size(): Vector3;
  63762. /**
  63763. * Set point size
  63764. */
  63765. set size(scale: Vector3);
  63766. /**
  63767. * Legacy support, changed quaternion to rotationQuaternion
  63768. */
  63769. get quaternion(): Nullable<Quaternion>;
  63770. /**
  63771. * Legacy support, changed quaternion to rotationQuaternion
  63772. */
  63773. set quaternion(q: Nullable<Quaternion>);
  63774. /**
  63775. * Returns a boolean. True if the particle intersects a mesh, else false
  63776. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  63777. * @param target is the object (point or mesh) what the intersection is computed against
  63778. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  63779. * @returns true if it intersects
  63780. */
  63781. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  63782. /**
  63783. * get the rotation matrix of the particle
  63784. * @hidden
  63785. */
  63786. getRotationMatrix(m: Matrix): void;
  63787. }
  63788. /**
  63789. * Represents a group of points in a points cloud system
  63790. * * PCS internal tool, don't use it manually.
  63791. */
  63792. export class PointsGroup {
  63793. /**
  63794. * The group id
  63795. * @hidden
  63796. */
  63797. groupID: number;
  63798. /**
  63799. * image data for group (internal use)
  63800. * @hidden
  63801. */
  63802. _groupImageData: Nullable<ArrayBufferView>;
  63803. /**
  63804. * Image Width (internal use)
  63805. * @hidden
  63806. */
  63807. _groupImgWidth: number;
  63808. /**
  63809. * Image Height (internal use)
  63810. * @hidden
  63811. */
  63812. _groupImgHeight: number;
  63813. /**
  63814. * Custom position function (internal use)
  63815. * @hidden
  63816. */
  63817. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  63818. /**
  63819. * density per facet for surface points
  63820. * @hidden
  63821. */
  63822. _groupDensity: number[];
  63823. /**
  63824. * Only when points are colored by texture carries pointer to texture list array
  63825. * @hidden
  63826. */
  63827. _textureNb: number;
  63828. /**
  63829. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  63830. * PCS internal tool, don't use it manually.
  63831. * @hidden
  63832. */
  63833. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  63834. }
  63835. }
  63836. declare module BABYLON {
  63837. interface Scene {
  63838. /** @hidden (Backing field) */
  63839. _physicsEngine: Nullable<IPhysicsEngine>;
  63840. /** @hidden */
  63841. _physicsTimeAccumulator: number;
  63842. /**
  63843. * Gets the current physics engine
  63844. * @returns a IPhysicsEngine or null if none attached
  63845. */
  63846. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  63847. /**
  63848. * Enables physics to the current scene
  63849. * @param gravity defines the scene's gravity for the physics engine
  63850. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  63851. * @return a boolean indicating if the physics engine was initialized
  63852. */
  63853. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  63854. /**
  63855. * Disables and disposes the physics engine associated with the scene
  63856. */
  63857. disablePhysicsEngine(): void;
  63858. /**
  63859. * Gets a boolean indicating if there is an active physics engine
  63860. * @returns a boolean indicating if there is an active physics engine
  63861. */
  63862. isPhysicsEnabled(): boolean;
  63863. /**
  63864. * Deletes a physics compound impostor
  63865. * @param compound defines the compound to delete
  63866. */
  63867. deleteCompoundImpostor(compound: any): void;
  63868. /**
  63869. * An event triggered when physic simulation is about to be run
  63870. */
  63871. onBeforePhysicsObservable: Observable<Scene>;
  63872. /**
  63873. * An event triggered when physic simulation has been done
  63874. */
  63875. onAfterPhysicsObservable: Observable<Scene>;
  63876. }
  63877. interface AbstractMesh {
  63878. /** @hidden */
  63879. _physicsImpostor: Nullable<PhysicsImpostor>;
  63880. /**
  63881. * Gets or sets impostor used for physic simulation
  63882. * @see http://doc.babylonjs.com/features/physics_engine
  63883. */
  63884. physicsImpostor: Nullable<PhysicsImpostor>;
  63885. /**
  63886. * Gets the current physics impostor
  63887. * @see http://doc.babylonjs.com/features/physics_engine
  63888. * @returns a physics impostor or null
  63889. */
  63890. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  63891. /** Apply a physic impulse to the mesh
  63892. * @param force defines the force to apply
  63893. * @param contactPoint defines where to apply the force
  63894. * @returns the current mesh
  63895. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  63896. */
  63897. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  63898. /**
  63899. * Creates a physic joint between two meshes
  63900. * @param otherMesh defines the other mesh to use
  63901. * @param pivot1 defines the pivot to use on this mesh
  63902. * @param pivot2 defines the pivot to use on the other mesh
  63903. * @param options defines additional options (can be plugin dependent)
  63904. * @returns the current mesh
  63905. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  63906. */
  63907. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  63908. /** @hidden */
  63909. _disposePhysicsObserver: Nullable<Observer<Node>>;
  63910. }
  63911. /**
  63912. * Defines the physics engine scene component responsible to manage a physics engine
  63913. */
  63914. export class PhysicsEngineSceneComponent implements ISceneComponent {
  63915. /**
  63916. * The component name helpful to identify the component in the list of scene components.
  63917. */
  63918. readonly name: string;
  63919. /**
  63920. * The scene the component belongs to.
  63921. */
  63922. scene: Scene;
  63923. /**
  63924. * Creates a new instance of the component for the given scene
  63925. * @param scene Defines the scene to register the component in
  63926. */
  63927. constructor(scene: Scene);
  63928. /**
  63929. * Registers the component in a given scene
  63930. */
  63931. register(): void;
  63932. /**
  63933. * Rebuilds the elements related to this component in case of
  63934. * context lost for instance.
  63935. */
  63936. rebuild(): void;
  63937. /**
  63938. * Disposes the component and the associated ressources
  63939. */
  63940. dispose(): void;
  63941. }
  63942. }
  63943. declare module BABYLON {
  63944. /**
  63945. * A helper for physics simulations
  63946. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63947. */
  63948. export class PhysicsHelper {
  63949. private _scene;
  63950. private _physicsEngine;
  63951. /**
  63952. * Initializes the Physics helper
  63953. * @param scene Babylon.js scene
  63954. */
  63955. constructor(scene: Scene);
  63956. /**
  63957. * Applies a radial explosion impulse
  63958. * @param origin the origin of the explosion
  63959. * @param radiusOrEventOptions the radius or the options of radial explosion
  63960. * @param strength the explosion strength
  63961. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63962. * @returns A physics radial explosion event, or null
  63963. */
  63964. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63965. /**
  63966. * Applies a radial explosion force
  63967. * @param origin the origin of the explosion
  63968. * @param radiusOrEventOptions the radius or the options of radial explosion
  63969. * @param strength the explosion strength
  63970. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63971. * @returns A physics radial explosion event, or null
  63972. */
  63973. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63974. /**
  63975. * Creates a gravitational field
  63976. * @param origin the origin of the explosion
  63977. * @param radiusOrEventOptions the radius or the options of radial explosion
  63978. * @param strength the explosion strength
  63979. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63980. * @returns A physics gravitational field event, or null
  63981. */
  63982. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  63983. /**
  63984. * Creates a physics updraft event
  63985. * @param origin the origin of the updraft
  63986. * @param radiusOrEventOptions the radius or the options of the updraft
  63987. * @param strength the strength of the updraft
  63988. * @param height the height of the updraft
  63989. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  63990. * @returns A physics updraft event, or null
  63991. */
  63992. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  63993. /**
  63994. * Creates a physics vortex event
  63995. * @param origin the of the vortex
  63996. * @param radiusOrEventOptions the radius or the options of the vortex
  63997. * @param strength the strength of the vortex
  63998. * @param height the height of the vortex
  63999. * @returns a Physics vortex event, or null
  64000. * A physics vortex event or null
  64001. */
  64002. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  64003. }
  64004. /**
  64005. * Represents a physics radial explosion event
  64006. */
  64007. class PhysicsRadialExplosionEvent {
  64008. private _scene;
  64009. private _options;
  64010. private _sphere;
  64011. private _dataFetched;
  64012. /**
  64013. * Initializes a radial explosioin event
  64014. * @param _scene BabylonJS scene
  64015. * @param _options The options for the vortex event
  64016. */
  64017. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  64018. /**
  64019. * Returns the data related to the radial explosion event (sphere).
  64020. * @returns The radial explosion event data
  64021. */
  64022. getData(): PhysicsRadialExplosionEventData;
  64023. /**
  64024. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  64025. * @param impostor A physics imposter
  64026. * @param origin the origin of the explosion
  64027. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  64028. */
  64029. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  64030. /**
  64031. * Triggers affecterd impostors callbacks
  64032. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  64033. */
  64034. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  64035. /**
  64036. * Disposes the sphere.
  64037. * @param force Specifies if the sphere should be disposed by force
  64038. */
  64039. dispose(force?: boolean): void;
  64040. /*** Helpers ***/
  64041. private _prepareSphere;
  64042. private _intersectsWithSphere;
  64043. }
  64044. /**
  64045. * Represents a gravitational field event
  64046. */
  64047. class PhysicsGravitationalFieldEvent {
  64048. private _physicsHelper;
  64049. private _scene;
  64050. private _origin;
  64051. private _options;
  64052. private _tickCallback;
  64053. private _sphere;
  64054. private _dataFetched;
  64055. /**
  64056. * Initializes the physics gravitational field event
  64057. * @param _physicsHelper A physics helper
  64058. * @param _scene BabylonJS scene
  64059. * @param _origin The origin position of the gravitational field event
  64060. * @param _options The options for the vortex event
  64061. */
  64062. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  64063. /**
  64064. * Returns the data related to the gravitational field event (sphere).
  64065. * @returns A gravitational field event
  64066. */
  64067. getData(): PhysicsGravitationalFieldEventData;
  64068. /**
  64069. * Enables the gravitational field.
  64070. */
  64071. enable(): void;
  64072. /**
  64073. * Disables the gravitational field.
  64074. */
  64075. disable(): void;
  64076. /**
  64077. * Disposes the sphere.
  64078. * @param force The force to dispose from the gravitational field event
  64079. */
  64080. dispose(force?: boolean): void;
  64081. private _tick;
  64082. }
  64083. /**
  64084. * Represents a physics updraft event
  64085. */
  64086. class PhysicsUpdraftEvent {
  64087. private _scene;
  64088. private _origin;
  64089. private _options;
  64090. private _physicsEngine;
  64091. private _originTop;
  64092. private _originDirection;
  64093. private _tickCallback;
  64094. private _cylinder;
  64095. private _cylinderPosition;
  64096. private _dataFetched;
  64097. /**
  64098. * Initializes the physics updraft event
  64099. * @param _scene BabylonJS scene
  64100. * @param _origin The origin position of the updraft
  64101. * @param _options The options for the updraft event
  64102. */
  64103. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  64104. /**
  64105. * Returns the data related to the updraft event (cylinder).
  64106. * @returns A physics updraft event
  64107. */
  64108. getData(): PhysicsUpdraftEventData;
  64109. /**
  64110. * Enables the updraft.
  64111. */
  64112. enable(): void;
  64113. /**
  64114. * Disables the updraft.
  64115. */
  64116. disable(): void;
  64117. /**
  64118. * Disposes the cylinder.
  64119. * @param force Specifies if the updraft should be disposed by force
  64120. */
  64121. dispose(force?: boolean): void;
  64122. private getImpostorHitData;
  64123. private _tick;
  64124. /*** Helpers ***/
  64125. private _prepareCylinder;
  64126. private _intersectsWithCylinder;
  64127. }
  64128. /**
  64129. * Represents a physics vortex event
  64130. */
  64131. class PhysicsVortexEvent {
  64132. private _scene;
  64133. private _origin;
  64134. private _options;
  64135. private _physicsEngine;
  64136. private _originTop;
  64137. private _tickCallback;
  64138. private _cylinder;
  64139. private _cylinderPosition;
  64140. private _dataFetched;
  64141. /**
  64142. * Initializes the physics vortex event
  64143. * @param _scene The BabylonJS scene
  64144. * @param _origin The origin position of the vortex
  64145. * @param _options The options for the vortex event
  64146. */
  64147. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  64148. /**
  64149. * Returns the data related to the vortex event (cylinder).
  64150. * @returns The physics vortex event data
  64151. */
  64152. getData(): PhysicsVortexEventData;
  64153. /**
  64154. * Enables the vortex.
  64155. */
  64156. enable(): void;
  64157. /**
  64158. * Disables the cortex.
  64159. */
  64160. disable(): void;
  64161. /**
  64162. * Disposes the sphere.
  64163. * @param force
  64164. */
  64165. dispose(force?: boolean): void;
  64166. private getImpostorHitData;
  64167. private _tick;
  64168. /*** Helpers ***/
  64169. private _prepareCylinder;
  64170. private _intersectsWithCylinder;
  64171. }
  64172. /**
  64173. * Options fot the radial explosion event
  64174. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64175. */
  64176. export class PhysicsRadialExplosionEventOptions {
  64177. /**
  64178. * The radius of the sphere for the radial explosion.
  64179. */
  64180. radius: number;
  64181. /**
  64182. * The strenth of the explosion.
  64183. */
  64184. strength: number;
  64185. /**
  64186. * The strenght of the force in correspondence to the distance of the affected object
  64187. */
  64188. falloff: PhysicsRadialImpulseFalloff;
  64189. /**
  64190. * Sphere options for the radial explosion.
  64191. */
  64192. sphere: {
  64193. segments: number;
  64194. diameter: number;
  64195. };
  64196. /**
  64197. * Sphere options for the radial explosion.
  64198. */
  64199. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  64200. }
  64201. /**
  64202. * Options fot the updraft event
  64203. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64204. */
  64205. export class PhysicsUpdraftEventOptions {
  64206. /**
  64207. * The radius of the cylinder for the vortex
  64208. */
  64209. radius: number;
  64210. /**
  64211. * The strenth of the updraft.
  64212. */
  64213. strength: number;
  64214. /**
  64215. * The height of the cylinder for the updraft.
  64216. */
  64217. height: number;
  64218. /**
  64219. * The mode for the the updraft.
  64220. */
  64221. updraftMode: PhysicsUpdraftMode;
  64222. }
  64223. /**
  64224. * Options fot the vortex event
  64225. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64226. */
  64227. export class PhysicsVortexEventOptions {
  64228. /**
  64229. * The radius of the cylinder for the vortex
  64230. */
  64231. radius: number;
  64232. /**
  64233. * The strenth of the vortex.
  64234. */
  64235. strength: number;
  64236. /**
  64237. * The height of the cylinder for the vortex.
  64238. */
  64239. height: number;
  64240. /**
  64241. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  64242. */
  64243. centripetalForceThreshold: number;
  64244. /**
  64245. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  64246. */
  64247. centripetalForceMultiplier: number;
  64248. /**
  64249. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  64250. */
  64251. centrifugalForceMultiplier: number;
  64252. /**
  64253. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  64254. */
  64255. updraftForceMultiplier: number;
  64256. }
  64257. /**
  64258. * The strenght of the force in correspondence to the distance of the affected object
  64259. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64260. */
  64261. export enum PhysicsRadialImpulseFalloff {
  64262. /** Defines that impulse is constant in strength across it's whole radius */
  64263. Constant = 0,
  64264. /** Defines that impulse gets weaker if it's further from the origin */
  64265. Linear = 1
  64266. }
  64267. /**
  64268. * The strength of the force in correspondence to the distance of the affected object
  64269. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64270. */
  64271. export enum PhysicsUpdraftMode {
  64272. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  64273. Center = 0,
  64274. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  64275. Perpendicular = 1
  64276. }
  64277. /**
  64278. * Interface for a physics hit data
  64279. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64280. */
  64281. export interface PhysicsHitData {
  64282. /**
  64283. * The force applied at the contact point
  64284. */
  64285. force: Vector3;
  64286. /**
  64287. * The contact point
  64288. */
  64289. contactPoint: Vector3;
  64290. /**
  64291. * The distance from the origin to the contact point
  64292. */
  64293. distanceFromOrigin: number;
  64294. }
  64295. /**
  64296. * Interface for radial explosion event data
  64297. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64298. */
  64299. export interface PhysicsRadialExplosionEventData {
  64300. /**
  64301. * A sphere used for the radial explosion event
  64302. */
  64303. sphere: Mesh;
  64304. }
  64305. /**
  64306. * Interface for gravitational field event data
  64307. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64308. */
  64309. export interface PhysicsGravitationalFieldEventData {
  64310. /**
  64311. * A sphere mesh used for the gravitational field event
  64312. */
  64313. sphere: Mesh;
  64314. }
  64315. /**
  64316. * Interface for updraft event data
  64317. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64318. */
  64319. export interface PhysicsUpdraftEventData {
  64320. /**
  64321. * A cylinder used for the updraft event
  64322. */
  64323. cylinder: Mesh;
  64324. }
  64325. /**
  64326. * Interface for vortex event data
  64327. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64328. */
  64329. export interface PhysicsVortexEventData {
  64330. /**
  64331. * A cylinder used for the vortex event
  64332. */
  64333. cylinder: Mesh;
  64334. }
  64335. /**
  64336. * Interface for an affected physics impostor
  64337. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64338. */
  64339. export interface PhysicsAffectedImpostorWithData {
  64340. /**
  64341. * The impostor affected by the effect
  64342. */
  64343. impostor: PhysicsImpostor;
  64344. /**
  64345. * The data about the hit/horce from the explosion
  64346. */
  64347. hitData: PhysicsHitData;
  64348. }
  64349. }
  64350. declare module BABYLON {
  64351. /** @hidden */
  64352. export var blackAndWhitePixelShader: {
  64353. name: string;
  64354. shader: string;
  64355. };
  64356. }
  64357. declare module BABYLON {
  64358. /**
  64359. * Post process used to render in black and white
  64360. */
  64361. export class BlackAndWhitePostProcess extends PostProcess {
  64362. /**
  64363. * Linear about to convert he result to black and white (default: 1)
  64364. */
  64365. degree: number;
  64366. /**
  64367. * Creates a black and white post process
  64368. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  64369. * @param name The name of the effect.
  64370. * @param options The required width/height ratio to downsize to before computing the render pass.
  64371. * @param camera The camera to apply the render pass to.
  64372. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64373. * @param engine The engine which the post process will be applied. (default: current engine)
  64374. * @param reusable If the post process can be reused on the same frame. (default: false)
  64375. */
  64376. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64377. }
  64378. }
  64379. declare module BABYLON {
  64380. /**
  64381. * This represents a set of one or more post processes in Babylon.
  64382. * A post process can be used to apply a shader to a texture after it is rendered.
  64383. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64384. */
  64385. export class PostProcessRenderEffect {
  64386. private _postProcesses;
  64387. private _getPostProcesses;
  64388. private _singleInstance;
  64389. private _cameras;
  64390. private _indicesForCamera;
  64391. /**
  64392. * Name of the effect
  64393. * @hidden
  64394. */
  64395. _name: string;
  64396. /**
  64397. * Instantiates a post process render effect.
  64398. * A post process can be used to apply a shader to a texture after it is rendered.
  64399. * @param engine The engine the effect is tied to
  64400. * @param name The name of the effect
  64401. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  64402. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  64403. */
  64404. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  64405. /**
  64406. * Checks if all the post processes in the effect are supported.
  64407. */
  64408. get isSupported(): boolean;
  64409. /**
  64410. * Updates the current state of the effect
  64411. * @hidden
  64412. */
  64413. _update(): void;
  64414. /**
  64415. * Attaches the effect on cameras
  64416. * @param cameras The camera to attach to.
  64417. * @hidden
  64418. */
  64419. _attachCameras(cameras: Camera): void;
  64420. /**
  64421. * Attaches the effect on cameras
  64422. * @param cameras The camera to attach to.
  64423. * @hidden
  64424. */
  64425. _attachCameras(cameras: Camera[]): void;
  64426. /**
  64427. * Detaches the effect on cameras
  64428. * @param cameras The camera to detatch from.
  64429. * @hidden
  64430. */
  64431. _detachCameras(cameras: Camera): void;
  64432. /**
  64433. * Detatches the effect on cameras
  64434. * @param cameras The camera to detatch from.
  64435. * @hidden
  64436. */
  64437. _detachCameras(cameras: Camera[]): void;
  64438. /**
  64439. * Enables the effect on given cameras
  64440. * @param cameras The camera to enable.
  64441. * @hidden
  64442. */
  64443. _enable(cameras: Camera): void;
  64444. /**
  64445. * Enables the effect on given cameras
  64446. * @param cameras The camera to enable.
  64447. * @hidden
  64448. */
  64449. _enable(cameras: Nullable<Camera[]>): void;
  64450. /**
  64451. * Disables the effect on the given cameras
  64452. * @param cameras The camera to disable.
  64453. * @hidden
  64454. */
  64455. _disable(cameras: Camera): void;
  64456. /**
  64457. * Disables the effect on the given cameras
  64458. * @param cameras The camera to disable.
  64459. * @hidden
  64460. */
  64461. _disable(cameras: Nullable<Camera[]>): void;
  64462. /**
  64463. * Gets a list of the post processes contained in the effect.
  64464. * @param camera The camera to get the post processes on.
  64465. * @returns The list of the post processes in the effect.
  64466. */
  64467. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  64468. }
  64469. }
  64470. declare module BABYLON {
  64471. /** @hidden */
  64472. export var extractHighlightsPixelShader: {
  64473. name: string;
  64474. shader: string;
  64475. };
  64476. }
  64477. declare module BABYLON {
  64478. /**
  64479. * 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.
  64480. */
  64481. export class ExtractHighlightsPostProcess extends PostProcess {
  64482. /**
  64483. * The luminance threshold, pixels below this value will be set to black.
  64484. */
  64485. threshold: number;
  64486. /** @hidden */
  64487. _exposure: number;
  64488. /**
  64489. * Post process which has the input texture to be used when performing highlight extraction
  64490. * @hidden
  64491. */
  64492. _inputPostProcess: Nullable<PostProcess>;
  64493. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64494. }
  64495. }
  64496. declare module BABYLON {
  64497. /** @hidden */
  64498. export var bloomMergePixelShader: {
  64499. name: string;
  64500. shader: string;
  64501. };
  64502. }
  64503. declare module BABYLON {
  64504. /**
  64505. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64506. */
  64507. export class BloomMergePostProcess extends PostProcess {
  64508. /** Weight of the bloom to be added to the original input. */
  64509. weight: number;
  64510. /**
  64511. * Creates a new instance of @see BloomMergePostProcess
  64512. * @param name The name of the effect.
  64513. * @param originalFromInput Post process which's input will be used for the merge.
  64514. * @param blurred Blurred highlights post process which's output will be used.
  64515. * @param weight Weight of the bloom to be added to the original input.
  64516. * @param options The required width/height ratio to downsize to before computing the render pass.
  64517. * @param camera The camera to apply the render pass to.
  64518. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64519. * @param engine The engine which the post process will be applied. (default: current engine)
  64520. * @param reusable If the post process can be reused on the same frame. (default: false)
  64521. * @param textureType Type of textures used when performing the post process. (default: 0)
  64522. * @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)
  64523. */
  64524. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  64525. /** Weight of the bloom to be added to the original input. */
  64526. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64527. }
  64528. }
  64529. declare module BABYLON {
  64530. /**
  64531. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  64532. */
  64533. export class BloomEffect extends PostProcessRenderEffect {
  64534. private bloomScale;
  64535. /**
  64536. * @hidden Internal
  64537. */
  64538. _effects: Array<PostProcess>;
  64539. /**
  64540. * @hidden Internal
  64541. */
  64542. _downscale: ExtractHighlightsPostProcess;
  64543. private _blurX;
  64544. private _blurY;
  64545. private _merge;
  64546. /**
  64547. * The luminance threshold to find bright areas of the image to bloom.
  64548. */
  64549. get threshold(): number;
  64550. set threshold(value: number);
  64551. /**
  64552. * The strength of the bloom.
  64553. */
  64554. get weight(): number;
  64555. set weight(value: number);
  64556. /**
  64557. * Specifies the size of the bloom blur kernel, relative to the final output size
  64558. */
  64559. get kernel(): number;
  64560. set kernel(value: number);
  64561. /**
  64562. * Creates a new instance of @see BloomEffect
  64563. * @param scene The scene the effect belongs to.
  64564. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64565. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64566. * @param bloomWeight The the strength of bloom.
  64567. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64568. * @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)
  64569. */
  64570. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64571. /**
  64572. * Disposes each of the internal effects for a given camera.
  64573. * @param camera The camera to dispose the effect on.
  64574. */
  64575. disposeEffects(camera: Camera): void;
  64576. /**
  64577. * @hidden Internal
  64578. */
  64579. _updateEffects(): void;
  64580. /**
  64581. * Internal
  64582. * @returns if all the contained post processes are ready.
  64583. * @hidden
  64584. */
  64585. _isReady(): boolean;
  64586. }
  64587. }
  64588. declare module BABYLON {
  64589. /** @hidden */
  64590. export var chromaticAberrationPixelShader: {
  64591. name: string;
  64592. shader: string;
  64593. };
  64594. }
  64595. declare module BABYLON {
  64596. /**
  64597. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  64598. */
  64599. export class ChromaticAberrationPostProcess extends PostProcess {
  64600. /**
  64601. * The amount of seperation of rgb channels (default: 30)
  64602. */
  64603. aberrationAmount: number;
  64604. /**
  64605. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  64606. */
  64607. radialIntensity: number;
  64608. /**
  64609. * 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))
  64610. */
  64611. direction: Vector2;
  64612. /**
  64613. * 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))
  64614. */
  64615. centerPosition: Vector2;
  64616. /**
  64617. * Creates a new instance ChromaticAberrationPostProcess
  64618. * @param name The name of the effect.
  64619. * @param screenWidth The width of the screen to apply the effect on.
  64620. * @param screenHeight The height of the screen to apply the effect on.
  64621. * @param options The required width/height ratio to downsize to before computing the render pass.
  64622. * @param camera The camera to apply the render pass to.
  64623. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64624. * @param engine The engine which the post process will be applied. (default: current engine)
  64625. * @param reusable If the post process can be reused on the same frame. (default: false)
  64626. * @param textureType Type of textures used when performing the post process. (default: 0)
  64627. * @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)
  64628. */
  64629. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64630. }
  64631. }
  64632. declare module BABYLON {
  64633. /** @hidden */
  64634. export var circleOfConfusionPixelShader: {
  64635. name: string;
  64636. shader: string;
  64637. };
  64638. }
  64639. declare module BABYLON {
  64640. /**
  64641. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  64642. */
  64643. export class CircleOfConfusionPostProcess extends PostProcess {
  64644. /**
  64645. * 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.
  64646. */
  64647. lensSize: number;
  64648. /**
  64649. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64650. */
  64651. fStop: number;
  64652. /**
  64653. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64654. */
  64655. focusDistance: number;
  64656. /**
  64657. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  64658. */
  64659. focalLength: number;
  64660. private _depthTexture;
  64661. /**
  64662. * Creates a new instance CircleOfConfusionPostProcess
  64663. * @param name The name of the effect.
  64664. * @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.
  64665. * @param options The required width/height ratio to downsize to before computing the render pass.
  64666. * @param camera The camera to apply the render pass to.
  64667. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64668. * @param engine The engine which the post process will be applied. (default: current engine)
  64669. * @param reusable If the post process can be reused on the same frame. (default: false)
  64670. * @param textureType Type of textures used when performing the post process. (default: 0)
  64671. * @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)
  64672. */
  64673. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64674. /**
  64675. * 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.
  64676. */
  64677. set depthTexture(value: RenderTargetTexture);
  64678. }
  64679. }
  64680. declare module BABYLON {
  64681. /** @hidden */
  64682. export var colorCorrectionPixelShader: {
  64683. name: string;
  64684. shader: string;
  64685. };
  64686. }
  64687. declare module BABYLON {
  64688. /**
  64689. *
  64690. * This post-process allows the modification of rendered colors by using
  64691. * a 'look-up table' (LUT). This effect is also called Color Grading.
  64692. *
  64693. * The object needs to be provided an url to a texture containing the color
  64694. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  64695. * Use an image editing software to tweak the LUT to match your needs.
  64696. *
  64697. * For an example of a color LUT, see here:
  64698. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  64699. * For explanations on color grading, see here:
  64700. * @see http://udn.epicgames.com/Three/ColorGrading.html
  64701. *
  64702. */
  64703. export class ColorCorrectionPostProcess extends PostProcess {
  64704. private _colorTableTexture;
  64705. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64706. }
  64707. }
  64708. declare module BABYLON {
  64709. /** @hidden */
  64710. export var convolutionPixelShader: {
  64711. name: string;
  64712. shader: string;
  64713. };
  64714. }
  64715. declare module BABYLON {
  64716. /**
  64717. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  64718. * input texture to perform effects such as edge detection or sharpening
  64719. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64720. */
  64721. export class ConvolutionPostProcess extends PostProcess {
  64722. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64723. kernel: number[];
  64724. /**
  64725. * Creates a new instance ConvolutionPostProcess
  64726. * @param name The name of the effect.
  64727. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  64728. * @param options The required width/height ratio to downsize to before computing the render pass.
  64729. * @param camera The camera to apply the render pass to.
  64730. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64731. * @param engine The engine which the post process will be applied. (default: current engine)
  64732. * @param reusable If the post process can be reused on the same frame. (default: false)
  64733. * @param textureType Type of textures used when performing the post process. (default: 0)
  64734. */
  64735. constructor(name: string,
  64736. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64737. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64738. /**
  64739. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64740. */
  64741. static EdgeDetect0Kernel: number[];
  64742. /**
  64743. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64744. */
  64745. static EdgeDetect1Kernel: number[];
  64746. /**
  64747. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64748. */
  64749. static EdgeDetect2Kernel: number[];
  64750. /**
  64751. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64752. */
  64753. static SharpenKernel: number[];
  64754. /**
  64755. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64756. */
  64757. static EmbossKernel: number[];
  64758. /**
  64759. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64760. */
  64761. static GaussianKernel: number[];
  64762. }
  64763. }
  64764. declare module BABYLON {
  64765. /**
  64766. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  64767. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  64768. * based on samples that have a large difference in distance than the center pixel.
  64769. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  64770. */
  64771. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  64772. direction: Vector2;
  64773. /**
  64774. * Creates a new instance CircleOfConfusionPostProcess
  64775. * @param name The name of the effect.
  64776. * @param scene The scene the effect belongs to.
  64777. * @param direction The direction the blur should be applied.
  64778. * @param kernel The size of the kernel used to blur.
  64779. * @param options The required width/height ratio to downsize to before computing the render pass.
  64780. * @param camera The camera to apply the render pass to.
  64781. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  64782. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  64783. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64784. * @param engine The engine which the post process will be applied. (default: current engine)
  64785. * @param reusable If the post process can be reused on the same frame. (default: false)
  64786. * @param textureType Type of textures used when performing the post process. (default: 0)
  64787. * @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)
  64788. */
  64789. 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);
  64790. }
  64791. }
  64792. declare module BABYLON {
  64793. /** @hidden */
  64794. export var depthOfFieldMergePixelShader: {
  64795. name: string;
  64796. shader: string;
  64797. };
  64798. }
  64799. declare module BABYLON {
  64800. /**
  64801. * Options to be set when merging outputs from the default pipeline.
  64802. */
  64803. export class DepthOfFieldMergePostProcessOptions {
  64804. /**
  64805. * The original image to merge on top of
  64806. */
  64807. originalFromInput: PostProcess;
  64808. /**
  64809. * Parameters to perform the merge of the depth of field effect
  64810. */
  64811. depthOfField?: {
  64812. circleOfConfusion: PostProcess;
  64813. blurSteps: Array<PostProcess>;
  64814. };
  64815. /**
  64816. * Parameters to perform the merge of bloom effect
  64817. */
  64818. bloom?: {
  64819. blurred: PostProcess;
  64820. weight: number;
  64821. };
  64822. }
  64823. /**
  64824. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64825. */
  64826. export class DepthOfFieldMergePostProcess extends PostProcess {
  64827. private blurSteps;
  64828. /**
  64829. * Creates a new instance of DepthOfFieldMergePostProcess
  64830. * @param name The name of the effect.
  64831. * @param originalFromInput Post process which's input will be used for the merge.
  64832. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  64833. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  64834. * @param options The required width/height ratio to downsize to before computing the render pass.
  64835. * @param camera The camera to apply the render pass to.
  64836. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64837. * @param engine The engine which the post process will be applied. (default: current engine)
  64838. * @param reusable If the post process can be reused on the same frame. (default: false)
  64839. * @param textureType Type of textures used when performing the post process. (default: 0)
  64840. * @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)
  64841. */
  64842. 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);
  64843. /**
  64844. * Updates the effect with the current post process compile time values and recompiles the shader.
  64845. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  64846. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  64847. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  64848. * @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
  64849. * @param onCompiled Called when the shader has been compiled.
  64850. * @param onError Called if there is an error when compiling a shader.
  64851. */
  64852. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  64853. }
  64854. }
  64855. declare module BABYLON {
  64856. /**
  64857. * Specifies the level of max blur that should be applied when using the depth of field effect
  64858. */
  64859. export enum DepthOfFieldEffectBlurLevel {
  64860. /**
  64861. * Subtle blur
  64862. */
  64863. Low = 0,
  64864. /**
  64865. * Medium blur
  64866. */
  64867. Medium = 1,
  64868. /**
  64869. * Large blur
  64870. */
  64871. High = 2
  64872. }
  64873. /**
  64874. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  64875. */
  64876. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  64877. private _circleOfConfusion;
  64878. /**
  64879. * @hidden Internal, blurs from high to low
  64880. */
  64881. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  64882. private _depthOfFieldBlurY;
  64883. private _dofMerge;
  64884. /**
  64885. * @hidden Internal post processes in depth of field effect
  64886. */
  64887. _effects: Array<PostProcess>;
  64888. /**
  64889. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  64890. */
  64891. set focalLength(value: number);
  64892. get focalLength(): number;
  64893. /**
  64894. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64895. */
  64896. set fStop(value: number);
  64897. get fStop(): number;
  64898. /**
  64899. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64900. */
  64901. set focusDistance(value: number);
  64902. get focusDistance(): number;
  64903. /**
  64904. * 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.
  64905. */
  64906. set lensSize(value: number);
  64907. get lensSize(): number;
  64908. /**
  64909. * Creates a new instance DepthOfFieldEffect
  64910. * @param scene The scene the effect belongs to.
  64911. * @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.
  64912. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64913. * @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)
  64914. */
  64915. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  64916. /**
  64917. * Get the current class name of the current effet
  64918. * @returns "DepthOfFieldEffect"
  64919. */
  64920. getClassName(): string;
  64921. /**
  64922. * 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.
  64923. */
  64924. set depthTexture(value: RenderTargetTexture);
  64925. /**
  64926. * Disposes each of the internal effects for a given camera.
  64927. * @param camera The camera to dispose the effect on.
  64928. */
  64929. disposeEffects(camera: Camera): void;
  64930. /**
  64931. * @hidden Internal
  64932. */
  64933. _updateEffects(): void;
  64934. /**
  64935. * Internal
  64936. * @returns if all the contained post processes are ready.
  64937. * @hidden
  64938. */
  64939. _isReady(): boolean;
  64940. }
  64941. }
  64942. declare module BABYLON {
  64943. /** @hidden */
  64944. export var displayPassPixelShader: {
  64945. name: string;
  64946. shader: string;
  64947. };
  64948. }
  64949. declare module BABYLON {
  64950. /**
  64951. * DisplayPassPostProcess which produces an output the same as it's input
  64952. */
  64953. export class DisplayPassPostProcess extends PostProcess {
  64954. /**
  64955. * Creates the DisplayPassPostProcess
  64956. * @param name The name of the effect.
  64957. * @param options The required width/height ratio to downsize to before computing the render pass.
  64958. * @param camera The camera to apply the render pass to.
  64959. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64960. * @param engine The engine which the post process will be applied. (default: current engine)
  64961. * @param reusable If the post process can be reused on the same frame. (default: false)
  64962. */
  64963. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64964. }
  64965. }
  64966. declare module BABYLON {
  64967. /** @hidden */
  64968. export var filterPixelShader: {
  64969. name: string;
  64970. shader: string;
  64971. };
  64972. }
  64973. declare module BABYLON {
  64974. /**
  64975. * Applies a kernel filter to the image
  64976. */
  64977. export class FilterPostProcess extends PostProcess {
  64978. /** The matrix to be applied to the image */
  64979. kernelMatrix: Matrix;
  64980. /**
  64981. *
  64982. * @param name The name of the effect.
  64983. * @param kernelMatrix The matrix to be applied to the image
  64984. * @param options The required width/height ratio to downsize to before computing the render pass.
  64985. * @param camera The camera to apply the render pass to.
  64986. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64987. * @param engine The engine which the post process will be applied. (default: current engine)
  64988. * @param reusable If the post process can be reused on the same frame. (default: false)
  64989. */
  64990. constructor(name: string,
  64991. /** The matrix to be applied to the image */
  64992. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64993. }
  64994. }
  64995. declare module BABYLON {
  64996. /** @hidden */
  64997. export var fxaaPixelShader: {
  64998. name: string;
  64999. shader: string;
  65000. };
  65001. }
  65002. declare module BABYLON {
  65003. /** @hidden */
  65004. export var fxaaVertexShader: {
  65005. name: string;
  65006. shader: string;
  65007. };
  65008. }
  65009. declare module BABYLON {
  65010. /**
  65011. * Fxaa post process
  65012. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  65013. */
  65014. export class FxaaPostProcess extends PostProcess {
  65015. /** @hidden */
  65016. texelWidth: number;
  65017. /** @hidden */
  65018. texelHeight: number;
  65019. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65020. private _getDefines;
  65021. }
  65022. }
  65023. declare module BABYLON {
  65024. /** @hidden */
  65025. export var grainPixelShader: {
  65026. name: string;
  65027. shader: string;
  65028. };
  65029. }
  65030. declare module BABYLON {
  65031. /**
  65032. * The GrainPostProcess adds noise to the image at mid luminance levels
  65033. */
  65034. export class GrainPostProcess extends PostProcess {
  65035. /**
  65036. * The intensity of the grain added (default: 30)
  65037. */
  65038. intensity: number;
  65039. /**
  65040. * If the grain should be randomized on every frame
  65041. */
  65042. animated: boolean;
  65043. /**
  65044. * Creates a new instance of @see GrainPostProcess
  65045. * @param name The name of the effect.
  65046. * @param options The required width/height ratio to downsize to before computing the render pass.
  65047. * @param camera The camera to apply the render pass to.
  65048. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65049. * @param engine The engine which the post process will be applied. (default: current engine)
  65050. * @param reusable If the post process can be reused on the same frame. (default: false)
  65051. * @param textureType Type of textures used when performing the post process. (default: 0)
  65052. * @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)
  65053. */
  65054. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65055. }
  65056. }
  65057. declare module BABYLON {
  65058. /** @hidden */
  65059. export var highlightsPixelShader: {
  65060. name: string;
  65061. shader: string;
  65062. };
  65063. }
  65064. declare module BABYLON {
  65065. /**
  65066. * Extracts highlights from the image
  65067. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  65068. */
  65069. export class HighlightsPostProcess extends PostProcess {
  65070. /**
  65071. * Extracts highlights from the image
  65072. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  65073. * @param name The name of the effect.
  65074. * @param options The required width/height ratio to downsize to before computing the render pass.
  65075. * @param camera The camera to apply the render pass to.
  65076. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65077. * @param engine The engine which the post process will be applied. (default: current engine)
  65078. * @param reusable If the post process can be reused on the same frame. (default: false)
  65079. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  65080. */
  65081. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65082. }
  65083. }
  65084. declare module BABYLON {
  65085. /** @hidden */
  65086. export var mrtFragmentDeclaration: {
  65087. name: string;
  65088. shader: string;
  65089. };
  65090. }
  65091. declare module BABYLON {
  65092. /** @hidden */
  65093. export var geometryPixelShader: {
  65094. name: string;
  65095. shader: string;
  65096. };
  65097. }
  65098. declare module BABYLON {
  65099. /** @hidden */
  65100. export var geometryVertexShader: {
  65101. name: string;
  65102. shader: string;
  65103. };
  65104. }
  65105. declare module BABYLON {
  65106. /** @hidden */
  65107. interface ISavedTransformationMatrix {
  65108. world: Matrix;
  65109. viewProjection: Matrix;
  65110. }
  65111. /**
  65112. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  65113. */
  65114. export class GeometryBufferRenderer {
  65115. /**
  65116. * Constant used to retrieve the position texture index in the G-Buffer textures array
  65117. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  65118. */
  65119. static readonly POSITION_TEXTURE_TYPE: number;
  65120. /**
  65121. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  65122. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  65123. */
  65124. static readonly VELOCITY_TEXTURE_TYPE: number;
  65125. /**
  65126. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  65127. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  65128. */
  65129. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  65130. /**
  65131. * Dictionary used to store the previous transformation matrices of each rendered mesh
  65132. * in order to compute objects velocities when enableVelocity is set to "true"
  65133. * @hidden
  65134. */
  65135. _previousTransformationMatrices: {
  65136. [index: number]: ISavedTransformationMatrix;
  65137. };
  65138. /**
  65139. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  65140. * in order to compute objects velocities when enableVelocity is set to "true"
  65141. * @hidden
  65142. */
  65143. _previousBonesTransformationMatrices: {
  65144. [index: number]: Float32Array;
  65145. };
  65146. /**
  65147. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  65148. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  65149. */
  65150. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  65151. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  65152. renderTransparentMeshes: boolean;
  65153. private _scene;
  65154. private _multiRenderTarget;
  65155. private _ratio;
  65156. private _enablePosition;
  65157. private _enableVelocity;
  65158. private _enableReflectivity;
  65159. private _positionIndex;
  65160. private _velocityIndex;
  65161. private _reflectivityIndex;
  65162. protected _effect: Effect;
  65163. protected _cachedDefines: string;
  65164. /**
  65165. * Set the render list (meshes to be rendered) used in the G buffer.
  65166. */
  65167. set renderList(meshes: Mesh[]);
  65168. /**
  65169. * Gets wether or not G buffer are supported by the running hardware.
  65170. * This requires draw buffer supports
  65171. */
  65172. get isSupported(): boolean;
  65173. /**
  65174. * Returns the index of the given texture type in the G-Buffer textures array
  65175. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  65176. * @returns the index of the given texture type in the G-Buffer textures array
  65177. */
  65178. getTextureIndex(textureType: number): number;
  65179. /**
  65180. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  65181. */
  65182. get enablePosition(): boolean;
  65183. /**
  65184. * Sets whether or not objects positions are enabled for the G buffer.
  65185. */
  65186. set enablePosition(enable: boolean);
  65187. /**
  65188. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  65189. */
  65190. get enableVelocity(): boolean;
  65191. /**
  65192. * Sets wether or not objects velocities are enabled for the G buffer.
  65193. */
  65194. set enableVelocity(enable: boolean);
  65195. /**
  65196. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  65197. */
  65198. get enableReflectivity(): boolean;
  65199. /**
  65200. * Sets wether or not objects roughness are enabled for the G buffer.
  65201. */
  65202. set enableReflectivity(enable: boolean);
  65203. /**
  65204. * Gets the scene associated with the buffer.
  65205. */
  65206. get scene(): Scene;
  65207. /**
  65208. * Gets the ratio used by the buffer during its creation.
  65209. * How big is the buffer related to the main canvas.
  65210. */
  65211. get ratio(): number;
  65212. /** @hidden */
  65213. static _SceneComponentInitialization: (scene: Scene) => void;
  65214. /**
  65215. * Creates a new G Buffer for the scene
  65216. * @param scene The scene the buffer belongs to
  65217. * @param ratio How big is the buffer related to the main canvas.
  65218. */
  65219. constructor(scene: Scene, ratio?: number);
  65220. /**
  65221. * Checks wether everything is ready to render a submesh to the G buffer.
  65222. * @param subMesh the submesh to check readiness for
  65223. * @param useInstances is the mesh drawn using instance or not
  65224. * @returns true if ready otherwise false
  65225. */
  65226. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65227. /**
  65228. * Gets the current underlying G Buffer.
  65229. * @returns the buffer
  65230. */
  65231. getGBuffer(): MultiRenderTarget;
  65232. /**
  65233. * Gets the number of samples used to render the buffer (anti aliasing).
  65234. */
  65235. get samples(): number;
  65236. /**
  65237. * Sets the number of samples used to render the buffer (anti aliasing).
  65238. */
  65239. set samples(value: number);
  65240. /**
  65241. * Disposes the renderer and frees up associated resources.
  65242. */
  65243. dispose(): void;
  65244. protected _createRenderTargets(): void;
  65245. private _copyBonesTransformationMatrices;
  65246. }
  65247. }
  65248. declare module BABYLON {
  65249. interface Scene {
  65250. /** @hidden (Backing field) */
  65251. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65252. /**
  65253. * Gets or Sets the current geometry buffer associated to the scene.
  65254. */
  65255. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65256. /**
  65257. * Enables a GeometryBufferRender and associates it with the scene
  65258. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  65259. * @returns the GeometryBufferRenderer
  65260. */
  65261. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  65262. /**
  65263. * Disables the GeometryBufferRender associated with the scene
  65264. */
  65265. disableGeometryBufferRenderer(): void;
  65266. }
  65267. /**
  65268. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  65269. * in several rendering techniques.
  65270. */
  65271. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  65272. /**
  65273. * The component name helpful to identify the component in the list of scene components.
  65274. */
  65275. readonly name: string;
  65276. /**
  65277. * The scene the component belongs to.
  65278. */
  65279. scene: Scene;
  65280. /**
  65281. * Creates a new instance of the component for the given scene
  65282. * @param scene Defines the scene to register the component in
  65283. */
  65284. constructor(scene: Scene);
  65285. /**
  65286. * Registers the component in a given scene
  65287. */
  65288. register(): void;
  65289. /**
  65290. * Rebuilds the elements related to this component in case of
  65291. * context lost for instance.
  65292. */
  65293. rebuild(): void;
  65294. /**
  65295. * Disposes the component and the associated ressources
  65296. */
  65297. dispose(): void;
  65298. private _gatherRenderTargets;
  65299. }
  65300. }
  65301. declare module BABYLON {
  65302. /** @hidden */
  65303. export var motionBlurPixelShader: {
  65304. name: string;
  65305. shader: string;
  65306. };
  65307. }
  65308. declare module BABYLON {
  65309. /**
  65310. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  65311. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  65312. * As an example, all you have to do is to create the post-process:
  65313. * var mb = new BABYLON.MotionBlurPostProcess(
  65314. * 'mb', // The name of the effect.
  65315. * scene, // The scene containing the objects to blur according to their velocity.
  65316. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  65317. * camera // The camera to apply the render pass to.
  65318. * );
  65319. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  65320. */
  65321. export class MotionBlurPostProcess extends PostProcess {
  65322. /**
  65323. * Defines how much the image is blurred by the movement. Default value is equal to 1
  65324. */
  65325. motionStrength: number;
  65326. /**
  65327. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  65328. */
  65329. get motionBlurSamples(): number;
  65330. /**
  65331. * Sets the number of iterations to be used for motion blur quality
  65332. */
  65333. set motionBlurSamples(samples: number);
  65334. private _motionBlurSamples;
  65335. private _geometryBufferRenderer;
  65336. /**
  65337. * Creates a new instance MotionBlurPostProcess
  65338. * @param name The name of the effect.
  65339. * @param scene The scene containing the objects to blur according to their velocity.
  65340. * @param options The required width/height ratio to downsize to before computing the render pass.
  65341. * @param camera The camera to apply the render pass to.
  65342. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65343. * @param engine The engine which the post process will be applied. (default: current engine)
  65344. * @param reusable If the post process can be reused on the same frame. (default: false)
  65345. * @param textureType Type of textures used when performing the post process. (default: 0)
  65346. * @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)
  65347. */
  65348. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65349. /**
  65350. * Excludes the given skinned mesh from computing bones velocities.
  65351. * 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.
  65352. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  65353. */
  65354. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65355. /**
  65356. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  65357. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  65358. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  65359. */
  65360. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65361. /**
  65362. * Disposes the post process.
  65363. * @param camera The camera to dispose the post process on.
  65364. */
  65365. dispose(camera?: Camera): void;
  65366. }
  65367. }
  65368. declare module BABYLON {
  65369. /** @hidden */
  65370. export var refractionPixelShader: {
  65371. name: string;
  65372. shader: string;
  65373. };
  65374. }
  65375. declare module BABYLON {
  65376. /**
  65377. * Post process which applies a refractin texture
  65378. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65379. */
  65380. export class RefractionPostProcess extends PostProcess {
  65381. /** the base color of the refraction (used to taint the rendering) */
  65382. color: Color3;
  65383. /** simulated refraction depth */
  65384. depth: number;
  65385. /** the coefficient of the base color (0 to remove base color tainting) */
  65386. colorLevel: number;
  65387. private _refTexture;
  65388. private _ownRefractionTexture;
  65389. /**
  65390. * Gets or sets the refraction texture
  65391. * Please note that you are responsible for disposing the texture if you set it manually
  65392. */
  65393. get refractionTexture(): Texture;
  65394. set refractionTexture(value: Texture);
  65395. /**
  65396. * Initializes the RefractionPostProcess
  65397. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65398. * @param name The name of the effect.
  65399. * @param refractionTextureUrl Url of the refraction texture to use
  65400. * @param color the base color of the refraction (used to taint the rendering)
  65401. * @param depth simulated refraction depth
  65402. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  65403. * @param camera The camera to apply the render pass to.
  65404. * @param options The required width/height ratio to downsize to before computing the render pass.
  65405. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65406. * @param engine The engine which the post process will be applied. (default: current engine)
  65407. * @param reusable If the post process can be reused on the same frame. (default: false)
  65408. */
  65409. constructor(name: string, refractionTextureUrl: string,
  65410. /** the base color of the refraction (used to taint the rendering) */
  65411. color: Color3,
  65412. /** simulated refraction depth */
  65413. depth: number,
  65414. /** the coefficient of the base color (0 to remove base color tainting) */
  65415. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65416. /**
  65417. * Disposes of the post process
  65418. * @param camera Camera to dispose post process on
  65419. */
  65420. dispose(camera: Camera): void;
  65421. }
  65422. }
  65423. declare module BABYLON {
  65424. /** @hidden */
  65425. export var sharpenPixelShader: {
  65426. name: string;
  65427. shader: string;
  65428. };
  65429. }
  65430. declare module BABYLON {
  65431. /**
  65432. * The SharpenPostProcess applies a sharpen kernel to every pixel
  65433. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65434. */
  65435. export class SharpenPostProcess extends PostProcess {
  65436. /**
  65437. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  65438. */
  65439. colorAmount: number;
  65440. /**
  65441. * How much sharpness should be applied (default: 0.3)
  65442. */
  65443. edgeAmount: number;
  65444. /**
  65445. * Creates a new instance ConvolutionPostProcess
  65446. * @param name The name of the effect.
  65447. * @param options The required width/height ratio to downsize to before computing the render pass.
  65448. * @param camera The camera to apply the render pass to.
  65449. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65450. * @param engine The engine which the post process will be applied. (default: current engine)
  65451. * @param reusable If the post process can be reused on the same frame. (default: false)
  65452. * @param textureType Type of textures used when performing the post process. (default: 0)
  65453. * @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)
  65454. */
  65455. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65456. }
  65457. }
  65458. declare module BABYLON {
  65459. /**
  65460. * PostProcessRenderPipeline
  65461. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65462. */
  65463. export class PostProcessRenderPipeline {
  65464. private engine;
  65465. private _renderEffects;
  65466. private _renderEffectsForIsolatedPass;
  65467. /**
  65468. * List of inspectable custom properties (used by the Inspector)
  65469. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  65470. */
  65471. inspectableCustomProperties: IInspectable[];
  65472. /**
  65473. * @hidden
  65474. */
  65475. protected _cameras: Camera[];
  65476. /** @hidden */
  65477. _name: string;
  65478. /**
  65479. * Gets pipeline name
  65480. */
  65481. get name(): string;
  65482. /** Gets the list of attached cameras */
  65483. get cameras(): Camera[];
  65484. /**
  65485. * Initializes a PostProcessRenderPipeline
  65486. * @param engine engine to add the pipeline to
  65487. * @param name name of the pipeline
  65488. */
  65489. constructor(engine: Engine, name: string);
  65490. /**
  65491. * Gets the class name
  65492. * @returns "PostProcessRenderPipeline"
  65493. */
  65494. getClassName(): string;
  65495. /**
  65496. * If all the render effects in the pipeline are supported
  65497. */
  65498. get isSupported(): boolean;
  65499. /**
  65500. * Adds an effect to the pipeline
  65501. * @param renderEffect the effect to add
  65502. */
  65503. addEffect(renderEffect: PostProcessRenderEffect): void;
  65504. /** @hidden */
  65505. _rebuild(): void;
  65506. /** @hidden */
  65507. _enableEffect(renderEffectName: string, cameras: Camera): void;
  65508. /** @hidden */
  65509. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  65510. /** @hidden */
  65511. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65512. /** @hidden */
  65513. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65514. /** @hidden */
  65515. _attachCameras(cameras: Camera, unique: boolean): void;
  65516. /** @hidden */
  65517. _attachCameras(cameras: Camera[], unique: boolean): void;
  65518. /** @hidden */
  65519. _detachCameras(cameras: Camera): void;
  65520. /** @hidden */
  65521. _detachCameras(cameras: Nullable<Camera[]>): void;
  65522. /** @hidden */
  65523. _update(): void;
  65524. /** @hidden */
  65525. _reset(): void;
  65526. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  65527. /**
  65528. * Disposes of the pipeline
  65529. */
  65530. dispose(): void;
  65531. }
  65532. }
  65533. declare module BABYLON {
  65534. /**
  65535. * PostProcessRenderPipelineManager class
  65536. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65537. */
  65538. export class PostProcessRenderPipelineManager {
  65539. private _renderPipelines;
  65540. /**
  65541. * Initializes a PostProcessRenderPipelineManager
  65542. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65543. */
  65544. constructor();
  65545. /**
  65546. * Gets the list of supported render pipelines
  65547. */
  65548. get supportedPipelines(): PostProcessRenderPipeline[];
  65549. /**
  65550. * Adds a pipeline to the manager
  65551. * @param renderPipeline The pipeline to add
  65552. */
  65553. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65554. /**
  65555. * Attaches a camera to the pipeline
  65556. * @param renderPipelineName The name of the pipeline to attach to
  65557. * @param cameras the camera to attach
  65558. * @param unique if the camera can be attached multiple times to the pipeline
  65559. */
  65560. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65561. /**
  65562. * Detaches a camera from the pipeline
  65563. * @param renderPipelineName The name of the pipeline to detach from
  65564. * @param cameras the camera to detach
  65565. */
  65566. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  65567. /**
  65568. * Enables an effect by name on a pipeline
  65569. * @param renderPipelineName the name of the pipeline to enable the effect in
  65570. * @param renderEffectName the name of the effect to enable
  65571. * @param cameras the cameras that the effect should be enabled on
  65572. */
  65573. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65574. /**
  65575. * Disables an effect by name on a pipeline
  65576. * @param renderPipelineName the name of the pipeline to disable the effect in
  65577. * @param renderEffectName the name of the effect to disable
  65578. * @param cameras the cameras that the effect should be disabled on
  65579. */
  65580. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65581. /**
  65582. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  65583. */
  65584. update(): void;
  65585. /** @hidden */
  65586. _rebuild(): void;
  65587. /**
  65588. * Disposes of the manager and pipelines
  65589. */
  65590. dispose(): void;
  65591. }
  65592. }
  65593. declare module BABYLON {
  65594. interface Scene {
  65595. /** @hidden (Backing field) */
  65596. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65597. /**
  65598. * Gets the postprocess render pipeline manager
  65599. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65600. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65601. */
  65602. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65603. }
  65604. /**
  65605. * Defines the Render Pipeline scene component responsible to rendering pipelines
  65606. */
  65607. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  65608. /**
  65609. * The component name helpfull to identify the component in the list of scene components.
  65610. */
  65611. readonly name: string;
  65612. /**
  65613. * The scene the component belongs to.
  65614. */
  65615. scene: Scene;
  65616. /**
  65617. * Creates a new instance of the component for the given scene
  65618. * @param scene Defines the scene to register the component in
  65619. */
  65620. constructor(scene: Scene);
  65621. /**
  65622. * Registers the component in a given scene
  65623. */
  65624. register(): void;
  65625. /**
  65626. * Rebuilds the elements related to this component in case of
  65627. * context lost for instance.
  65628. */
  65629. rebuild(): void;
  65630. /**
  65631. * Disposes the component and the associated ressources
  65632. */
  65633. dispose(): void;
  65634. private _gatherRenderTargets;
  65635. }
  65636. }
  65637. declare module BABYLON {
  65638. /**
  65639. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  65640. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65641. */
  65642. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65643. private _scene;
  65644. private _camerasToBeAttached;
  65645. /**
  65646. * ID of the sharpen post process,
  65647. */
  65648. private readonly SharpenPostProcessId;
  65649. /**
  65650. * @ignore
  65651. * ID of the image processing post process;
  65652. */
  65653. readonly ImageProcessingPostProcessId: string;
  65654. /**
  65655. * @ignore
  65656. * ID of the Fast Approximate Anti-Aliasing post process;
  65657. */
  65658. readonly FxaaPostProcessId: string;
  65659. /**
  65660. * ID of the chromatic aberration post process,
  65661. */
  65662. private readonly ChromaticAberrationPostProcessId;
  65663. /**
  65664. * ID of the grain post process
  65665. */
  65666. private readonly GrainPostProcessId;
  65667. /**
  65668. * Sharpen post process which will apply a sharpen convolution to enhance edges
  65669. */
  65670. sharpen: SharpenPostProcess;
  65671. private _sharpenEffect;
  65672. private bloom;
  65673. /**
  65674. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  65675. */
  65676. depthOfField: DepthOfFieldEffect;
  65677. /**
  65678. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65679. */
  65680. fxaa: FxaaPostProcess;
  65681. /**
  65682. * Image post processing pass used to perform operations such as tone mapping or color grading.
  65683. */
  65684. imageProcessing: ImageProcessingPostProcess;
  65685. /**
  65686. * Chromatic aberration post process which will shift rgb colors in the image
  65687. */
  65688. chromaticAberration: ChromaticAberrationPostProcess;
  65689. private _chromaticAberrationEffect;
  65690. /**
  65691. * Grain post process which add noise to the image
  65692. */
  65693. grain: GrainPostProcess;
  65694. private _grainEffect;
  65695. /**
  65696. * Glow post process which adds a glow to emissive areas of the image
  65697. */
  65698. private _glowLayer;
  65699. /**
  65700. * Animations which can be used to tweak settings over a period of time
  65701. */
  65702. animations: Animation[];
  65703. private _imageProcessingConfigurationObserver;
  65704. private _sharpenEnabled;
  65705. private _bloomEnabled;
  65706. private _depthOfFieldEnabled;
  65707. private _depthOfFieldBlurLevel;
  65708. private _fxaaEnabled;
  65709. private _imageProcessingEnabled;
  65710. private _defaultPipelineTextureType;
  65711. private _bloomScale;
  65712. private _chromaticAberrationEnabled;
  65713. private _grainEnabled;
  65714. private _buildAllowed;
  65715. /**
  65716. * Gets active scene
  65717. */
  65718. get scene(): Scene;
  65719. /**
  65720. * Enable or disable the sharpen process from the pipeline
  65721. */
  65722. set sharpenEnabled(enabled: boolean);
  65723. get sharpenEnabled(): boolean;
  65724. private _resizeObserver;
  65725. private _hardwareScaleLevel;
  65726. private _bloomKernel;
  65727. /**
  65728. * Specifies the size of the bloom blur kernel, relative to the final output size
  65729. */
  65730. get bloomKernel(): number;
  65731. set bloomKernel(value: number);
  65732. /**
  65733. * Specifies the weight of the bloom in the final rendering
  65734. */
  65735. private _bloomWeight;
  65736. /**
  65737. * Specifies the luma threshold for the area that will be blurred by the bloom
  65738. */
  65739. private _bloomThreshold;
  65740. private _hdr;
  65741. /**
  65742. * The strength of the bloom.
  65743. */
  65744. set bloomWeight(value: number);
  65745. get bloomWeight(): number;
  65746. /**
  65747. * The strength of the bloom.
  65748. */
  65749. set bloomThreshold(value: number);
  65750. get bloomThreshold(): number;
  65751. /**
  65752. * The scale of the bloom, lower value will provide better performance.
  65753. */
  65754. set bloomScale(value: number);
  65755. get bloomScale(): number;
  65756. /**
  65757. * Enable or disable the bloom from the pipeline
  65758. */
  65759. set bloomEnabled(enabled: boolean);
  65760. get bloomEnabled(): boolean;
  65761. private _rebuildBloom;
  65762. /**
  65763. * If the depth of field is enabled.
  65764. */
  65765. get depthOfFieldEnabled(): boolean;
  65766. set depthOfFieldEnabled(enabled: boolean);
  65767. /**
  65768. * Blur level of the depth of field effect. (Higher blur will effect performance)
  65769. */
  65770. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  65771. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  65772. /**
  65773. * If the anti aliasing is enabled.
  65774. */
  65775. set fxaaEnabled(enabled: boolean);
  65776. get fxaaEnabled(): boolean;
  65777. private _samples;
  65778. /**
  65779. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65780. */
  65781. set samples(sampleCount: number);
  65782. get samples(): number;
  65783. /**
  65784. * If image processing is enabled.
  65785. */
  65786. set imageProcessingEnabled(enabled: boolean);
  65787. get imageProcessingEnabled(): boolean;
  65788. /**
  65789. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  65790. */
  65791. set glowLayerEnabled(enabled: boolean);
  65792. get glowLayerEnabled(): boolean;
  65793. /**
  65794. * Gets the glow layer (or null if not defined)
  65795. */
  65796. get glowLayer(): Nullable<GlowLayer>;
  65797. /**
  65798. * Enable or disable the chromaticAberration process from the pipeline
  65799. */
  65800. set chromaticAberrationEnabled(enabled: boolean);
  65801. get chromaticAberrationEnabled(): boolean;
  65802. /**
  65803. * Enable or disable the grain process from the pipeline
  65804. */
  65805. set grainEnabled(enabled: boolean);
  65806. get grainEnabled(): boolean;
  65807. /**
  65808. * @constructor
  65809. * @param name - The rendering pipeline name (default: "")
  65810. * @param hdr - If high dynamic range textures should be used (default: true)
  65811. * @param scene - The scene linked to this pipeline (default: the last created scene)
  65812. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  65813. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  65814. */
  65815. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  65816. /**
  65817. * Get the class name
  65818. * @returns "DefaultRenderingPipeline"
  65819. */
  65820. getClassName(): string;
  65821. /**
  65822. * Force the compilation of the entire pipeline.
  65823. */
  65824. prepare(): void;
  65825. private _hasCleared;
  65826. private _prevPostProcess;
  65827. private _prevPrevPostProcess;
  65828. private _setAutoClearAndTextureSharing;
  65829. private _depthOfFieldSceneObserver;
  65830. private _buildPipeline;
  65831. private _disposePostProcesses;
  65832. /**
  65833. * Adds a camera to the pipeline
  65834. * @param camera the camera to be added
  65835. */
  65836. addCamera(camera: Camera): void;
  65837. /**
  65838. * Removes a camera from the pipeline
  65839. * @param camera the camera to remove
  65840. */
  65841. removeCamera(camera: Camera): void;
  65842. /**
  65843. * Dispose of the pipeline and stop all post processes
  65844. */
  65845. dispose(): void;
  65846. /**
  65847. * Serialize the rendering pipeline (Used when exporting)
  65848. * @returns the serialized object
  65849. */
  65850. serialize(): any;
  65851. /**
  65852. * Parse the serialized pipeline
  65853. * @param source Source pipeline.
  65854. * @param scene The scene to load the pipeline to.
  65855. * @param rootUrl The URL of the serialized pipeline.
  65856. * @returns An instantiated pipeline from the serialized object.
  65857. */
  65858. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  65859. }
  65860. }
  65861. declare module BABYLON {
  65862. /** @hidden */
  65863. export var lensHighlightsPixelShader: {
  65864. name: string;
  65865. shader: string;
  65866. };
  65867. }
  65868. declare module BABYLON {
  65869. /** @hidden */
  65870. export var depthOfFieldPixelShader: {
  65871. name: string;
  65872. shader: string;
  65873. };
  65874. }
  65875. declare module BABYLON {
  65876. /**
  65877. * BABYLON.JS Chromatic Aberration GLSL Shader
  65878. * Author: Olivier Guyot
  65879. * Separates very slightly R, G and B colors on the edges of the screen
  65880. * Inspired by Francois Tarlier & Martins Upitis
  65881. */
  65882. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  65883. /**
  65884. * @ignore
  65885. * The chromatic aberration PostProcess id in the pipeline
  65886. */
  65887. LensChromaticAberrationEffect: string;
  65888. /**
  65889. * @ignore
  65890. * The highlights enhancing PostProcess id in the pipeline
  65891. */
  65892. HighlightsEnhancingEffect: string;
  65893. /**
  65894. * @ignore
  65895. * The depth-of-field PostProcess id in the pipeline
  65896. */
  65897. LensDepthOfFieldEffect: string;
  65898. private _scene;
  65899. private _depthTexture;
  65900. private _grainTexture;
  65901. private _chromaticAberrationPostProcess;
  65902. private _highlightsPostProcess;
  65903. private _depthOfFieldPostProcess;
  65904. private _edgeBlur;
  65905. private _grainAmount;
  65906. private _chromaticAberration;
  65907. private _distortion;
  65908. private _highlightsGain;
  65909. private _highlightsThreshold;
  65910. private _dofDistance;
  65911. private _dofAperture;
  65912. private _dofDarken;
  65913. private _dofPentagon;
  65914. private _blurNoise;
  65915. /**
  65916. * @constructor
  65917. *
  65918. * Effect parameters are as follow:
  65919. * {
  65920. * chromatic_aberration: number; // from 0 to x (1 for realism)
  65921. * edge_blur: number; // from 0 to x (1 for realism)
  65922. * distortion: number; // from 0 to x (1 for realism)
  65923. * grain_amount: number; // from 0 to 1
  65924. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  65925. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  65926. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  65927. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  65928. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  65929. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  65930. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  65931. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  65932. * }
  65933. * Note: if an effect parameter is unset, effect is disabled
  65934. *
  65935. * @param name The rendering pipeline name
  65936. * @param parameters - An object containing all parameters (see above)
  65937. * @param scene The scene linked to this pipeline
  65938. * @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)
  65939. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65940. */
  65941. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  65942. /**
  65943. * Get the class name
  65944. * @returns "LensRenderingPipeline"
  65945. */
  65946. getClassName(): string;
  65947. /**
  65948. * Gets associated scene
  65949. */
  65950. get scene(): Scene;
  65951. /**
  65952. * Gets or sets the edge blur
  65953. */
  65954. get edgeBlur(): number;
  65955. set edgeBlur(value: number);
  65956. /**
  65957. * Gets or sets the grain amount
  65958. */
  65959. get grainAmount(): number;
  65960. set grainAmount(value: number);
  65961. /**
  65962. * Gets or sets the chromatic aberration amount
  65963. */
  65964. get chromaticAberration(): number;
  65965. set chromaticAberration(value: number);
  65966. /**
  65967. * Gets or sets the depth of field aperture
  65968. */
  65969. get dofAperture(): number;
  65970. set dofAperture(value: number);
  65971. /**
  65972. * Gets or sets the edge distortion
  65973. */
  65974. get edgeDistortion(): number;
  65975. set edgeDistortion(value: number);
  65976. /**
  65977. * Gets or sets the depth of field distortion
  65978. */
  65979. get dofDistortion(): number;
  65980. set dofDistortion(value: number);
  65981. /**
  65982. * Gets or sets the darken out of focus amount
  65983. */
  65984. get darkenOutOfFocus(): number;
  65985. set darkenOutOfFocus(value: number);
  65986. /**
  65987. * Gets or sets a boolean indicating if blur noise is enabled
  65988. */
  65989. get blurNoise(): boolean;
  65990. set blurNoise(value: boolean);
  65991. /**
  65992. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  65993. */
  65994. get pentagonBokeh(): boolean;
  65995. set pentagonBokeh(value: boolean);
  65996. /**
  65997. * Gets or sets the highlight grain amount
  65998. */
  65999. get highlightsGain(): number;
  66000. set highlightsGain(value: number);
  66001. /**
  66002. * Gets or sets the highlight threshold
  66003. */
  66004. get highlightsThreshold(): number;
  66005. set highlightsThreshold(value: number);
  66006. /**
  66007. * Sets the amount of blur at the edges
  66008. * @param amount blur amount
  66009. */
  66010. setEdgeBlur(amount: number): void;
  66011. /**
  66012. * Sets edge blur to 0
  66013. */
  66014. disableEdgeBlur(): void;
  66015. /**
  66016. * Sets the amout of grain
  66017. * @param amount Amount of grain
  66018. */
  66019. setGrainAmount(amount: number): void;
  66020. /**
  66021. * Set grain amount to 0
  66022. */
  66023. disableGrain(): void;
  66024. /**
  66025. * Sets the chromatic aberration amount
  66026. * @param amount amount of chromatic aberration
  66027. */
  66028. setChromaticAberration(amount: number): void;
  66029. /**
  66030. * Sets chromatic aberration amount to 0
  66031. */
  66032. disableChromaticAberration(): void;
  66033. /**
  66034. * Sets the EdgeDistortion amount
  66035. * @param amount amount of EdgeDistortion
  66036. */
  66037. setEdgeDistortion(amount: number): void;
  66038. /**
  66039. * Sets edge distortion to 0
  66040. */
  66041. disableEdgeDistortion(): void;
  66042. /**
  66043. * Sets the FocusDistance amount
  66044. * @param amount amount of FocusDistance
  66045. */
  66046. setFocusDistance(amount: number): void;
  66047. /**
  66048. * Disables depth of field
  66049. */
  66050. disableDepthOfField(): void;
  66051. /**
  66052. * Sets the Aperture amount
  66053. * @param amount amount of Aperture
  66054. */
  66055. setAperture(amount: number): void;
  66056. /**
  66057. * Sets the DarkenOutOfFocus amount
  66058. * @param amount amount of DarkenOutOfFocus
  66059. */
  66060. setDarkenOutOfFocus(amount: number): void;
  66061. private _pentagonBokehIsEnabled;
  66062. /**
  66063. * Creates a pentagon bokeh effect
  66064. */
  66065. enablePentagonBokeh(): void;
  66066. /**
  66067. * Disables the pentagon bokeh effect
  66068. */
  66069. disablePentagonBokeh(): void;
  66070. /**
  66071. * Enables noise blur
  66072. */
  66073. enableNoiseBlur(): void;
  66074. /**
  66075. * Disables noise blur
  66076. */
  66077. disableNoiseBlur(): void;
  66078. /**
  66079. * Sets the HighlightsGain amount
  66080. * @param amount amount of HighlightsGain
  66081. */
  66082. setHighlightsGain(amount: number): void;
  66083. /**
  66084. * Sets the HighlightsThreshold amount
  66085. * @param amount amount of HighlightsThreshold
  66086. */
  66087. setHighlightsThreshold(amount: number): void;
  66088. /**
  66089. * Disables highlights
  66090. */
  66091. disableHighlights(): void;
  66092. /**
  66093. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  66094. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  66095. */
  66096. dispose(disableDepthRender?: boolean): void;
  66097. private _createChromaticAberrationPostProcess;
  66098. private _createHighlightsPostProcess;
  66099. private _createDepthOfFieldPostProcess;
  66100. private _createGrainTexture;
  66101. }
  66102. }
  66103. declare module BABYLON {
  66104. /** @hidden */
  66105. export var ssao2PixelShader: {
  66106. name: string;
  66107. shader: string;
  66108. };
  66109. }
  66110. declare module BABYLON {
  66111. /** @hidden */
  66112. export var ssaoCombinePixelShader: {
  66113. name: string;
  66114. shader: string;
  66115. };
  66116. }
  66117. declare module BABYLON {
  66118. /**
  66119. * Render pipeline to produce ssao effect
  66120. */
  66121. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  66122. /**
  66123. * @ignore
  66124. * The PassPostProcess id in the pipeline that contains the original scene color
  66125. */
  66126. SSAOOriginalSceneColorEffect: string;
  66127. /**
  66128. * @ignore
  66129. * The SSAO PostProcess id in the pipeline
  66130. */
  66131. SSAORenderEffect: string;
  66132. /**
  66133. * @ignore
  66134. * The horizontal blur PostProcess id in the pipeline
  66135. */
  66136. SSAOBlurHRenderEffect: string;
  66137. /**
  66138. * @ignore
  66139. * The vertical blur PostProcess id in the pipeline
  66140. */
  66141. SSAOBlurVRenderEffect: string;
  66142. /**
  66143. * @ignore
  66144. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66145. */
  66146. SSAOCombineRenderEffect: string;
  66147. /**
  66148. * The output strength of the SSAO post-process. Default value is 1.0.
  66149. */
  66150. totalStrength: number;
  66151. /**
  66152. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  66153. */
  66154. maxZ: number;
  66155. /**
  66156. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  66157. */
  66158. minZAspect: number;
  66159. private _samples;
  66160. /**
  66161. * Number of samples used for the SSAO calculations. Default value is 8
  66162. */
  66163. set samples(n: number);
  66164. get samples(): number;
  66165. private _textureSamples;
  66166. /**
  66167. * Number of samples to use for antialiasing
  66168. */
  66169. set textureSamples(n: number);
  66170. get textureSamples(): number;
  66171. /**
  66172. * Ratio object used for SSAO ratio and blur ratio
  66173. */
  66174. private _ratio;
  66175. /**
  66176. * Dynamically generated sphere sampler.
  66177. */
  66178. private _sampleSphere;
  66179. /**
  66180. * Blur filter offsets
  66181. */
  66182. private _samplerOffsets;
  66183. private _expensiveBlur;
  66184. /**
  66185. * If bilateral blur should be used
  66186. */
  66187. set expensiveBlur(b: boolean);
  66188. get expensiveBlur(): boolean;
  66189. /**
  66190. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  66191. */
  66192. radius: number;
  66193. /**
  66194. * The base color of the SSAO post-process
  66195. * The final result is "base + ssao" between [0, 1]
  66196. */
  66197. base: number;
  66198. /**
  66199. * Support test.
  66200. */
  66201. static get IsSupported(): boolean;
  66202. private _scene;
  66203. private _depthTexture;
  66204. private _normalTexture;
  66205. private _randomTexture;
  66206. private _originalColorPostProcess;
  66207. private _ssaoPostProcess;
  66208. private _blurHPostProcess;
  66209. private _blurVPostProcess;
  66210. private _ssaoCombinePostProcess;
  66211. /**
  66212. * Gets active scene
  66213. */
  66214. get scene(): Scene;
  66215. /**
  66216. * @constructor
  66217. * @param name The rendering pipeline name
  66218. * @param scene The scene linked to this pipeline
  66219. * @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 }
  66220. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66221. */
  66222. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66223. /**
  66224. * Get the class name
  66225. * @returns "SSAO2RenderingPipeline"
  66226. */
  66227. getClassName(): string;
  66228. /**
  66229. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66230. */
  66231. dispose(disableGeometryBufferRenderer?: boolean): void;
  66232. private _createBlurPostProcess;
  66233. /** @hidden */
  66234. _rebuild(): void;
  66235. private _bits;
  66236. private _radicalInverse_VdC;
  66237. private _hammersley;
  66238. private _hemisphereSample_uniform;
  66239. private _generateHemisphere;
  66240. private _createSSAOPostProcess;
  66241. private _createSSAOCombinePostProcess;
  66242. private _createRandomTexture;
  66243. /**
  66244. * Serialize the rendering pipeline (Used when exporting)
  66245. * @returns the serialized object
  66246. */
  66247. serialize(): any;
  66248. /**
  66249. * Parse the serialized pipeline
  66250. * @param source Source pipeline.
  66251. * @param scene The scene to load the pipeline to.
  66252. * @param rootUrl The URL of the serialized pipeline.
  66253. * @returns An instantiated pipeline from the serialized object.
  66254. */
  66255. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  66256. }
  66257. }
  66258. declare module BABYLON {
  66259. /** @hidden */
  66260. export var ssaoPixelShader: {
  66261. name: string;
  66262. shader: string;
  66263. };
  66264. }
  66265. declare module BABYLON {
  66266. /**
  66267. * Render pipeline to produce ssao effect
  66268. */
  66269. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  66270. /**
  66271. * @ignore
  66272. * The PassPostProcess id in the pipeline that contains the original scene color
  66273. */
  66274. SSAOOriginalSceneColorEffect: string;
  66275. /**
  66276. * @ignore
  66277. * The SSAO PostProcess id in the pipeline
  66278. */
  66279. SSAORenderEffect: string;
  66280. /**
  66281. * @ignore
  66282. * The horizontal blur PostProcess id in the pipeline
  66283. */
  66284. SSAOBlurHRenderEffect: string;
  66285. /**
  66286. * @ignore
  66287. * The vertical blur PostProcess id in the pipeline
  66288. */
  66289. SSAOBlurVRenderEffect: string;
  66290. /**
  66291. * @ignore
  66292. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66293. */
  66294. SSAOCombineRenderEffect: string;
  66295. /**
  66296. * The output strength of the SSAO post-process. Default value is 1.0.
  66297. */
  66298. totalStrength: number;
  66299. /**
  66300. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  66301. */
  66302. radius: number;
  66303. /**
  66304. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  66305. * Must not be equal to fallOff and superior to fallOff.
  66306. * Default value is 0.0075
  66307. */
  66308. area: number;
  66309. /**
  66310. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  66311. * Must not be equal to area and inferior to area.
  66312. * Default value is 0.000001
  66313. */
  66314. fallOff: number;
  66315. /**
  66316. * The base color of the SSAO post-process
  66317. * The final result is "base + ssao" between [0, 1]
  66318. */
  66319. base: number;
  66320. private _scene;
  66321. private _depthTexture;
  66322. private _randomTexture;
  66323. private _originalColorPostProcess;
  66324. private _ssaoPostProcess;
  66325. private _blurHPostProcess;
  66326. private _blurVPostProcess;
  66327. private _ssaoCombinePostProcess;
  66328. private _firstUpdate;
  66329. /**
  66330. * Gets active scene
  66331. */
  66332. get scene(): Scene;
  66333. /**
  66334. * @constructor
  66335. * @param name - The rendering pipeline name
  66336. * @param scene - The scene linked to this pipeline
  66337. * @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 }
  66338. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  66339. */
  66340. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66341. /**
  66342. * Get the class name
  66343. * @returns "SSAORenderingPipeline"
  66344. */
  66345. getClassName(): string;
  66346. /**
  66347. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66348. */
  66349. dispose(disableDepthRender?: boolean): void;
  66350. private _createBlurPostProcess;
  66351. /** @hidden */
  66352. _rebuild(): void;
  66353. private _createSSAOPostProcess;
  66354. private _createSSAOCombinePostProcess;
  66355. private _createRandomTexture;
  66356. }
  66357. }
  66358. declare module BABYLON {
  66359. /** @hidden */
  66360. export var screenSpaceReflectionPixelShader: {
  66361. name: string;
  66362. shader: string;
  66363. };
  66364. }
  66365. declare module BABYLON {
  66366. /**
  66367. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  66368. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  66369. */
  66370. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  66371. /**
  66372. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  66373. */
  66374. threshold: number;
  66375. /**
  66376. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  66377. */
  66378. strength: number;
  66379. /**
  66380. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  66381. */
  66382. reflectionSpecularFalloffExponent: number;
  66383. /**
  66384. * 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]
  66385. */
  66386. step: number;
  66387. /**
  66388. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  66389. */
  66390. roughnessFactor: number;
  66391. private _geometryBufferRenderer;
  66392. private _enableSmoothReflections;
  66393. private _reflectionSamples;
  66394. private _smoothSteps;
  66395. /**
  66396. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  66397. * @param name The name of the effect.
  66398. * @param scene The scene containing the objects to calculate reflections.
  66399. * @param options The required width/height ratio to downsize to before computing the render pass.
  66400. * @param camera The camera to apply the render pass to.
  66401. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66402. * @param engine The engine which the post process will be applied. (default: current engine)
  66403. * @param reusable If the post process can be reused on the same frame. (default: false)
  66404. * @param textureType Type of textures used when performing the post process. (default: 0)
  66405. * @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)
  66406. */
  66407. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66408. /**
  66409. * Gets wether or not smoothing reflections is enabled.
  66410. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66411. */
  66412. get enableSmoothReflections(): boolean;
  66413. /**
  66414. * Sets wether or not smoothing reflections is enabled.
  66415. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66416. */
  66417. set enableSmoothReflections(enabled: boolean);
  66418. /**
  66419. * Gets the number of samples taken while computing reflections. More samples count is high,
  66420. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66421. */
  66422. get reflectionSamples(): number;
  66423. /**
  66424. * Sets the number of samples taken while computing reflections. More samples count is high,
  66425. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66426. */
  66427. set reflectionSamples(samples: number);
  66428. /**
  66429. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  66430. * more the post-process will require GPU power and can generate a drop in FPS.
  66431. * Default value (5.0) work pretty well in all cases but can be adjusted.
  66432. */
  66433. get smoothSteps(): number;
  66434. set smoothSteps(steps: number);
  66435. private _updateEffectDefines;
  66436. }
  66437. }
  66438. declare module BABYLON {
  66439. /** @hidden */
  66440. export var standardPixelShader: {
  66441. name: string;
  66442. shader: string;
  66443. };
  66444. }
  66445. declare module BABYLON {
  66446. /**
  66447. * Standard rendering pipeline
  66448. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66449. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  66450. */
  66451. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66452. /**
  66453. * Public members
  66454. */
  66455. /**
  66456. * Post-process which contains the original scene color before the pipeline applies all the effects
  66457. */
  66458. originalPostProcess: Nullable<PostProcess>;
  66459. /**
  66460. * Post-process used to down scale an image x4
  66461. */
  66462. downSampleX4PostProcess: Nullable<PostProcess>;
  66463. /**
  66464. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  66465. */
  66466. brightPassPostProcess: Nullable<PostProcess>;
  66467. /**
  66468. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  66469. */
  66470. blurHPostProcesses: PostProcess[];
  66471. /**
  66472. * Post-process array storing all the vertical blur post-processes used by the pipeline
  66473. */
  66474. blurVPostProcesses: PostProcess[];
  66475. /**
  66476. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  66477. */
  66478. textureAdderPostProcess: Nullable<PostProcess>;
  66479. /**
  66480. * Post-process used to create volumetric lighting effect
  66481. */
  66482. volumetricLightPostProcess: Nullable<PostProcess>;
  66483. /**
  66484. * Post-process used to smooth the previous volumetric light post-process on the X axis
  66485. */
  66486. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  66487. /**
  66488. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  66489. */
  66490. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  66491. /**
  66492. * Post-process used to merge the volumetric light effect and the real scene color
  66493. */
  66494. volumetricLightMergePostProces: Nullable<PostProcess>;
  66495. /**
  66496. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  66497. */
  66498. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  66499. /**
  66500. * Base post-process used to calculate the average luminance of the final image for HDR
  66501. */
  66502. luminancePostProcess: Nullable<PostProcess>;
  66503. /**
  66504. * Post-processes used to create down sample post-processes in order to get
  66505. * the average luminance of the final image for HDR
  66506. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  66507. */
  66508. luminanceDownSamplePostProcesses: PostProcess[];
  66509. /**
  66510. * Post-process used to create a HDR effect (light adaptation)
  66511. */
  66512. hdrPostProcess: Nullable<PostProcess>;
  66513. /**
  66514. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  66515. */
  66516. textureAdderFinalPostProcess: Nullable<PostProcess>;
  66517. /**
  66518. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  66519. */
  66520. lensFlareFinalPostProcess: Nullable<PostProcess>;
  66521. /**
  66522. * Post-process used to merge the final HDR post-process and the real scene color
  66523. */
  66524. hdrFinalPostProcess: Nullable<PostProcess>;
  66525. /**
  66526. * Post-process used to create a lens flare effect
  66527. */
  66528. lensFlarePostProcess: Nullable<PostProcess>;
  66529. /**
  66530. * Post-process that merges the result of the lens flare post-process and the real scene color
  66531. */
  66532. lensFlareComposePostProcess: Nullable<PostProcess>;
  66533. /**
  66534. * Post-process used to create a motion blur effect
  66535. */
  66536. motionBlurPostProcess: Nullable<PostProcess>;
  66537. /**
  66538. * Post-process used to create a depth of field effect
  66539. */
  66540. depthOfFieldPostProcess: Nullable<PostProcess>;
  66541. /**
  66542. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66543. */
  66544. fxaaPostProcess: Nullable<FxaaPostProcess>;
  66545. /**
  66546. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  66547. */
  66548. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  66549. /**
  66550. * Represents the brightness threshold in order to configure the illuminated surfaces
  66551. */
  66552. brightThreshold: number;
  66553. /**
  66554. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66555. */
  66556. blurWidth: number;
  66557. /**
  66558. * Sets if the blur for highlighted surfaces must be only horizontal
  66559. */
  66560. horizontalBlur: boolean;
  66561. /**
  66562. * Gets the overall exposure used by the pipeline
  66563. */
  66564. get exposure(): number;
  66565. /**
  66566. * Sets the overall exposure used by the pipeline
  66567. */
  66568. set exposure(value: number);
  66569. /**
  66570. * Texture used typically to simulate "dirty" on camera lens
  66571. */
  66572. lensTexture: Nullable<Texture>;
  66573. /**
  66574. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66575. */
  66576. volumetricLightCoefficient: number;
  66577. /**
  66578. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66579. */
  66580. volumetricLightPower: number;
  66581. /**
  66582. * Used the set the blur intensity to smooth the volumetric lights
  66583. */
  66584. volumetricLightBlurScale: number;
  66585. /**
  66586. * Light (spot or directional) used to generate the volumetric lights rays
  66587. * The source light must have a shadow generate so the pipeline can get its
  66588. * depth map
  66589. */
  66590. sourceLight: Nullable<SpotLight | DirectionalLight>;
  66591. /**
  66592. * For eye adaptation, represents the minimum luminance the eye can see
  66593. */
  66594. hdrMinimumLuminance: number;
  66595. /**
  66596. * For eye adaptation, represents the decrease luminance speed
  66597. */
  66598. hdrDecreaseRate: number;
  66599. /**
  66600. * For eye adaptation, represents the increase luminance speed
  66601. */
  66602. hdrIncreaseRate: number;
  66603. /**
  66604. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66605. */
  66606. get hdrAutoExposure(): boolean;
  66607. /**
  66608. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66609. */
  66610. set hdrAutoExposure(value: boolean);
  66611. /**
  66612. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  66613. */
  66614. lensColorTexture: Nullable<Texture>;
  66615. /**
  66616. * The overall strengh for the lens flare effect
  66617. */
  66618. lensFlareStrength: number;
  66619. /**
  66620. * Dispersion coefficient for lens flare ghosts
  66621. */
  66622. lensFlareGhostDispersal: number;
  66623. /**
  66624. * Main lens flare halo width
  66625. */
  66626. lensFlareHaloWidth: number;
  66627. /**
  66628. * Based on the lens distortion effect, defines how much the lens flare result
  66629. * is distorted
  66630. */
  66631. lensFlareDistortionStrength: number;
  66632. /**
  66633. * Configures the blur intensity used for for lens flare (halo)
  66634. */
  66635. lensFlareBlurWidth: number;
  66636. /**
  66637. * Lens star texture must be used to simulate rays on the flares and is available
  66638. * in the documentation
  66639. */
  66640. lensStarTexture: Nullable<Texture>;
  66641. /**
  66642. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  66643. * flare effect by taking account of the dirt texture
  66644. */
  66645. lensFlareDirtTexture: Nullable<Texture>;
  66646. /**
  66647. * Represents the focal length for the depth of field effect
  66648. */
  66649. depthOfFieldDistance: number;
  66650. /**
  66651. * Represents the blur intensity for the blurred part of the depth of field effect
  66652. */
  66653. depthOfFieldBlurWidth: number;
  66654. /**
  66655. * Gets how much the image is blurred by the movement while using the motion blur post-process
  66656. */
  66657. get motionStrength(): number;
  66658. /**
  66659. * Sets how much the image is blurred by the movement while using the motion blur post-process
  66660. */
  66661. set motionStrength(strength: number);
  66662. /**
  66663. * Gets wether or not the motion blur post-process is object based or screen based.
  66664. */
  66665. get objectBasedMotionBlur(): boolean;
  66666. /**
  66667. * Sets wether or not the motion blur post-process should be object based or screen based
  66668. */
  66669. set objectBasedMotionBlur(value: boolean);
  66670. /**
  66671. * List of animations for the pipeline (IAnimatable implementation)
  66672. */
  66673. animations: Animation[];
  66674. /**
  66675. * Private members
  66676. */
  66677. private _scene;
  66678. private _currentDepthOfFieldSource;
  66679. private _basePostProcess;
  66680. private _fixedExposure;
  66681. private _currentExposure;
  66682. private _hdrAutoExposure;
  66683. private _hdrCurrentLuminance;
  66684. private _motionStrength;
  66685. private _isObjectBasedMotionBlur;
  66686. private _floatTextureType;
  66687. private _camerasToBeAttached;
  66688. private _ratio;
  66689. private _bloomEnabled;
  66690. private _depthOfFieldEnabled;
  66691. private _vlsEnabled;
  66692. private _lensFlareEnabled;
  66693. private _hdrEnabled;
  66694. private _motionBlurEnabled;
  66695. private _fxaaEnabled;
  66696. private _screenSpaceReflectionsEnabled;
  66697. private _motionBlurSamples;
  66698. private _volumetricLightStepsCount;
  66699. private _samples;
  66700. /**
  66701. * @ignore
  66702. * Specifies if the bloom pipeline is enabled
  66703. */
  66704. get BloomEnabled(): boolean;
  66705. set BloomEnabled(enabled: boolean);
  66706. /**
  66707. * @ignore
  66708. * Specifies if the depth of field pipeline is enabed
  66709. */
  66710. get DepthOfFieldEnabled(): boolean;
  66711. set DepthOfFieldEnabled(enabled: boolean);
  66712. /**
  66713. * @ignore
  66714. * Specifies if the lens flare pipeline is enabed
  66715. */
  66716. get LensFlareEnabled(): boolean;
  66717. set LensFlareEnabled(enabled: boolean);
  66718. /**
  66719. * @ignore
  66720. * Specifies if the HDR pipeline is enabled
  66721. */
  66722. get HDREnabled(): boolean;
  66723. set HDREnabled(enabled: boolean);
  66724. /**
  66725. * @ignore
  66726. * Specifies if the volumetric lights scattering effect is enabled
  66727. */
  66728. get VLSEnabled(): boolean;
  66729. set VLSEnabled(enabled: boolean);
  66730. /**
  66731. * @ignore
  66732. * Specifies if the motion blur effect is enabled
  66733. */
  66734. get MotionBlurEnabled(): boolean;
  66735. set MotionBlurEnabled(enabled: boolean);
  66736. /**
  66737. * Specifies if anti-aliasing is enabled
  66738. */
  66739. get fxaaEnabled(): boolean;
  66740. set fxaaEnabled(enabled: boolean);
  66741. /**
  66742. * Specifies if screen space reflections are enabled.
  66743. */
  66744. get screenSpaceReflectionsEnabled(): boolean;
  66745. set screenSpaceReflectionsEnabled(enabled: boolean);
  66746. /**
  66747. * Specifies the number of steps used to calculate the volumetric lights
  66748. * Typically in interval [50, 200]
  66749. */
  66750. get volumetricLightStepsCount(): number;
  66751. set volumetricLightStepsCount(count: number);
  66752. /**
  66753. * Specifies the number of samples used for the motion blur effect
  66754. * Typically in interval [16, 64]
  66755. */
  66756. get motionBlurSamples(): number;
  66757. set motionBlurSamples(samples: number);
  66758. /**
  66759. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66760. */
  66761. get samples(): number;
  66762. set samples(sampleCount: number);
  66763. /**
  66764. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66765. * @constructor
  66766. * @param name The rendering pipeline name
  66767. * @param scene The scene linked to this pipeline
  66768. * @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)
  66769. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  66770. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66771. */
  66772. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  66773. private _buildPipeline;
  66774. private _createDownSampleX4PostProcess;
  66775. private _createBrightPassPostProcess;
  66776. private _createBlurPostProcesses;
  66777. private _createTextureAdderPostProcess;
  66778. private _createVolumetricLightPostProcess;
  66779. private _createLuminancePostProcesses;
  66780. private _createHdrPostProcess;
  66781. private _createLensFlarePostProcess;
  66782. private _createDepthOfFieldPostProcess;
  66783. private _createMotionBlurPostProcess;
  66784. private _getDepthTexture;
  66785. private _disposePostProcesses;
  66786. /**
  66787. * Dispose of the pipeline and stop all post processes
  66788. */
  66789. dispose(): void;
  66790. /**
  66791. * Serialize the rendering pipeline (Used when exporting)
  66792. * @returns the serialized object
  66793. */
  66794. serialize(): any;
  66795. /**
  66796. * Parse the serialized pipeline
  66797. * @param source Source pipeline.
  66798. * @param scene The scene to load the pipeline to.
  66799. * @param rootUrl The URL of the serialized pipeline.
  66800. * @returns An instantiated pipeline from the serialized object.
  66801. */
  66802. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  66803. /**
  66804. * Luminance steps
  66805. */
  66806. static LuminanceSteps: number;
  66807. }
  66808. }
  66809. declare module BABYLON {
  66810. /** @hidden */
  66811. export var tonemapPixelShader: {
  66812. name: string;
  66813. shader: string;
  66814. };
  66815. }
  66816. declare module BABYLON {
  66817. /** Defines operator used for tonemapping */
  66818. export enum TonemappingOperator {
  66819. /** Hable */
  66820. Hable = 0,
  66821. /** Reinhard */
  66822. Reinhard = 1,
  66823. /** HejiDawson */
  66824. HejiDawson = 2,
  66825. /** Photographic */
  66826. Photographic = 3
  66827. }
  66828. /**
  66829. * Defines a post process to apply tone mapping
  66830. */
  66831. export class TonemapPostProcess extends PostProcess {
  66832. private _operator;
  66833. /** Defines the required exposure adjustement */
  66834. exposureAdjustment: number;
  66835. /**
  66836. * Creates a new TonemapPostProcess
  66837. * @param name defines the name of the postprocess
  66838. * @param _operator defines the operator to use
  66839. * @param exposureAdjustment defines the required exposure adjustement
  66840. * @param camera defines the camera to use (can be null)
  66841. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  66842. * @param engine defines the hosting engine (can be ignore if camera is set)
  66843. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66844. */
  66845. constructor(name: string, _operator: TonemappingOperator,
  66846. /** Defines the required exposure adjustement */
  66847. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  66848. }
  66849. }
  66850. declare module BABYLON {
  66851. /** @hidden */
  66852. export var volumetricLightScatteringPixelShader: {
  66853. name: string;
  66854. shader: string;
  66855. };
  66856. }
  66857. declare module BABYLON {
  66858. /** @hidden */
  66859. export var volumetricLightScatteringPassVertexShader: {
  66860. name: string;
  66861. shader: string;
  66862. };
  66863. }
  66864. declare module BABYLON {
  66865. /** @hidden */
  66866. export var volumetricLightScatteringPassPixelShader: {
  66867. name: string;
  66868. shader: string;
  66869. };
  66870. }
  66871. declare module BABYLON {
  66872. /**
  66873. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  66874. */
  66875. export class VolumetricLightScatteringPostProcess extends PostProcess {
  66876. private _volumetricLightScatteringPass;
  66877. private _volumetricLightScatteringRTT;
  66878. private _viewPort;
  66879. private _screenCoordinates;
  66880. private _cachedDefines;
  66881. /**
  66882. * If not undefined, the mesh position is computed from the attached node position
  66883. */
  66884. attachedNode: {
  66885. position: Vector3;
  66886. };
  66887. /**
  66888. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  66889. */
  66890. customMeshPosition: Vector3;
  66891. /**
  66892. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  66893. */
  66894. useCustomMeshPosition: boolean;
  66895. /**
  66896. * If the post-process should inverse the light scattering direction
  66897. */
  66898. invert: boolean;
  66899. /**
  66900. * The internal mesh used by the post-process
  66901. */
  66902. mesh: Mesh;
  66903. /**
  66904. * @hidden
  66905. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  66906. */
  66907. get useDiffuseColor(): boolean;
  66908. set useDiffuseColor(useDiffuseColor: boolean);
  66909. /**
  66910. * Array containing the excluded meshes not rendered in the internal pass
  66911. */
  66912. excludedMeshes: AbstractMesh[];
  66913. /**
  66914. * Controls the overall intensity of the post-process
  66915. */
  66916. exposure: number;
  66917. /**
  66918. * Dissipates each sample's contribution in range [0, 1]
  66919. */
  66920. decay: number;
  66921. /**
  66922. * Controls the overall intensity of each sample
  66923. */
  66924. weight: number;
  66925. /**
  66926. * Controls the density of each sample
  66927. */
  66928. density: number;
  66929. /**
  66930. * @constructor
  66931. * @param name The post-process name
  66932. * @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)
  66933. * @param camera The camera that the post-process will be attached to
  66934. * @param mesh The mesh used to create the light scattering
  66935. * @param samples The post-process quality, default 100
  66936. * @param samplingModeThe post-process filtering mode
  66937. * @param engine The babylon engine
  66938. * @param reusable If the post-process is reusable
  66939. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  66940. */
  66941. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  66942. /**
  66943. * Returns the string "VolumetricLightScatteringPostProcess"
  66944. * @returns "VolumetricLightScatteringPostProcess"
  66945. */
  66946. getClassName(): string;
  66947. private _isReady;
  66948. /**
  66949. * Sets the new light position for light scattering effect
  66950. * @param position The new custom light position
  66951. */
  66952. setCustomMeshPosition(position: Vector3): void;
  66953. /**
  66954. * Returns the light position for light scattering effect
  66955. * @return Vector3 The custom light position
  66956. */
  66957. getCustomMeshPosition(): Vector3;
  66958. /**
  66959. * Disposes the internal assets and detaches the post-process from the camera
  66960. */
  66961. dispose(camera: Camera): void;
  66962. /**
  66963. * Returns the render target texture used by the post-process
  66964. * @return the render target texture used by the post-process
  66965. */
  66966. getPass(): RenderTargetTexture;
  66967. private _meshExcluded;
  66968. private _createPass;
  66969. private _updateMeshScreenCoordinates;
  66970. /**
  66971. * Creates a default mesh for the Volumeric Light Scattering post-process
  66972. * @param name The mesh name
  66973. * @param scene The scene where to create the mesh
  66974. * @return the default mesh
  66975. */
  66976. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  66977. }
  66978. }
  66979. declare module BABYLON {
  66980. interface Scene {
  66981. /** @hidden (Backing field) */
  66982. _boundingBoxRenderer: BoundingBoxRenderer;
  66983. /** @hidden (Backing field) */
  66984. _forceShowBoundingBoxes: boolean;
  66985. /**
  66986. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  66987. */
  66988. forceShowBoundingBoxes: boolean;
  66989. /**
  66990. * Gets the bounding box renderer associated with the scene
  66991. * @returns a BoundingBoxRenderer
  66992. */
  66993. getBoundingBoxRenderer(): BoundingBoxRenderer;
  66994. }
  66995. interface AbstractMesh {
  66996. /** @hidden (Backing field) */
  66997. _showBoundingBox: boolean;
  66998. /**
  66999. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  67000. */
  67001. showBoundingBox: boolean;
  67002. }
  67003. /**
  67004. * Component responsible of rendering the bounding box of the meshes in a scene.
  67005. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  67006. */
  67007. export class BoundingBoxRenderer implements ISceneComponent {
  67008. /**
  67009. * The component name helpfull to identify the component in the list of scene components.
  67010. */
  67011. readonly name: string;
  67012. /**
  67013. * The scene the component belongs to.
  67014. */
  67015. scene: Scene;
  67016. /**
  67017. * Color of the bounding box lines placed in front of an object
  67018. */
  67019. frontColor: Color3;
  67020. /**
  67021. * Color of the bounding box lines placed behind an object
  67022. */
  67023. backColor: Color3;
  67024. /**
  67025. * Defines if the renderer should show the back lines or not
  67026. */
  67027. showBackLines: boolean;
  67028. /**
  67029. * @hidden
  67030. */
  67031. renderList: SmartArray<BoundingBox>;
  67032. private _colorShader;
  67033. private _vertexBuffers;
  67034. private _indexBuffer;
  67035. private _fillIndexBuffer;
  67036. private _fillIndexData;
  67037. /**
  67038. * Instantiates a new bounding box renderer in a scene.
  67039. * @param scene the scene the renderer renders in
  67040. */
  67041. constructor(scene: Scene);
  67042. /**
  67043. * Registers the component in a given scene
  67044. */
  67045. register(): void;
  67046. private _evaluateSubMesh;
  67047. private _activeMesh;
  67048. private _prepareRessources;
  67049. private _createIndexBuffer;
  67050. /**
  67051. * Rebuilds the elements related to this component in case of
  67052. * context lost for instance.
  67053. */
  67054. rebuild(): void;
  67055. /**
  67056. * @hidden
  67057. */
  67058. reset(): void;
  67059. /**
  67060. * Render the bounding boxes of a specific rendering group
  67061. * @param renderingGroupId defines the rendering group to render
  67062. */
  67063. render(renderingGroupId: number): void;
  67064. /**
  67065. * In case of occlusion queries, we can render the occlusion bounding box through this method
  67066. * @param mesh Define the mesh to render the occlusion bounding box for
  67067. */
  67068. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  67069. /**
  67070. * Dispose and release the resources attached to this renderer.
  67071. */
  67072. dispose(): void;
  67073. }
  67074. }
  67075. declare module BABYLON {
  67076. interface Scene {
  67077. /** @hidden (Backing field) */
  67078. _depthRenderer: {
  67079. [id: string]: DepthRenderer;
  67080. };
  67081. /**
  67082. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  67083. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  67084. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  67085. * @returns the created depth renderer
  67086. */
  67087. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  67088. /**
  67089. * Disables a depth renderer for a given camera
  67090. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  67091. */
  67092. disableDepthRenderer(camera?: Nullable<Camera>): void;
  67093. }
  67094. /**
  67095. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  67096. * in several rendering techniques.
  67097. */
  67098. export class DepthRendererSceneComponent implements ISceneComponent {
  67099. /**
  67100. * The component name helpfull to identify the component in the list of scene components.
  67101. */
  67102. readonly name: string;
  67103. /**
  67104. * The scene the component belongs to.
  67105. */
  67106. scene: Scene;
  67107. /**
  67108. * Creates a new instance of the component for the given scene
  67109. * @param scene Defines the scene to register the component in
  67110. */
  67111. constructor(scene: Scene);
  67112. /**
  67113. * Registers the component in a given scene
  67114. */
  67115. register(): void;
  67116. /**
  67117. * Rebuilds the elements related to this component in case of
  67118. * context lost for instance.
  67119. */
  67120. rebuild(): void;
  67121. /**
  67122. * Disposes the component and the associated ressources
  67123. */
  67124. dispose(): void;
  67125. private _gatherRenderTargets;
  67126. private _gatherActiveCameraRenderTargets;
  67127. }
  67128. }
  67129. declare module BABYLON {
  67130. /** @hidden */
  67131. export var outlinePixelShader: {
  67132. name: string;
  67133. shader: string;
  67134. };
  67135. }
  67136. declare module BABYLON {
  67137. /** @hidden */
  67138. export var outlineVertexShader: {
  67139. name: string;
  67140. shader: string;
  67141. };
  67142. }
  67143. declare module BABYLON {
  67144. interface Scene {
  67145. /** @hidden */
  67146. _outlineRenderer: OutlineRenderer;
  67147. /**
  67148. * Gets the outline renderer associated with the scene
  67149. * @returns a OutlineRenderer
  67150. */
  67151. getOutlineRenderer(): OutlineRenderer;
  67152. }
  67153. interface AbstractMesh {
  67154. /** @hidden (Backing field) */
  67155. _renderOutline: boolean;
  67156. /**
  67157. * Gets or sets a boolean indicating if the outline must be rendered as well
  67158. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  67159. */
  67160. renderOutline: boolean;
  67161. /** @hidden (Backing field) */
  67162. _renderOverlay: boolean;
  67163. /**
  67164. * Gets or sets a boolean indicating if the overlay must be rendered as well
  67165. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  67166. */
  67167. renderOverlay: boolean;
  67168. }
  67169. /**
  67170. * This class is responsible to draw bothe outline/overlay of meshes.
  67171. * It should not be used directly but through the available method on mesh.
  67172. */
  67173. export class OutlineRenderer implements ISceneComponent {
  67174. /**
  67175. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  67176. */
  67177. private static _StencilReference;
  67178. /**
  67179. * The name of the component. Each component must have a unique name.
  67180. */
  67181. name: string;
  67182. /**
  67183. * The scene the component belongs to.
  67184. */
  67185. scene: Scene;
  67186. /**
  67187. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  67188. */
  67189. zOffset: number;
  67190. private _engine;
  67191. private _effect;
  67192. private _cachedDefines;
  67193. private _savedDepthWrite;
  67194. /**
  67195. * Instantiates a new outline renderer. (There could be only one per scene).
  67196. * @param scene Defines the scene it belongs to
  67197. */
  67198. constructor(scene: Scene);
  67199. /**
  67200. * Register the component to one instance of a scene.
  67201. */
  67202. register(): void;
  67203. /**
  67204. * Rebuilds the elements related to this component in case of
  67205. * context lost for instance.
  67206. */
  67207. rebuild(): void;
  67208. /**
  67209. * Disposes the component and the associated ressources.
  67210. */
  67211. dispose(): void;
  67212. /**
  67213. * Renders the outline in the canvas.
  67214. * @param subMesh Defines the sumesh to render
  67215. * @param batch Defines the batch of meshes in case of instances
  67216. * @param useOverlay Defines if the rendering is for the overlay or the outline
  67217. */
  67218. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  67219. /**
  67220. * Returns whether or not the outline renderer is ready for a given submesh.
  67221. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  67222. * @param subMesh Defines the submesh to check readyness for
  67223. * @param useInstances Defines wheter wee are trying to render instances or not
  67224. * @returns true if ready otherwise false
  67225. */
  67226. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67227. private _beforeRenderingMesh;
  67228. private _afterRenderingMesh;
  67229. }
  67230. }
  67231. declare module BABYLON {
  67232. /**
  67233. * Defines the basic options interface of a Sprite Frame Source Size.
  67234. */
  67235. export interface ISpriteJSONSpriteSourceSize {
  67236. /**
  67237. * number of the original width of the Frame
  67238. */
  67239. w: number;
  67240. /**
  67241. * number of the original height of the Frame
  67242. */
  67243. h: number;
  67244. }
  67245. /**
  67246. * Defines the basic options interface of a Sprite Frame Data.
  67247. */
  67248. export interface ISpriteJSONSpriteFrameData {
  67249. /**
  67250. * number of the x offset of the Frame
  67251. */
  67252. x: number;
  67253. /**
  67254. * number of the y offset of the Frame
  67255. */
  67256. y: number;
  67257. /**
  67258. * number of the width of the Frame
  67259. */
  67260. w: number;
  67261. /**
  67262. * number of the height of the Frame
  67263. */
  67264. h: number;
  67265. }
  67266. /**
  67267. * Defines the basic options interface of a JSON Sprite.
  67268. */
  67269. export interface ISpriteJSONSprite {
  67270. /**
  67271. * string name of the Frame
  67272. */
  67273. filename: string;
  67274. /**
  67275. * ISpriteJSONSpriteFrame basic object of the frame data
  67276. */
  67277. frame: ISpriteJSONSpriteFrameData;
  67278. /**
  67279. * boolean to flag is the frame was rotated.
  67280. */
  67281. rotated: boolean;
  67282. /**
  67283. * boolean to flag is the frame was trimmed.
  67284. */
  67285. trimmed: boolean;
  67286. /**
  67287. * ISpriteJSONSpriteFrame basic object of the source data
  67288. */
  67289. spriteSourceSize: ISpriteJSONSpriteFrameData;
  67290. /**
  67291. * ISpriteJSONSpriteFrame basic object of the source data
  67292. */
  67293. sourceSize: ISpriteJSONSpriteSourceSize;
  67294. }
  67295. /**
  67296. * Defines the basic options interface of a JSON atlas.
  67297. */
  67298. export interface ISpriteJSONAtlas {
  67299. /**
  67300. * Array of objects that contain the frame data.
  67301. */
  67302. frames: Array<ISpriteJSONSprite>;
  67303. /**
  67304. * object basic object containing the sprite meta data.
  67305. */
  67306. meta?: object;
  67307. }
  67308. }
  67309. declare module BABYLON {
  67310. /** @hidden */
  67311. export var spriteMapPixelShader: {
  67312. name: string;
  67313. shader: string;
  67314. };
  67315. }
  67316. declare module BABYLON {
  67317. /** @hidden */
  67318. export var spriteMapVertexShader: {
  67319. name: string;
  67320. shader: string;
  67321. };
  67322. }
  67323. declare module BABYLON {
  67324. /**
  67325. * Defines the basic options interface of a SpriteMap
  67326. */
  67327. export interface ISpriteMapOptions {
  67328. /**
  67329. * Vector2 of the number of cells in the grid.
  67330. */
  67331. stageSize?: Vector2;
  67332. /**
  67333. * Vector2 of the size of the output plane in World Units.
  67334. */
  67335. outputSize?: Vector2;
  67336. /**
  67337. * Vector3 of the position of the output plane in World Units.
  67338. */
  67339. outputPosition?: Vector3;
  67340. /**
  67341. * Vector3 of the rotation of the output plane.
  67342. */
  67343. outputRotation?: Vector3;
  67344. /**
  67345. * number of layers that the system will reserve in resources.
  67346. */
  67347. layerCount?: number;
  67348. /**
  67349. * number of max animation frames a single cell will reserve in resources.
  67350. */
  67351. maxAnimationFrames?: number;
  67352. /**
  67353. * number cell index of the base tile when the system compiles.
  67354. */
  67355. baseTile?: number;
  67356. /**
  67357. * boolean flip the sprite after its been repositioned by the framing data.
  67358. */
  67359. flipU?: boolean;
  67360. /**
  67361. * Vector3 scalar of the global RGB values of the SpriteMap.
  67362. */
  67363. colorMultiply?: Vector3;
  67364. }
  67365. /**
  67366. * Defines the IDisposable interface in order to be cleanable from resources.
  67367. */
  67368. export interface ISpriteMap extends IDisposable {
  67369. /**
  67370. * String name of the SpriteMap.
  67371. */
  67372. name: string;
  67373. /**
  67374. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  67375. */
  67376. atlasJSON: ISpriteJSONAtlas;
  67377. /**
  67378. * Texture of the SpriteMap.
  67379. */
  67380. spriteSheet: Texture;
  67381. /**
  67382. * The parameters to initialize the SpriteMap with.
  67383. */
  67384. options: ISpriteMapOptions;
  67385. }
  67386. /**
  67387. * Class used to manage a grid restricted sprite deployment on an Output plane.
  67388. */
  67389. export class SpriteMap implements ISpriteMap {
  67390. /** The Name of the spriteMap */
  67391. name: string;
  67392. /** The JSON file with the frame and meta data */
  67393. atlasJSON: ISpriteJSONAtlas;
  67394. /** The systems Sprite Sheet Texture */
  67395. spriteSheet: Texture;
  67396. /** Arguments passed with the Constructor */
  67397. options: ISpriteMapOptions;
  67398. /** Public Sprite Storage array, parsed from atlasJSON */
  67399. sprites: Array<ISpriteJSONSprite>;
  67400. /** Returns the Number of Sprites in the System */
  67401. get spriteCount(): number;
  67402. /** Returns the Position of Output Plane*/
  67403. get position(): Vector3;
  67404. /** Returns the Position of Output Plane*/
  67405. set position(v: Vector3);
  67406. /** Returns the Rotation of Output Plane*/
  67407. get rotation(): Vector3;
  67408. /** Returns the Rotation of Output Plane*/
  67409. set rotation(v: Vector3);
  67410. /** Sets the AnimationMap*/
  67411. get animationMap(): RawTexture;
  67412. /** Sets the AnimationMap*/
  67413. set animationMap(v: RawTexture);
  67414. /** Scene that the SpriteMap was created in */
  67415. private _scene;
  67416. /** Texture Buffer of Float32 that holds tile frame data*/
  67417. private _frameMap;
  67418. /** Texture Buffers of Float32 that holds tileMap data*/
  67419. private _tileMaps;
  67420. /** Texture Buffer of Float32 that holds Animation Data*/
  67421. private _animationMap;
  67422. /** Custom ShaderMaterial Central to the System*/
  67423. private _material;
  67424. /** Custom ShaderMaterial Central to the System*/
  67425. private _output;
  67426. /** Systems Time Ticker*/
  67427. private _time;
  67428. /**
  67429. * Creates a new SpriteMap
  67430. * @param name defines the SpriteMaps Name
  67431. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  67432. * @param spriteSheet is the Texture that the Sprites are on.
  67433. * @param options a basic deployment configuration
  67434. * @param scene The Scene that the map is deployed on
  67435. */
  67436. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  67437. /**
  67438. * Returns tileID location
  67439. * @returns Vector2 the cell position ID
  67440. */
  67441. getTileID(): Vector2;
  67442. /**
  67443. * Gets the UV location of the mouse over the SpriteMap.
  67444. * @returns Vector2 the UV position of the mouse interaction
  67445. */
  67446. getMousePosition(): Vector2;
  67447. /**
  67448. * Creates the "frame" texture Buffer
  67449. * -------------------------------------
  67450. * Structure of frames
  67451. * "filename": "Falling-Water-2.png",
  67452. * "frame": {"x":69,"y":103,"w":24,"h":32},
  67453. * "rotated": true,
  67454. * "trimmed": true,
  67455. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  67456. * "sourceSize": {"w":32,"h":32}
  67457. * @returns RawTexture of the frameMap
  67458. */
  67459. private _createFrameBuffer;
  67460. /**
  67461. * Creates the tileMap texture Buffer
  67462. * @param buffer normally and array of numbers, or a false to generate from scratch
  67463. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  67464. * @returns RawTexture of the tileMap
  67465. */
  67466. private _createTileBuffer;
  67467. /**
  67468. * Modifies the data of the tileMaps
  67469. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  67470. * @param pos is the iVector2 Coordinates of the Tile
  67471. * @param tile The SpriteIndex of the new Tile
  67472. */
  67473. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  67474. /**
  67475. * Creates the animationMap texture Buffer
  67476. * @param buffer normally and array of numbers, or a false to generate from scratch
  67477. * @returns RawTexture of the animationMap
  67478. */
  67479. private _createTileAnimationBuffer;
  67480. /**
  67481. * Modifies the data of the animationMap
  67482. * @param cellID is the Index of the Sprite
  67483. * @param _frame is the target Animation frame
  67484. * @param toCell is the Target Index of the next frame of the animation
  67485. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  67486. * @param speed is a global scalar of the time variable on the map.
  67487. */
  67488. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  67489. /**
  67490. * Exports the .tilemaps file
  67491. */
  67492. saveTileMaps(): void;
  67493. /**
  67494. * Imports the .tilemaps file
  67495. * @param url of the .tilemaps file
  67496. */
  67497. loadTileMaps(url: string): void;
  67498. /**
  67499. * Release associated resources
  67500. */
  67501. dispose(): void;
  67502. }
  67503. }
  67504. declare module BABYLON {
  67505. /**
  67506. * Class used to manage multiple sprites of different sizes on the same spritesheet
  67507. * @see http://doc.babylonjs.com/babylon101/sprites
  67508. */
  67509. export class SpritePackedManager extends SpriteManager {
  67510. /** defines the packed manager's name */
  67511. name: string;
  67512. /**
  67513. * Creates a new sprite manager from a packed sprite sheet
  67514. * @param name defines the manager's name
  67515. * @param imgUrl defines the sprite sheet url
  67516. * @param capacity defines the maximum allowed number of sprites
  67517. * @param scene defines the hosting scene
  67518. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  67519. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  67520. * @param samplingMode defines the smapling mode to use with spritesheet
  67521. * @param fromPacked set to true; do not alter
  67522. */
  67523. constructor(
  67524. /** defines the packed manager's name */
  67525. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  67526. }
  67527. }
  67528. declare module BABYLON {
  67529. /**
  67530. * Defines the list of states available for a task inside a AssetsManager
  67531. */
  67532. export enum AssetTaskState {
  67533. /**
  67534. * Initialization
  67535. */
  67536. INIT = 0,
  67537. /**
  67538. * Running
  67539. */
  67540. RUNNING = 1,
  67541. /**
  67542. * Done
  67543. */
  67544. DONE = 2,
  67545. /**
  67546. * Error
  67547. */
  67548. ERROR = 3
  67549. }
  67550. /**
  67551. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  67552. */
  67553. export abstract class AbstractAssetTask {
  67554. /**
  67555. * Task name
  67556. */ name: string;
  67557. /**
  67558. * Callback called when the task is successful
  67559. */
  67560. onSuccess: (task: any) => void;
  67561. /**
  67562. * Callback called when the task is not successful
  67563. */
  67564. onError: (task: any, message?: string, exception?: any) => void;
  67565. /**
  67566. * Creates a new AssetsManager
  67567. * @param name defines the name of the task
  67568. */
  67569. constructor(
  67570. /**
  67571. * Task name
  67572. */ name: string);
  67573. private _isCompleted;
  67574. private _taskState;
  67575. private _errorObject;
  67576. /**
  67577. * Get if the task is completed
  67578. */
  67579. get isCompleted(): boolean;
  67580. /**
  67581. * Gets the current state of the task
  67582. */
  67583. get taskState(): AssetTaskState;
  67584. /**
  67585. * Gets the current error object (if task is in error)
  67586. */
  67587. get errorObject(): {
  67588. message?: string;
  67589. exception?: any;
  67590. };
  67591. /**
  67592. * Internal only
  67593. * @hidden
  67594. */
  67595. _setErrorObject(message?: string, exception?: any): void;
  67596. /**
  67597. * Execute the current task
  67598. * @param scene defines the scene where you want your assets to be loaded
  67599. * @param onSuccess is a callback called when the task is successfully executed
  67600. * @param onError is a callback called if an error occurs
  67601. */
  67602. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67603. /**
  67604. * Execute the current task
  67605. * @param scene defines the scene where you want your assets to be loaded
  67606. * @param onSuccess is a callback called when the task is successfully executed
  67607. * @param onError is a callback called if an error occurs
  67608. */
  67609. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67610. /**
  67611. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  67612. * This can be used with failed tasks that have the reason for failure fixed.
  67613. */
  67614. reset(): void;
  67615. private onErrorCallback;
  67616. private onDoneCallback;
  67617. }
  67618. /**
  67619. * Define the interface used by progress events raised during assets loading
  67620. */
  67621. export interface IAssetsProgressEvent {
  67622. /**
  67623. * Defines the number of remaining tasks to process
  67624. */
  67625. remainingCount: number;
  67626. /**
  67627. * Defines the total number of tasks
  67628. */
  67629. totalCount: number;
  67630. /**
  67631. * Defines the task that was just processed
  67632. */
  67633. task: AbstractAssetTask;
  67634. }
  67635. /**
  67636. * Class used to share progress information about assets loading
  67637. */
  67638. export class AssetsProgressEvent implements IAssetsProgressEvent {
  67639. /**
  67640. * Defines the number of remaining tasks to process
  67641. */
  67642. remainingCount: number;
  67643. /**
  67644. * Defines the total number of tasks
  67645. */
  67646. totalCount: number;
  67647. /**
  67648. * Defines the task that was just processed
  67649. */
  67650. task: AbstractAssetTask;
  67651. /**
  67652. * Creates a AssetsProgressEvent
  67653. * @param remainingCount defines the number of remaining tasks to process
  67654. * @param totalCount defines the total number of tasks
  67655. * @param task defines the task that was just processed
  67656. */
  67657. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  67658. }
  67659. /**
  67660. * Define a task used by AssetsManager to load meshes
  67661. */
  67662. export class MeshAssetTask extends AbstractAssetTask {
  67663. /**
  67664. * Defines the name of the task
  67665. */
  67666. name: string;
  67667. /**
  67668. * Defines the list of mesh's names you want to load
  67669. */
  67670. meshesNames: any;
  67671. /**
  67672. * Defines the root url to use as a base to load your meshes and associated resources
  67673. */
  67674. rootUrl: string;
  67675. /**
  67676. * Defines the filename of the scene to load from
  67677. */
  67678. sceneFilename: string;
  67679. /**
  67680. * Gets the list of loaded meshes
  67681. */
  67682. loadedMeshes: Array<AbstractMesh>;
  67683. /**
  67684. * Gets the list of loaded particle systems
  67685. */
  67686. loadedParticleSystems: Array<IParticleSystem>;
  67687. /**
  67688. * Gets the list of loaded skeletons
  67689. */
  67690. loadedSkeletons: Array<Skeleton>;
  67691. /**
  67692. * Gets the list of loaded animation groups
  67693. */
  67694. loadedAnimationGroups: Array<AnimationGroup>;
  67695. /**
  67696. * Callback called when the task is successful
  67697. */
  67698. onSuccess: (task: MeshAssetTask) => void;
  67699. /**
  67700. * Callback called when the task is successful
  67701. */
  67702. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  67703. /**
  67704. * Creates a new MeshAssetTask
  67705. * @param name defines the name of the task
  67706. * @param meshesNames defines the list of mesh's names you want to load
  67707. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  67708. * @param sceneFilename defines the filename of the scene to load from
  67709. */
  67710. constructor(
  67711. /**
  67712. * Defines the name of the task
  67713. */
  67714. name: string,
  67715. /**
  67716. * Defines the list of mesh's names you want to load
  67717. */
  67718. meshesNames: any,
  67719. /**
  67720. * Defines the root url to use as a base to load your meshes and associated resources
  67721. */
  67722. rootUrl: string,
  67723. /**
  67724. * Defines the filename of the scene to load from
  67725. */
  67726. sceneFilename: string);
  67727. /**
  67728. * Execute the current task
  67729. * @param scene defines the scene where you want your assets to be loaded
  67730. * @param onSuccess is a callback called when the task is successfully executed
  67731. * @param onError is a callback called if an error occurs
  67732. */
  67733. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67734. }
  67735. /**
  67736. * Define a task used by AssetsManager to load text content
  67737. */
  67738. export class TextFileAssetTask extends AbstractAssetTask {
  67739. /**
  67740. * Defines the name of the task
  67741. */
  67742. name: string;
  67743. /**
  67744. * Defines the location of the file to load
  67745. */
  67746. url: string;
  67747. /**
  67748. * Gets the loaded text string
  67749. */
  67750. text: string;
  67751. /**
  67752. * Callback called when the task is successful
  67753. */
  67754. onSuccess: (task: TextFileAssetTask) => void;
  67755. /**
  67756. * Callback called when the task is successful
  67757. */
  67758. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  67759. /**
  67760. * Creates a new TextFileAssetTask object
  67761. * @param name defines the name of the task
  67762. * @param url defines the location of the file to load
  67763. */
  67764. constructor(
  67765. /**
  67766. * Defines the name of the task
  67767. */
  67768. name: string,
  67769. /**
  67770. * Defines the location of the file to load
  67771. */
  67772. url: string);
  67773. /**
  67774. * Execute the current task
  67775. * @param scene defines the scene where you want your assets to be loaded
  67776. * @param onSuccess is a callback called when the task is successfully executed
  67777. * @param onError is a callback called if an error occurs
  67778. */
  67779. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67780. }
  67781. /**
  67782. * Define a task used by AssetsManager to load binary data
  67783. */
  67784. export class BinaryFileAssetTask extends AbstractAssetTask {
  67785. /**
  67786. * Defines the name of the task
  67787. */
  67788. name: string;
  67789. /**
  67790. * Defines the location of the file to load
  67791. */
  67792. url: string;
  67793. /**
  67794. * Gets the lodaded data (as an array buffer)
  67795. */
  67796. data: ArrayBuffer;
  67797. /**
  67798. * Callback called when the task is successful
  67799. */
  67800. onSuccess: (task: BinaryFileAssetTask) => void;
  67801. /**
  67802. * Callback called when the task is successful
  67803. */
  67804. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  67805. /**
  67806. * Creates a new BinaryFileAssetTask object
  67807. * @param name defines the name of the new task
  67808. * @param url defines the location of the file to load
  67809. */
  67810. constructor(
  67811. /**
  67812. * Defines the name of the task
  67813. */
  67814. name: string,
  67815. /**
  67816. * Defines the location of the file to load
  67817. */
  67818. url: string);
  67819. /**
  67820. * Execute the current task
  67821. * @param scene defines the scene where you want your assets to be loaded
  67822. * @param onSuccess is a callback called when the task is successfully executed
  67823. * @param onError is a callback called if an error occurs
  67824. */
  67825. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67826. }
  67827. /**
  67828. * Define a task used by AssetsManager to load images
  67829. */
  67830. export class ImageAssetTask extends AbstractAssetTask {
  67831. /**
  67832. * Defines the name of the task
  67833. */
  67834. name: string;
  67835. /**
  67836. * Defines the location of the image to load
  67837. */
  67838. url: string;
  67839. /**
  67840. * Gets the loaded images
  67841. */
  67842. image: HTMLImageElement;
  67843. /**
  67844. * Callback called when the task is successful
  67845. */
  67846. onSuccess: (task: ImageAssetTask) => void;
  67847. /**
  67848. * Callback called when the task is successful
  67849. */
  67850. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  67851. /**
  67852. * Creates a new ImageAssetTask
  67853. * @param name defines the name of the task
  67854. * @param url defines the location of the image to load
  67855. */
  67856. constructor(
  67857. /**
  67858. * Defines the name of the task
  67859. */
  67860. name: string,
  67861. /**
  67862. * Defines the location of the image to load
  67863. */
  67864. url: string);
  67865. /**
  67866. * Execute the current task
  67867. * @param scene defines the scene where you want your assets to be loaded
  67868. * @param onSuccess is a callback called when the task is successfully executed
  67869. * @param onError is a callback called if an error occurs
  67870. */
  67871. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67872. }
  67873. /**
  67874. * Defines the interface used by texture loading tasks
  67875. */
  67876. export interface ITextureAssetTask<TEX extends BaseTexture> {
  67877. /**
  67878. * Gets the loaded texture
  67879. */
  67880. texture: TEX;
  67881. }
  67882. /**
  67883. * Define a task used by AssetsManager to load 2D textures
  67884. */
  67885. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  67886. /**
  67887. * Defines the name of the task
  67888. */
  67889. name: string;
  67890. /**
  67891. * Defines the location of the file to load
  67892. */
  67893. url: string;
  67894. /**
  67895. * Defines if mipmap should not be generated (default is false)
  67896. */
  67897. noMipmap?: boolean | undefined;
  67898. /**
  67899. * Defines if texture must be inverted on Y axis (default is false)
  67900. */
  67901. invertY?: boolean | undefined;
  67902. /**
  67903. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67904. */
  67905. samplingMode: number;
  67906. /**
  67907. * Gets the loaded texture
  67908. */
  67909. texture: Texture;
  67910. /**
  67911. * Callback called when the task is successful
  67912. */
  67913. onSuccess: (task: TextureAssetTask) => void;
  67914. /**
  67915. * Callback called when the task is successful
  67916. */
  67917. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  67918. /**
  67919. * Creates a new TextureAssetTask object
  67920. * @param name defines the name of the task
  67921. * @param url defines the location of the file to load
  67922. * @param noMipmap defines if mipmap should not be generated (default is false)
  67923. * @param invertY defines if texture must be inverted on Y axis (default is false)
  67924. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67925. */
  67926. constructor(
  67927. /**
  67928. * Defines the name of the task
  67929. */
  67930. name: string,
  67931. /**
  67932. * Defines the location of the file to load
  67933. */
  67934. url: string,
  67935. /**
  67936. * Defines if mipmap should not be generated (default is false)
  67937. */
  67938. noMipmap?: boolean | undefined,
  67939. /**
  67940. * Defines if texture must be inverted on Y axis (default is false)
  67941. */
  67942. invertY?: boolean | undefined,
  67943. /**
  67944. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67945. */
  67946. samplingMode?: number);
  67947. /**
  67948. * Execute the current task
  67949. * @param scene defines the scene where you want your assets to be loaded
  67950. * @param onSuccess is a callback called when the task is successfully executed
  67951. * @param onError is a callback called if an error occurs
  67952. */
  67953. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67954. }
  67955. /**
  67956. * Define a task used by AssetsManager to load cube textures
  67957. */
  67958. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  67959. /**
  67960. * Defines the name of the task
  67961. */
  67962. name: string;
  67963. /**
  67964. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67965. */
  67966. url: string;
  67967. /**
  67968. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67969. */
  67970. extensions?: string[] | undefined;
  67971. /**
  67972. * Defines if mipmaps should not be generated (default is false)
  67973. */
  67974. noMipmap?: boolean | undefined;
  67975. /**
  67976. * Defines the explicit list of files (undefined by default)
  67977. */
  67978. files?: string[] | undefined;
  67979. /**
  67980. * Gets the loaded texture
  67981. */
  67982. texture: CubeTexture;
  67983. /**
  67984. * Callback called when the task is successful
  67985. */
  67986. onSuccess: (task: CubeTextureAssetTask) => void;
  67987. /**
  67988. * Callback called when the task is successful
  67989. */
  67990. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  67991. /**
  67992. * Creates a new CubeTextureAssetTask
  67993. * @param name defines the name of the task
  67994. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67995. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67996. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67997. * @param files defines the explicit list of files (undefined by default)
  67998. */
  67999. constructor(
  68000. /**
  68001. * Defines the name of the task
  68002. */
  68003. name: string,
  68004. /**
  68005. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68006. */
  68007. url: string,
  68008. /**
  68009. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68010. */
  68011. extensions?: string[] | undefined,
  68012. /**
  68013. * Defines if mipmaps should not be generated (default is false)
  68014. */
  68015. noMipmap?: boolean | undefined,
  68016. /**
  68017. * Defines the explicit list of files (undefined by default)
  68018. */
  68019. files?: string[] | undefined);
  68020. /**
  68021. * Execute the current task
  68022. * @param scene defines the scene where you want your assets to be loaded
  68023. * @param onSuccess is a callback called when the task is successfully executed
  68024. * @param onError is a callback called if an error occurs
  68025. */
  68026. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68027. }
  68028. /**
  68029. * Define a task used by AssetsManager to load HDR cube textures
  68030. */
  68031. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  68032. /**
  68033. * Defines the name of the task
  68034. */
  68035. name: string;
  68036. /**
  68037. * Defines the location of the file to load
  68038. */
  68039. url: string;
  68040. /**
  68041. * Defines the desired size (the more it increases the longer the generation will be)
  68042. */
  68043. size: number;
  68044. /**
  68045. * Defines if mipmaps should not be generated (default is false)
  68046. */
  68047. noMipmap: boolean;
  68048. /**
  68049. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68050. */
  68051. generateHarmonics: boolean;
  68052. /**
  68053. * 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)
  68054. */
  68055. gammaSpace: boolean;
  68056. /**
  68057. * Internal Use Only
  68058. */
  68059. reserved: boolean;
  68060. /**
  68061. * Gets the loaded texture
  68062. */
  68063. texture: HDRCubeTexture;
  68064. /**
  68065. * Callback called when the task is successful
  68066. */
  68067. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  68068. /**
  68069. * Callback called when the task is successful
  68070. */
  68071. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  68072. /**
  68073. * Creates a new HDRCubeTextureAssetTask object
  68074. * @param name defines the name of the task
  68075. * @param url defines the location of the file to load
  68076. * @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.
  68077. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68078. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68079. * @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)
  68080. * @param reserved Internal use only
  68081. */
  68082. constructor(
  68083. /**
  68084. * Defines the name of the task
  68085. */
  68086. name: string,
  68087. /**
  68088. * Defines the location of the file to load
  68089. */
  68090. url: string,
  68091. /**
  68092. * Defines the desired size (the more it increases the longer the generation will be)
  68093. */
  68094. size: number,
  68095. /**
  68096. * Defines if mipmaps should not be generated (default is false)
  68097. */
  68098. noMipmap?: boolean,
  68099. /**
  68100. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68101. */
  68102. generateHarmonics?: boolean,
  68103. /**
  68104. * 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)
  68105. */
  68106. gammaSpace?: boolean,
  68107. /**
  68108. * Internal Use Only
  68109. */
  68110. reserved?: boolean);
  68111. /**
  68112. * Execute the current task
  68113. * @param scene defines the scene where you want your assets to be loaded
  68114. * @param onSuccess is a callback called when the task is successfully executed
  68115. * @param onError is a callback called if an error occurs
  68116. */
  68117. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68118. }
  68119. /**
  68120. * Define a task used by AssetsManager to load Equirectangular cube textures
  68121. */
  68122. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  68123. /**
  68124. * Defines the name of the task
  68125. */
  68126. name: string;
  68127. /**
  68128. * Defines the location of the file to load
  68129. */
  68130. url: string;
  68131. /**
  68132. * Defines the desired size (the more it increases the longer the generation will be)
  68133. */
  68134. size: number;
  68135. /**
  68136. * Defines if mipmaps should not be generated (default is false)
  68137. */
  68138. noMipmap: boolean;
  68139. /**
  68140. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68141. * but the standard material would require them in Gamma space) (default is true)
  68142. */
  68143. gammaSpace: boolean;
  68144. /**
  68145. * Gets the loaded texture
  68146. */
  68147. texture: EquiRectangularCubeTexture;
  68148. /**
  68149. * Callback called when the task is successful
  68150. */
  68151. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  68152. /**
  68153. * Callback called when the task is successful
  68154. */
  68155. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  68156. /**
  68157. * Creates a new EquiRectangularCubeTextureAssetTask object
  68158. * @param name defines the name of the task
  68159. * @param url defines the location of the file to load
  68160. * @param size defines the desired size (the more it increases the longer the generation will be)
  68161. * If the size is omitted this implies you are using a preprocessed cubemap.
  68162. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68163. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  68164. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  68165. * (default is true)
  68166. */
  68167. constructor(
  68168. /**
  68169. * Defines the name of the task
  68170. */
  68171. name: string,
  68172. /**
  68173. * Defines the location of the file to load
  68174. */
  68175. url: string,
  68176. /**
  68177. * Defines the desired size (the more it increases the longer the generation will be)
  68178. */
  68179. size: number,
  68180. /**
  68181. * Defines if mipmaps should not be generated (default is false)
  68182. */
  68183. noMipmap?: boolean,
  68184. /**
  68185. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68186. * but the standard material would require them in Gamma space) (default is true)
  68187. */
  68188. gammaSpace?: boolean);
  68189. /**
  68190. * Execute the current task
  68191. * @param scene defines the scene where you want your assets to be loaded
  68192. * @param onSuccess is a callback called when the task is successfully executed
  68193. * @param onError is a callback called if an error occurs
  68194. */
  68195. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68196. }
  68197. /**
  68198. * This class can be used to easily import assets into a scene
  68199. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  68200. */
  68201. export class AssetsManager {
  68202. private _scene;
  68203. private _isLoading;
  68204. protected _tasks: AbstractAssetTask[];
  68205. protected _waitingTasksCount: number;
  68206. protected _totalTasksCount: number;
  68207. /**
  68208. * Callback called when all tasks are processed
  68209. */
  68210. onFinish: (tasks: AbstractAssetTask[]) => void;
  68211. /**
  68212. * Callback called when a task is successful
  68213. */
  68214. onTaskSuccess: (task: AbstractAssetTask) => void;
  68215. /**
  68216. * Callback called when a task had an error
  68217. */
  68218. onTaskError: (task: AbstractAssetTask) => void;
  68219. /**
  68220. * Callback called when a task is done (whatever the result is)
  68221. */
  68222. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  68223. /**
  68224. * Observable called when all tasks are processed
  68225. */
  68226. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  68227. /**
  68228. * Observable called when a task had an error
  68229. */
  68230. onTaskErrorObservable: Observable<AbstractAssetTask>;
  68231. /**
  68232. * Observable called when all tasks were executed
  68233. */
  68234. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  68235. /**
  68236. * Observable called when a task is done (whatever the result is)
  68237. */
  68238. onProgressObservable: Observable<IAssetsProgressEvent>;
  68239. /**
  68240. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  68241. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  68242. */
  68243. useDefaultLoadingScreen: boolean;
  68244. /**
  68245. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  68246. * when all assets have been downloaded.
  68247. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  68248. */
  68249. autoHideLoadingUI: boolean;
  68250. /**
  68251. * Creates a new AssetsManager
  68252. * @param scene defines the scene to work on
  68253. */
  68254. constructor(scene: Scene);
  68255. /**
  68256. * Add a MeshAssetTask to the list of active tasks
  68257. * @param taskName defines the name of the new task
  68258. * @param meshesNames defines the name of meshes to load
  68259. * @param rootUrl defines the root url to use to locate files
  68260. * @param sceneFilename defines the filename of the scene file
  68261. * @returns a new MeshAssetTask object
  68262. */
  68263. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  68264. /**
  68265. * Add a TextFileAssetTask to the list of active tasks
  68266. * @param taskName defines the name of the new task
  68267. * @param url defines the url of the file to load
  68268. * @returns a new TextFileAssetTask object
  68269. */
  68270. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  68271. /**
  68272. * Add a BinaryFileAssetTask to the list of active tasks
  68273. * @param taskName defines the name of the new task
  68274. * @param url defines the url of the file to load
  68275. * @returns a new BinaryFileAssetTask object
  68276. */
  68277. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  68278. /**
  68279. * Add a ImageAssetTask to the list of active tasks
  68280. * @param taskName defines the name of the new task
  68281. * @param url defines the url of the file to load
  68282. * @returns a new ImageAssetTask object
  68283. */
  68284. addImageTask(taskName: string, url: string): ImageAssetTask;
  68285. /**
  68286. * Add a TextureAssetTask to the list of active tasks
  68287. * @param taskName defines the name of the new task
  68288. * @param url defines the url of the file to load
  68289. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68290. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  68291. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  68292. * @returns a new TextureAssetTask object
  68293. */
  68294. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  68295. /**
  68296. * Add a CubeTextureAssetTask to the list of active tasks
  68297. * @param taskName defines the name of the new task
  68298. * @param url defines the url of the file to load
  68299. * @param extensions defines the extension to use to load the cube map (can be null)
  68300. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68301. * @param files defines the list of files to load (can be null)
  68302. * @returns a new CubeTextureAssetTask object
  68303. */
  68304. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  68305. /**
  68306. *
  68307. * Add a HDRCubeTextureAssetTask to the list of active tasks
  68308. * @param taskName defines the name of the new task
  68309. * @param url defines the url of the file to load
  68310. * @param size defines the size you want for the cubemap (can be null)
  68311. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68312. * @param generateHarmonics defines if you want to automatically generate (true by default)
  68313. * @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)
  68314. * @param reserved Internal use only
  68315. * @returns a new HDRCubeTextureAssetTask object
  68316. */
  68317. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  68318. /**
  68319. *
  68320. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  68321. * @param taskName defines the name of the new task
  68322. * @param url defines the url of the file to load
  68323. * @param size defines the size you want for the cubemap (can be null)
  68324. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68325. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  68326. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  68327. * @returns a new EquiRectangularCubeTextureAssetTask object
  68328. */
  68329. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  68330. /**
  68331. * Remove a task from the assets manager.
  68332. * @param task the task to remove
  68333. */
  68334. removeTask(task: AbstractAssetTask): void;
  68335. private _decreaseWaitingTasksCount;
  68336. private _runTask;
  68337. /**
  68338. * Reset the AssetsManager and remove all tasks
  68339. * @return the current instance of the AssetsManager
  68340. */
  68341. reset(): AssetsManager;
  68342. /**
  68343. * Start the loading process
  68344. * @return the current instance of the AssetsManager
  68345. */
  68346. load(): AssetsManager;
  68347. /**
  68348. * Start the loading process as an async operation
  68349. * @return a promise returning the list of failed tasks
  68350. */
  68351. loadAsync(): Promise<void>;
  68352. }
  68353. }
  68354. declare module BABYLON {
  68355. /**
  68356. * Wrapper class for promise with external resolve and reject.
  68357. */
  68358. export class Deferred<T> {
  68359. /**
  68360. * The promise associated with this deferred object.
  68361. */
  68362. readonly promise: Promise<T>;
  68363. private _resolve;
  68364. private _reject;
  68365. /**
  68366. * The resolve method of the promise associated with this deferred object.
  68367. */
  68368. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  68369. /**
  68370. * The reject method of the promise associated with this deferred object.
  68371. */
  68372. get reject(): (reason?: any) => void;
  68373. /**
  68374. * Constructor for this deferred object.
  68375. */
  68376. constructor();
  68377. }
  68378. }
  68379. declare module BABYLON {
  68380. /**
  68381. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  68382. */
  68383. export class MeshExploder {
  68384. private _centerMesh;
  68385. private _meshes;
  68386. private _meshesOrigins;
  68387. private _toCenterVectors;
  68388. private _scaledDirection;
  68389. private _newPosition;
  68390. private _centerPosition;
  68391. /**
  68392. * Explodes meshes from a center mesh.
  68393. * @param meshes The meshes to explode.
  68394. * @param centerMesh The mesh to be center of explosion.
  68395. */
  68396. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  68397. private _setCenterMesh;
  68398. /**
  68399. * Get class name
  68400. * @returns "MeshExploder"
  68401. */
  68402. getClassName(): string;
  68403. /**
  68404. * "Exploded meshes"
  68405. * @returns Array of meshes with the centerMesh at index 0.
  68406. */
  68407. getMeshes(): Array<Mesh>;
  68408. /**
  68409. * Explodes meshes giving a specific direction
  68410. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  68411. */
  68412. explode(direction?: number): void;
  68413. }
  68414. }
  68415. declare module BABYLON {
  68416. /**
  68417. * Class used to help managing file picking and drag'n'drop
  68418. */
  68419. export class FilesInput {
  68420. /**
  68421. * List of files ready to be loaded
  68422. */
  68423. static get FilesToLoad(): {
  68424. [key: string]: File;
  68425. };
  68426. /**
  68427. * Callback called when a file is processed
  68428. */
  68429. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  68430. private _engine;
  68431. private _currentScene;
  68432. private _sceneLoadedCallback;
  68433. private _progressCallback;
  68434. private _additionalRenderLoopLogicCallback;
  68435. private _textureLoadingCallback;
  68436. private _startingProcessingFilesCallback;
  68437. private _onReloadCallback;
  68438. private _errorCallback;
  68439. private _elementToMonitor;
  68440. private _sceneFileToLoad;
  68441. private _filesToLoad;
  68442. /**
  68443. * Creates a new FilesInput
  68444. * @param engine defines the rendering engine
  68445. * @param scene defines the hosting scene
  68446. * @param sceneLoadedCallback callback called when scene is loaded
  68447. * @param progressCallback callback called to track progress
  68448. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  68449. * @param textureLoadingCallback callback called when a texture is loading
  68450. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  68451. * @param onReloadCallback callback called when a reload is requested
  68452. * @param errorCallback callback call if an error occurs
  68453. */
  68454. 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);
  68455. private _dragEnterHandler;
  68456. private _dragOverHandler;
  68457. private _dropHandler;
  68458. /**
  68459. * Calls this function to listen to drag'n'drop events on a specific DOM element
  68460. * @param elementToMonitor defines the DOM element to track
  68461. */
  68462. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  68463. /**
  68464. * Release all associated resources
  68465. */
  68466. dispose(): void;
  68467. private renderFunction;
  68468. private drag;
  68469. private drop;
  68470. private _traverseFolder;
  68471. private _processFiles;
  68472. /**
  68473. * Load files from a drop event
  68474. * @param event defines the drop event to use as source
  68475. */
  68476. loadFiles(event: any): void;
  68477. private _processReload;
  68478. /**
  68479. * Reload the current scene from the loaded files
  68480. */
  68481. reload(): void;
  68482. }
  68483. }
  68484. declare module BABYLON {
  68485. /**
  68486. * Defines the root class used to create scene optimization to use with SceneOptimizer
  68487. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68488. */
  68489. export class SceneOptimization {
  68490. /**
  68491. * Defines the priority of this optimization (0 by default which means first in the list)
  68492. */
  68493. priority: number;
  68494. /**
  68495. * Gets a string describing the action executed by the current optimization
  68496. * @returns description string
  68497. */
  68498. getDescription(): string;
  68499. /**
  68500. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68501. * @param scene defines the current scene where to apply this optimization
  68502. * @param optimizer defines the current optimizer
  68503. * @returns true if everything that can be done was applied
  68504. */
  68505. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68506. /**
  68507. * Creates the SceneOptimization object
  68508. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68509. * @param desc defines the description associated with the optimization
  68510. */
  68511. constructor(
  68512. /**
  68513. * Defines the priority of this optimization (0 by default which means first in the list)
  68514. */
  68515. priority?: number);
  68516. }
  68517. /**
  68518. * Defines an optimization used to reduce the size of render target textures
  68519. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68520. */
  68521. export class TextureOptimization extends SceneOptimization {
  68522. /**
  68523. * Defines the priority of this optimization (0 by default which means first in the list)
  68524. */
  68525. priority: number;
  68526. /**
  68527. * 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
  68528. */
  68529. maximumSize: number;
  68530. /**
  68531. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68532. */
  68533. step: number;
  68534. /**
  68535. * Gets a string describing the action executed by the current optimization
  68536. * @returns description string
  68537. */
  68538. getDescription(): string;
  68539. /**
  68540. * Creates the TextureOptimization object
  68541. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68542. * @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
  68543. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68544. */
  68545. constructor(
  68546. /**
  68547. * Defines the priority of this optimization (0 by default which means first in the list)
  68548. */
  68549. priority?: number,
  68550. /**
  68551. * 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
  68552. */
  68553. maximumSize?: number,
  68554. /**
  68555. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68556. */
  68557. step?: number);
  68558. /**
  68559. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68560. * @param scene defines the current scene where to apply this optimization
  68561. * @param optimizer defines the current optimizer
  68562. * @returns true if everything that can be done was applied
  68563. */
  68564. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68565. }
  68566. /**
  68567. * Defines an optimization used to increase or decrease the rendering resolution
  68568. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68569. */
  68570. export class HardwareScalingOptimization extends SceneOptimization {
  68571. /**
  68572. * Defines the priority of this optimization (0 by default which means first in the list)
  68573. */
  68574. priority: number;
  68575. /**
  68576. * Defines the maximum scale to use (2 by default)
  68577. */
  68578. maximumScale: number;
  68579. /**
  68580. * Defines the step to use between two passes (0.5 by default)
  68581. */
  68582. step: number;
  68583. private _currentScale;
  68584. private _directionOffset;
  68585. /**
  68586. * Gets a string describing the action executed by the current optimization
  68587. * @return description string
  68588. */
  68589. getDescription(): string;
  68590. /**
  68591. * Creates the HardwareScalingOptimization object
  68592. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68593. * @param maximumScale defines the maximum scale to use (2 by default)
  68594. * @param step defines the step to use between two passes (0.5 by default)
  68595. */
  68596. constructor(
  68597. /**
  68598. * Defines the priority of this optimization (0 by default which means first in the list)
  68599. */
  68600. priority?: number,
  68601. /**
  68602. * Defines the maximum scale to use (2 by default)
  68603. */
  68604. maximumScale?: number,
  68605. /**
  68606. * Defines the step to use between two passes (0.5 by default)
  68607. */
  68608. step?: number);
  68609. /**
  68610. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68611. * @param scene defines the current scene where to apply this optimization
  68612. * @param optimizer defines the current optimizer
  68613. * @returns true if everything that can be done was applied
  68614. */
  68615. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68616. }
  68617. /**
  68618. * Defines an optimization used to remove shadows
  68619. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68620. */
  68621. export class ShadowsOptimization extends SceneOptimization {
  68622. /**
  68623. * Gets a string describing the action executed by the current optimization
  68624. * @return description string
  68625. */
  68626. getDescription(): string;
  68627. /**
  68628. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68629. * @param scene defines the current scene where to apply this optimization
  68630. * @param optimizer defines the current optimizer
  68631. * @returns true if everything that can be done was applied
  68632. */
  68633. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68634. }
  68635. /**
  68636. * Defines an optimization used to turn post-processes off
  68637. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68638. */
  68639. export class PostProcessesOptimization extends SceneOptimization {
  68640. /**
  68641. * Gets a string describing the action executed by the current optimization
  68642. * @return description string
  68643. */
  68644. getDescription(): string;
  68645. /**
  68646. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68647. * @param scene defines the current scene where to apply this optimization
  68648. * @param optimizer defines the current optimizer
  68649. * @returns true if everything that can be done was applied
  68650. */
  68651. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68652. }
  68653. /**
  68654. * Defines an optimization used to turn lens flares off
  68655. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68656. */
  68657. export class LensFlaresOptimization extends SceneOptimization {
  68658. /**
  68659. * Gets a string describing the action executed by the current optimization
  68660. * @return description string
  68661. */
  68662. getDescription(): string;
  68663. /**
  68664. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68665. * @param scene defines the current scene where to apply this optimization
  68666. * @param optimizer defines the current optimizer
  68667. * @returns true if everything that can be done was applied
  68668. */
  68669. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68670. }
  68671. /**
  68672. * Defines an optimization based on user defined callback.
  68673. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68674. */
  68675. export class CustomOptimization extends SceneOptimization {
  68676. /**
  68677. * Callback called to apply the custom optimization.
  68678. */
  68679. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  68680. /**
  68681. * Callback called to get custom description
  68682. */
  68683. onGetDescription: () => string;
  68684. /**
  68685. * Gets a string describing the action executed by the current optimization
  68686. * @returns description string
  68687. */
  68688. getDescription(): string;
  68689. /**
  68690. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68691. * @param scene defines the current scene where to apply this optimization
  68692. * @param optimizer defines the current optimizer
  68693. * @returns true if everything that can be done was applied
  68694. */
  68695. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68696. }
  68697. /**
  68698. * Defines an optimization used to turn particles off
  68699. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68700. */
  68701. export class ParticlesOptimization extends SceneOptimization {
  68702. /**
  68703. * Gets a string describing the action executed by the current optimization
  68704. * @return description string
  68705. */
  68706. getDescription(): string;
  68707. /**
  68708. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68709. * @param scene defines the current scene where to apply this optimization
  68710. * @param optimizer defines the current optimizer
  68711. * @returns true if everything that can be done was applied
  68712. */
  68713. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68714. }
  68715. /**
  68716. * Defines an optimization used to turn render targets off
  68717. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68718. */
  68719. export class RenderTargetsOptimization extends SceneOptimization {
  68720. /**
  68721. * Gets a string describing the action executed by the current optimization
  68722. * @return description string
  68723. */
  68724. getDescription(): string;
  68725. /**
  68726. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68727. * @param scene defines the current scene where to apply this optimization
  68728. * @param optimizer defines the current optimizer
  68729. * @returns true if everything that can be done was applied
  68730. */
  68731. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68732. }
  68733. /**
  68734. * Defines an optimization used to merge meshes with compatible materials
  68735. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68736. */
  68737. export class MergeMeshesOptimization extends SceneOptimization {
  68738. private static _UpdateSelectionTree;
  68739. /**
  68740. * Gets or sets a boolean which defines if optimization octree has to be updated
  68741. */
  68742. static get UpdateSelectionTree(): boolean;
  68743. /**
  68744. * Gets or sets a boolean which defines if optimization octree has to be updated
  68745. */
  68746. static set UpdateSelectionTree(value: boolean);
  68747. /**
  68748. * Gets a string describing the action executed by the current optimization
  68749. * @return description string
  68750. */
  68751. getDescription(): string;
  68752. private _canBeMerged;
  68753. /**
  68754. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68755. * @param scene defines the current scene where to apply this optimization
  68756. * @param optimizer defines the current optimizer
  68757. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  68758. * @returns true if everything that can be done was applied
  68759. */
  68760. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  68761. }
  68762. /**
  68763. * Defines a list of options used by SceneOptimizer
  68764. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68765. */
  68766. export class SceneOptimizerOptions {
  68767. /**
  68768. * Defines the target frame rate to reach (60 by default)
  68769. */
  68770. targetFrameRate: number;
  68771. /**
  68772. * Defines the interval between two checkes (2000ms by default)
  68773. */
  68774. trackerDuration: number;
  68775. /**
  68776. * Gets the list of optimizations to apply
  68777. */
  68778. optimizations: SceneOptimization[];
  68779. /**
  68780. * Creates a new list of options used by SceneOptimizer
  68781. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  68782. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  68783. */
  68784. constructor(
  68785. /**
  68786. * Defines the target frame rate to reach (60 by default)
  68787. */
  68788. targetFrameRate?: number,
  68789. /**
  68790. * Defines the interval between two checkes (2000ms by default)
  68791. */
  68792. trackerDuration?: number);
  68793. /**
  68794. * Add a new optimization
  68795. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  68796. * @returns the current SceneOptimizerOptions
  68797. */
  68798. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  68799. /**
  68800. * Add a new custom optimization
  68801. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  68802. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  68803. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68804. * @returns the current SceneOptimizerOptions
  68805. */
  68806. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  68807. /**
  68808. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  68809. * @param targetFrameRate defines the target frame rate (60 by default)
  68810. * @returns a SceneOptimizerOptions object
  68811. */
  68812. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68813. /**
  68814. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  68815. * @param targetFrameRate defines the target frame rate (60 by default)
  68816. * @returns a SceneOptimizerOptions object
  68817. */
  68818. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68819. /**
  68820. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  68821. * @param targetFrameRate defines the target frame rate (60 by default)
  68822. * @returns a SceneOptimizerOptions object
  68823. */
  68824. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68825. }
  68826. /**
  68827. * Class used to run optimizations in order to reach a target frame rate
  68828. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68829. */
  68830. export class SceneOptimizer implements IDisposable {
  68831. private _isRunning;
  68832. private _options;
  68833. private _scene;
  68834. private _currentPriorityLevel;
  68835. private _targetFrameRate;
  68836. private _trackerDuration;
  68837. private _currentFrameRate;
  68838. private _sceneDisposeObserver;
  68839. private _improvementMode;
  68840. /**
  68841. * Defines an observable called when the optimizer reaches the target frame rate
  68842. */
  68843. onSuccessObservable: Observable<SceneOptimizer>;
  68844. /**
  68845. * Defines an observable called when the optimizer enables an optimization
  68846. */
  68847. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  68848. /**
  68849. * Defines an observable called when the optimizer is not able to reach the target frame rate
  68850. */
  68851. onFailureObservable: Observable<SceneOptimizer>;
  68852. /**
  68853. * Gets a boolean indicating if the optimizer is in improvement mode
  68854. */
  68855. get isInImprovementMode(): boolean;
  68856. /**
  68857. * Gets the current priority level (0 at start)
  68858. */
  68859. get currentPriorityLevel(): number;
  68860. /**
  68861. * Gets the current frame rate checked by the SceneOptimizer
  68862. */
  68863. get currentFrameRate(): number;
  68864. /**
  68865. * Gets or sets the current target frame rate (60 by default)
  68866. */
  68867. get targetFrameRate(): number;
  68868. /**
  68869. * Gets or sets the current target frame rate (60 by default)
  68870. */
  68871. set targetFrameRate(value: number);
  68872. /**
  68873. * Gets or sets the current interval between two checks (every 2000ms by default)
  68874. */
  68875. get trackerDuration(): number;
  68876. /**
  68877. * Gets or sets the current interval between two checks (every 2000ms by default)
  68878. */
  68879. set trackerDuration(value: number);
  68880. /**
  68881. * Gets the list of active optimizations
  68882. */
  68883. get optimizations(): SceneOptimization[];
  68884. /**
  68885. * Creates a new SceneOptimizer
  68886. * @param scene defines the scene to work on
  68887. * @param options defines the options to use with the SceneOptimizer
  68888. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  68889. * @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)
  68890. */
  68891. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  68892. /**
  68893. * Stops the current optimizer
  68894. */
  68895. stop(): void;
  68896. /**
  68897. * Reset the optimizer to initial step (current priority level = 0)
  68898. */
  68899. reset(): void;
  68900. /**
  68901. * Start the optimizer. By default it will try to reach a specific framerate
  68902. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  68903. */
  68904. start(): void;
  68905. private _checkCurrentState;
  68906. /**
  68907. * Release all resources
  68908. */
  68909. dispose(): void;
  68910. /**
  68911. * Helper function to create a SceneOptimizer with one single line of code
  68912. * @param scene defines the scene to work on
  68913. * @param options defines the options to use with the SceneOptimizer
  68914. * @param onSuccess defines a callback to call on success
  68915. * @param onFailure defines a callback to call on failure
  68916. * @returns the new SceneOptimizer object
  68917. */
  68918. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  68919. }
  68920. }
  68921. declare module BABYLON {
  68922. /**
  68923. * Class used to serialize a scene into a string
  68924. */
  68925. export class SceneSerializer {
  68926. /**
  68927. * Clear cache used by a previous serialization
  68928. */
  68929. static ClearCache(): void;
  68930. /**
  68931. * Serialize a scene into a JSON compatible object
  68932. * @param scene defines the scene to serialize
  68933. * @returns a JSON compatible object
  68934. */
  68935. static Serialize(scene: Scene): any;
  68936. /**
  68937. * Serialize a mesh into a JSON compatible object
  68938. * @param toSerialize defines the mesh to serialize
  68939. * @param withParents defines if parents must be serialized as well
  68940. * @param withChildren defines if children must be serialized as well
  68941. * @returns a JSON compatible object
  68942. */
  68943. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  68944. }
  68945. }
  68946. declare module BABYLON {
  68947. /**
  68948. * Class used to host texture specific utilities
  68949. */
  68950. export class TextureTools {
  68951. /**
  68952. * Uses the GPU to create a copy texture rescaled at a given size
  68953. * @param texture Texture to copy from
  68954. * @param width defines the desired width
  68955. * @param height defines the desired height
  68956. * @param useBilinearMode defines if bilinear mode has to be used
  68957. * @return the generated texture
  68958. */
  68959. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  68960. }
  68961. }
  68962. declare module BABYLON {
  68963. /**
  68964. * This represents the different options available for the video capture.
  68965. */
  68966. export interface VideoRecorderOptions {
  68967. /** Defines the mime type of the video. */
  68968. mimeType: string;
  68969. /** Defines the FPS the video should be recorded at. */
  68970. fps: number;
  68971. /** Defines the chunk size for the recording data. */
  68972. recordChunckSize: number;
  68973. /** The audio tracks to attach to the recording. */
  68974. audioTracks?: MediaStreamTrack[];
  68975. }
  68976. /**
  68977. * This can help with recording videos from BabylonJS.
  68978. * This is based on the available WebRTC functionalities of the browser.
  68979. *
  68980. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  68981. */
  68982. export class VideoRecorder {
  68983. private static readonly _defaultOptions;
  68984. /**
  68985. * Returns whether or not the VideoRecorder is available in your browser.
  68986. * @param engine Defines the Babylon Engine.
  68987. * @returns true if supported otherwise false.
  68988. */
  68989. static IsSupported(engine: Engine): boolean;
  68990. private readonly _options;
  68991. private _canvas;
  68992. private _mediaRecorder;
  68993. private _recordedChunks;
  68994. private _fileName;
  68995. private _resolve;
  68996. private _reject;
  68997. /**
  68998. * True when a recording is already in progress.
  68999. */
  69000. get isRecording(): boolean;
  69001. /**
  69002. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  69003. * @param engine Defines the BabylonJS Engine you wish to record.
  69004. * @param options Defines options that can be used to customize the capture.
  69005. */
  69006. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  69007. /**
  69008. * Stops the current recording before the default capture timeout passed in the startRecording function.
  69009. */
  69010. stopRecording(): void;
  69011. /**
  69012. * Starts recording the canvas for a max duration specified in parameters.
  69013. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  69014. * If null no automatic download will start and you can rely on the promise to get the data back.
  69015. * @param maxDuration Defines the maximum recording time in seconds.
  69016. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  69017. * @return A promise callback at the end of the recording with the video data in Blob.
  69018. */
  69019. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  69020. /**
  69021. * Releases internal resources used during the recording.
  69022. */
  69023. dispose(): void;
  69024. private _handleDataAvailable;
  69025. private _handleError;
  69026. private _handleStop;
  69027. }
  69028. }
  69029. declare module BABYLON {
  69030. /**
  69031. * Class containing a set of static utilities functions for screenshots
  69032. */
  69033. export class ScreenshotTools {
  69034. /**
  69035. * Captures a screenshot of the current rendering
  69036. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69037. * @param engine defines the rendering engine
  69038. * @param camera defines the source camera
  69039. * @param size This parameter can be set to a single number or to an object with the
  69040. * following (optional) properties: precision, width, height. If a single number is passed,
  69041. * it will be used for both width and height. If an object is passed, the screenshot size
  69042. * will be derived from the parameters. The precision property is a multiplier allowing
  69043. * rendering at a higher or lower resolution
  69044. * @param successCallback defines the callback receives a single parameter which contains the
  69045. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69046. * src parameter of an <img> to display it
  69047. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69048. * Check your browser for supported MIME types
  69049. */
  69050. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  69051. /**
  69052. * Captures a screenshot of the current rendering
  69053. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69054. * @param engine defines the rendering engine
  69055. * @param camera defines the source camera
  69056. * @param size This parameter can be set to a single number or to an object with the
  69057. * following (optional) properties: precision, width, height. If a single number is passed,
  69058. * it will be used for both width and height. If an object is passed, the screenshot size
  69059. * will be derived from the parameters. The precision property is a multiplier allowing
  69060. * rendering at a higher or lower resolution
  69061. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69062. * Check your browser for supported MIME types
  69063. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69064. * to the src parameter of an <img> to display it
  69065. */
  69066. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  69067. /**
  69068. * Generates an image screenshot from the specified camera.
  69069. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69070. * @param engine The engine to use for rendering
  69071. * @param camera The camera to use for rendering
  69072. * @param size This parameter can be set to a single number or to an object with the
  69073. * following (optional) properties: precision, width, height. If a single number is passed,
  69074. * it will be used for both width and height. If an object is passed, the screenshot size
  69075. * will be derived from the parameters. The precision property is a multiplier allowing
  69076. * rendering at a higher or lower resolution
  69077. * @param successCallback The callback receives a single parameter which contains the
  69078. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69079. * src parameter of an <img> to display it
  69080. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69081. * Check your browser for supported MIME types
  69082. * @param samples Texture samples (default: 1)
  69083. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69084. * @param fileName A name for for the downloaded file.
  69085. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  69086. */
  69087. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  69088. /**
  69089. * Generates an image screenshot from the specified camera.
  69090. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69091. * @param engine The engine to use for rendering
  69092. * @param camera The camera to use for rendering
  69093. * @param size This parameter can be set to a single number or to an object with the
  69094. * following (optional) properties: precision, width, height. If a single number is passed,
  69095. * it will be used for both width and height. If an object is passed, the screenshot size
  69096. * will be derived from the parameters. The precision property is a multiplier allowing
  69097. * rendering at a higher or lower resolution
  69098. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69099. * Check your browser for supported MIME types
  69100. * @param samples Texture samples (default: 1)
  69101. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69102. * @param fileName A name for for the downloaded file.
  69103. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  69104. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69105. * to the src parameter of an <img> to display it
  69106. */
  69107. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  69108. /**
  69109. * Gets height and width for screenshot size
  69110. * @private
  69111. */
  69112. private static _getScreenshotSize;
  69113. }
  69114. }
  69115. declare module BABYLON {
  69116. /**
  69117. * Interface for a data buffer
  69118. */
  69119. export interface IDataBuffer {
  69120. /**
  69121. * Reads bytes from the data buffer.
  69122. * @param byteOffset The byte offset to read
  69123. * @param byteLength The byte length to read
  69124. * @returns A promise that resolves when the bytes are read
  69125. */
  69126. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  69127. /**
  69128. * The byte length of the buffer.
  69129. */
  69130. readonly byteLength: number;
  69131. }
  69132. /**
  69133. * Utility class for reading from a data buffer
  69134. */
  69135. export class DataReader {
  69136. /**
  69137. * The data buffer associated with this data reader.
  69138. */
  69139. readonly buffer: IDataBuffer;
  69140. /**
  69141. * The current byte offset from the beginning of the data buffer.
  69142. */
  69143. byteOffset: number;
  69144. private _dataView;
  69145. private _dataByteOffset;
  69146. /**
  69147. * Constructor
  69148. * @param buffer The buffer to read
  69149. */
  69150. constructor(buffer: IDataBuffer);
  69151. /**
  69152. * Loads the given byte length.
  69153. * @param byteLength The byte length to load
  69154. * @returns A promise that resolves when the load is complete
  69155. */
  69156. loadAsync(byteLength: number): Promise<void>;
  69157. /**
  69158. * Read a unsigned 32-bit integer from the currently loaded data range.
  69159. * @returns The 32-bit integer read
  69160. */
  69161. readUint32(): number;
  69162. /**
  69163. * Read a byte array from the currently loaded data range.
  69164. * @param byteLength The byte length to read
  69165. * @returns The byte array read
  69166. */
  69167. readUint8Array(byteLength: number): Uint8Array;
  69168. /**
  69169. * Read a string from the currently loaded data range.
  69170. * @param byteLength The byte length to read
  69171. * @returns The string read
  69172. */
  69173. readString(byteLength: number): string;
  69174. /**
  69175. * Skips the given byte length the currently loaded data range.
  69176. * @param byteLength The byte length to skip
  69177. */
  69178. skipBytes(byteLength: number): void;
  69179. }
  69180. }
  69181. declare module BABYLON {
  69182. /**
  69183. * Class for storing data to local storage if available or in-memory storage otherwise
  69184. */
  69185. export class DataStorage {
  69186. private static _Storage;
  69187. private static _GetStorage;
  69188. /**
  69189. * Reads a string from the data storage
  69190. * @param key The key to read
  69191. * @param defaultValue The value if the key doesn't exist
  69192. * @returns The string value
  69193. */
  69194. static ReadString(key: string, defaultValue: string): string;
  69195. /**
  69196. * Writes a string to the data storage
  69197. * @param key The key to write
  69198. * @param value The value to write
  69199. */
  69200. static WriteString(key: string, value: string): void;
  69201. /**
  69202. * Reads a boolean from the data storage
  69203. * @param key The key to read
  69204. * @param defaultValue The value if the key doesn't exist
  69205. * @returns The boolean value
  69206. */
  69207. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  69208. /**
  69209. * Writes a boolean to the data storage
  69210. * @param key The key to write
  69211. * @param value The value to write
  69212. */
  69213. static WriteBoolean(key: string, value: boolean): void;
  69214. /**
  69215. * Reads a number from the data storage
  69216. * @param key The key to read
  69217. * @param defaultValue The value if the key doesn't exist
  69218. * @returns The number value
  69219. */
  69220. static ReadNumber(key: string, defaultValue: number): number;
  69221. /**
  69222. * Writes a number to the data storage
  69223. * @param key The key to write
  69224. * @param value The value to write
  69225. */
  69226. static WriteNumber(key: string, value: number): void;
  69227. }
  69228. }
  69229. declare module BABYLON {
  69230. /**
  69231. * Options used for hit testing
  69232. */
  69233. export interface IWebXRLegacyHitTestOptions {
  69234. /**
  69235. * Only test when user interacted with the scene. Default - hit test every frame
  69236. */
  69237. testOnPointerDownOnly?: boolean;
  69238. /**
  69239. * The node to use to transform the local results to world coordinates
  69240. */
  69241. worldParentNode?: TransformNode;
  69242. }
  69243. /**
  69244. * Interface defining the babylon result of raycasting/hit-test
  69245. */
  69246. export interface IWebXRLegacyHitResult {
  69247. /**
  69248. * Transformation matrix that can be applied to a node that will put it in the hit point location
  69249. */
  69250. transformationMatrix: Matrix;
  69251. /**
  69252. * The native hit test result
  69253. */
  69254. xrHitResult: XRHitResult | XRHitTestResult;
  69255. }
  69256. /**
  69257. * The currently-working hit-test module.
  69258. * Hit test (or Ray-casting) is used to interact with the real world.
  69259. * For further information read here - https://github.com/immersive-web/hit-test
  69260. */
  69261. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  69262. /**
  69263. * options to use when constructing this feature
  69264. */
  69265. readonly options: IWebXRLegacyHitTestOptions;
  69266. private _direction;
  69267. private _mat;
  69268. private _onSelectEnabled;
  69269. private _origin;
  69270. /**
  69271. * The module's name
  69272. */
  69273. static readonly Name: string;
  69274. /**
  69275. * The (Babylon) version of this module.
  69276. * This is an integer representing the implementation version.
  69277. * This number does not correspond to the WebXR specs version
  69278. */
  69279. static readonly Version: number;
  69280. /**
  69281. * Populated with the last native XR Hit Results
  69282. */
  69283. lastNativeXRHitResults: XRHitResult[];
  69284. /**
  69285. * Triggered when new babylon (transformed) hit test results are available
  69286. */
  69287. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  69288. /**
  69289. * Creates a new instance of the (legacy version) hit test feature
  69290. * @param _xrSessionManager an instance of WebXRSessionManager
  69291. * @param options options to use when constructing this feature
  69292. */
  69293. constructor(_xrSessionManager: WebXRSessionManager,
  69294. /**
  69295. * options to use when constructing this feature
  69296. */
  69297. options?: IWebXRLegacyHitTestOptions);
  69298. /**
  69299. * execute a hit test with an XR Ray
  69300. *
  69301. * @param xrSession a native xrSession that will execute this hit test
  69302. * @param xrRay the ray (position and direction) to use for ray-casting
  69303. * @param referenceSpace native XR reference space to use for the hit-test
  69304. * @param filter filter function that will filter the results
  69305. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69306. */
  69307. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  69308. /**
  69309. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  69310. * @param event the (select) event to use to select with
  69311. * @param referenceSpace the reference space to use for this hit test
  69312. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69313. */
  69314. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  69315. /**
  69316. * attach this feature
  69317. * Will usually be called by the features manager
  69318. *
  69319. * @returns true if successful.
  69320. */
  69321. attach(): boolean;
  69322. /**
  69323. * detach this feature.
  69324. * Will usually be called by the features manager
  69325. *
  69326. * @returns true if successful.
  69327. */
  69328. detach(): boolean;
  69329. /**
  69330. * Dispose this feature and all of the resources attached
  69331. */
  69332. dispose(): void;
  69333. protected _onXRFrame(frame: XRFrame): void;
  69334. private _onHitTestResults;
  69335. private _onSelect;
  69336. }
  69337. }
  69338. declare module BABYLON {
  69339. /**
  69340. * Options used in the plane detector module
  69341. */
  69342. export interface IWebXRPlaneDetectorOptions {
  69343. /**
  69344. * The node to use to transform the local results to world coordinates
  69345. */
  69346. worldParentNode?: TransformNode;
  69347. }
  69348. /**
  69349. * A babylon interface for a WebXR plane.
  69350. * A Plane is actually a polygon, built from N points in space
  69351. *
  69352. * Supported in chrome 79, not supported in canary 81 ATM
  69353. */
  69354. export interface IWebXRPlane {
  69355. /**
  69356. * a babylon-assigned ID for this polygon
  69357. */
  69358. id: number;
  69359. /**
  69360. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  69361. */
  69362. polygonDefinition: Array<Vector3>;
  69363. /**
  69364. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  69365. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  69366. */
  69367. transformationMatrix: Matrix;
  69368. /**
  69369. * the native xr-plane object
  69370. */
  69371. xrPlane: XRPlane;
  69372. }
  69373. /**
  69374. * The plane detector is used to detect planes in the real world when in AR
  69375. * For more information see https://github.com/immersive-web/real-world-geometry/
  69376. */
  69377. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  69378. private _options;
  69379. private _detectedPlanes;
  69380. private _enabled;
  69381. private _lastFrameDetected;
  69382. /**
  69383. * The module's name
  69384. */
  69385. static readonly Name: string;
  69386. /**
  69387. * The (Babylon) version of this module.
  69388. * This is an integer representing the implementation version.
  69389. * This number does not correspond to the WebXR specs version
  69390. */
  69391. static readonly Version: number;
  69392. /**
  69393. * Observers registered here will be executed when a new plane was added to the session
  69394. */
  69395. onPlaneAddedObservable: Observable<IWebXRPlane>;
  69396. /**
  69397. * Observers registered here will be executed when a plane is no longer detected in the session
  69398. */
  69399. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  69400. /**
  69401. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  69402. * This can execute N times every frame
  69403. */
  69404. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  69405. /**
  69406. * construct a new Plane Detector
  69407. * @param _xrSessionManager an instance of xr Session manager
  69408. * @param _options configuration to use when constructing this feature
  69409. */
  69410. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  69411. /**
  69412. * Dispose this feature and all of the resources attached
  69413. */
  69414. dispose(): void;
  69415. protected _onXRFrame(frame: XRFrame): void;
  69416. private _init;
  69417. private _updatePlaneWithXRPlane;
  69418. /**
  69419. * avoiding using Array.find for global support.
  69420. * @param xrPlane the plane to find in the array
  69421. */
  69422. private findIndexInPlaneArray;
  69423. }
  69424. }
  69425. declare module BABYLON {
  69426. /**
  69427. * Configuration options of the anchor system
  69428. */
  69429. export interface IWebXRAnchorSystemOptions {
  69430. /**
  69431. * Should a new anchor be added every time a select event is triggered
  69432. */
  69433. addAnchorOnSelect?: boolean;
  69434. /**
  69435. * should the anchor system use plane detection.
  69436. * If set to true, the plane-detection feature should be set using setPlaneDetector
  69437. */
  69438. usePlaneDetection?: boolean;
  69439. /**
  69440. * a node that will be used to convert local to world coordinates
  69441. */
  69442. worldParentNode?: TransformNode;
  69443. }
  69444. /**
  69445. * A babylon container for an XR Anchor
  69446. */
  69447. export interface IWebXRAnchor {
  69448. /**
  69449. * A babylon-assigned ID for this anchor
  69450. */
  69451. id: number;
  69452. /**
  69453. * Transformation matrix to apply to an object attached to this anchor
  69454. */
  69455. transformationMatrix: Matrix;
  69456. /**
  69457. * The native anchor object
  69458. */
  69459. xrAnchor: XRAnchor;
  69460. }
  69461. /**
  69462. * An implementation of the anchor system of WebXR.
  69463. * Note that the current documented implementation is not available in any browser. Future implementations
  69464. * will use the frame to create an anchor and not the session or a detected plane
  69465. * For further information see https://github.com/immersive-web/anchors/
  69466. */
  69467. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  69468. private _options;
  69469. private _enabled;
  69470. private _hitTestModule;
  69471. private _lastFrameDetected;
  69472. private _onSelect;
  69473. private _planeDetector;
  69474. private _trackedAnchors;
  69475. /**
  69476. * The module's name
  69477. */
  69478. static readonly Name: string;
  69479. /**
  69480. * The (Babylon) version of this module.
  69481. * This is an integer representing the implementation version.
  69482. * This number does not correspond to the WebXR specs version
  69483. */
  69484. static readonly Version: number;
  69485. /**
  69486. * Observers registered here will be executed when a new anchor was added to the session
  69487. */
  69488. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  69489. /**
  69490. * Observers registered here will be executed when an anchor was removed from the session
  69491. */
  69492. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  69493. /**
  69494. * Observers registered here will be executed when an existing anchor updates
  69495. * This can execute N times every frame
  69496. */
  69497. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  69498. /**
  69499. * constructs a new anchor system
  69500. * @param _xrSessionManager an instance of WebXRSessionManager
  69501. * @param _options configuration object for this feature
  69502. */
  69503. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  69504. /**
  69505. * Add anchor at a specific XR point.
  69506. *
  69507. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  69508. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  69509. * @returns a promise the fulfills when the anchor was created
  69510. */
  69511. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  69512. /**
  69513. * attach this feature
  69514. * Will usually be called by the features manager
  69515. *
  69516. * @returns true if successful.
  69517. */
  69518. attach(): boolean;
  69519. /**
  69520. * detach this feature.
  69521. * Will usually be called by the features manager
  69522. *
  69523. * @returns true if successful.
  69524. */
  69525. detach(): boolean;
  69526. /**
  69527. * Dispose this feature and all of the resources attached
  69528. */
  69529. dispose(): void;
  69530. /**
  69531. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  69532. * @param hitTestModule the hit-test module to use.
  69533. */
  69534. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  69535. /**
  69536. * set the plane detector to use in order to create anchors from frames
  69537. * @param planeDetector the plane-detector module to use
  69538. * @param enable enable plane-anchors. default is true
  69539. */
  69540. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  69541. protected _onXRFrame(frame: XRFrame): void;
  69542. /**
  69543. * avoiding using Array.find for global support.
  69544. * @param xrAnchor the plane to find in the array
  69545. */
  69546. private _findIndexInAnchorArray;
  69547. private _updateAnchorWithXRFrame;
  69548. }
  69549. }
  69550. declare module BABYLON {
  69551. /**
  69552. * Options interface for the background remover plugin
  69553. */
  69554. export interface IWebXRBackgroundRemoverOptions {
  69555. /**
  69556. * Further background meshes to disable when entering AR
  69557. */
  69558. backgroundMeshes?: AbstractMesh[];
  69559. /**
  69560. * flags to configure the removal of the environment helper.
  69561. * If not set, the entire background will be removed. If set, flags should be set as well.
  69562. */
  69563. environmentHelperRemovalFlags?: {
  69564. /**
  69565. * Should the skybox be removed (default false)
  69566. */
  69567. skyBox?: boolean;
  69568. /**
  69569. * Should the ground be removed (default false)
  69570. */
  69571. ground?: boolean;
  69572. };
  69573. /**
  69574. * don't disable the environment helper
  69575. */
  69576. ignoreEnvironmentHelper?: boolean;
  69577. }
  69578. /**
  69579. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  69580. */
  69581. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  69582. /**
  69583. * read-only options to be used in this module
  69584. */
  69585. readonly options: IWebXRBackgroundRemoverOptions;
  69586. /**
  69587. * The module's name
  69588. */
  69589. static readonly Name: string;
  69590. /**
  69591. * The (Babylon) version of this module.
  69592. * This is an integer representing the implementation version.
  69593. * This number does not correspond to the WebXR specs version
  69594. */
  69595. static readonly Version: number;
  69596. /**
  69597. * registered observers will be triggered when the background state changes
  69598. */
  69599. onBackgroundStateChangedObservable: Observable<boolean>;
  69600. /**
  69601. * constructs a new background remover module
  69602. * @param _xrSessionManager the session manager for this module
  69603. * @param options read-only options to be used in this module
  69604. */
  69605. constructor(_xrSessionManager: WebXRSessionManager,
  69606. /**
  69607. * read-only options to be used in this module
  69608. */
  69609. options?: IWebXRBackgroundRemoverOptions);
  69610. /**
  69611. * attach this feature
  69612. * Will usually be called by the features manager
  69613. *
  69614. * @returns true if successful.
  69615. */
  69616. attach(): boolean;
  69617. /**
  69618. * detach this feature.
  69619. * Will usually be called by the features manager
  69620. *
  69621. * @returns true if successful.
  69622. */
  69623. detach(): boolean;
  69624. /**
  69625. * Dispose this feature and all of the resources attached
  69626. */
  69627. dispose(): void;
  69628. protected _onXRFrame(_xrFrame: XRFrame): void;
  69629. private _setBackgroundState;
  69630. }
  69631. }
  69632. declare module BABYLON {
  69633. /**
  69634. * Options for the controller physics feature
  69635. */
  69636. export class IWebXRControllerPhysicsOptions {
  69637. /**
  69638. * Should the headset get its own impostor
  69639. */
  69640. enableHeadsetImpostor?: boolean;
  69641. /**
  69642. * Optional parameters for the headset impostor
  69643. */
  69644. headsetImpostorParams?: {
  69645. /**
  69646. * The type of impostor to create. Default is sphere
  69647. */
  69648. impostorType: number;
  69649. /**
  69650. * the size of the impostor. Defaults to 10cm
  69651. */
  69652. impostorSize?: number | {
  69653. width: number;
  69654. height: number;
  69655. depth: number;
  69656. };
  69657. /**
  69658. * Friction definitions
  69659. */
  69660. friction?: number;
  69661. /**
  69662. * Restitution
  69663. */
  69664. restitution?: number;
  69665. };
  69666. /**
  69667. * The physics properties of the future impostors
  69668. */
  69669. physicsProperties?: {
  69670. /**
  69671. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  69672. * Note that this requires a physics engine that supports mesh impostors!
  69673. */
  69674. useControllerMesh?: boolean;
  69675. /**
  69676. * The type of impostor to create. Default is sphere
  69677. */
  69678. impostorType?: number;
  69679. /**
  69680. * the size of the impostor. Defaults to 10cm
  69681. */
  69682. impostorSize?: number | {
  69683. width: number;
  69684. height: number;
  69685. depth: number;
  69686. };
  69687. /**
  69688. * Friction definitions
  69689. */
  69690. friction?: number;
  69691. /**
  69692. * Restitution
  69693. */
  69694. restitution?: number;
  69695. };
  69696. /**
  69697. * the xr input to use with this pointer selection
  69698. */
  69699. xrInput: WebXRInput;
  69700. }
  69701. /**
  69702. * Add physics impostor to your webxr controllers,
  69703. * including naive calculation of their linear and angular velocity
  69704. */
  69705. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  69706. private readonly _options;
  69707. private _attachController;
  69708. private _controllers;
  69709. private _debugMode;
  69710. private _delta;
  69711. private _headsetImpostor?;
  69712. private _headsetMesh?;
  69713. private _lastTimestamp;
  69714. private _tmpQuaternion;
  69715. private _tmpVector;
  69716. /**
  69717. * The module's name
  69718. */
  69719. static readonly Name: string;
  69720. /**
  69721. * The (Babylon) version of this module.
  69722. * This is an integer representing the implementation version.
  69723. * This number does not correspond to the webxr specs version
  69724. */
  69725. static readonly Version: number;
  69726. /**
  69727. * Construct a new Controller Physics Feature
  69728. * @param _xrSessionManager the corresponding xr session manager
  69729. * @param _options options to create this feature with
  69730. */
  69731. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  69732. /**
  69733. * @hidden
  69734. * enable debugging - will show console outputs and the impostor mesh
  69735. */
  69736. _enablePhysicsDebug(): void;
  69737. /**
  69738. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  69739. * @param xrController the controller to add
  69740. */
  69741. addController(xrController: WebXRInputSource): void;
  69742. /**
  69743. * attach this feature
  69744. * Will usually be called by the features manager
  69745. *
  69746. * @returns true if successful.
  69747. */
  69748. attach(): boolean;
  69749. /**
  69750. * detach this feature.
  69751. * Will usually be called by the features manager
  69752. *
  69753. * @returns true if successful.
  69754. */
  69755. detach(): boolean;
  69756. /**
  69757. * Get the headset impostor, if enabled
  69758. * @returns the impostor
  69759. */
  69760. getHeadsetImpostor(): PhysicsImpostor | undefined;
  69761. /**
  69762. * Get the physics impostor of a specific controller.
  69763. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  69764. * @param controller the controller or the controller id of which to get the impostor
  69765. * @returns the impostor or null
  69766. */
  69767. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  69768. /**
  69769. * Update the physics properties provided in the constructor
  69770. * @param newProperties the new properties object
  69771. */
  69772. setPhysicsProperties(newProperties: {
  69773. impostorType?: number;
  69774. impostorSize?: number | {
  69775. width: number;
  69776. height: number;
  69777. depth: number;
  69778. };
  69779. friction?: number;
  69780. restitution?: number;
  69781. }): void;
  69782. protected _onXRFrame(_xrFrame: any): void;
  69783. private _detachController;
  69784. }
  69785. }
  69786. declare module BABYLON {
  69787. /**
  69788. * Options used for hit testing (version 2)
  69789. */
  69790. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  69791. /**
  69792. * Do not create a permanent hit test. Will usually be used when only
  69793. * transient inputs are needed.
  69794. */
  69795. disablePermanentHitTest?: boolean;
  69796. /**
  69797. * Enable transient (for example touch-based) hit test inspections
  69798. */
  69799. enableTransientHitTest?: boolean;
  69800. /**
  69801. * Offset ray for the permanent hit test
  69802. */
  69803. offsetRay?: Vector3;
  69804. /**
  69805. * Offset ray for the transient hit test
  69806. */
  69807. transientOffsetRay?: Vector3;
  69808. /**
  69809. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  69810. */
  69811. useReferenceSpace?: boolean;
  69812. }
  69813. /**
  69814. * Interface defining the babylon result of hit-test
  69815. */
  69816. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  69817. /**
  69818. * The input source that generated this hit test (if transient)
  69819. */
  69820. inputSource?: XRInputSource;
  69821. /**
  69822. * Is this a transient hit test
  69823. */
  69824. isTransient?: boolean;
  69825. /**
  69826. * Position of the hit test result
  69827. */
  69828. position: Vector3;
  69829. /**
  69830. * Rotation of the hit test result
  69831. */
  69832. rotationQuaternion: Quaternion;
  69833. }
  69834. /**
  69835. * The currently-working hit-test module.
  69836. * Hit test (or Ray-casting) is used to interact with the real world.
  69837. * For further information read here - https://github.com/immersive-web/hit-test
  69838. *
  69839. * Tested on chrome (mobile) 80.
  69840. */
  69841. export class WebXRHitTest extends WebXRAbstractFeature {
  69842. /**
  69843. * options to use when constructing this feature
  69844. */
  69845. readonly options: IWebXRHitTestOptions;
  69846. private _tmpMat;
  69847. private _tmpPos;
  69848. private _tmpQuat;
  69849. private _transientXrHitTestSource;
  69850. private _xrHitTestSource;
  69851. private initHitTestSource;
  69852. /**
  69853. * The module's name
  69854. */
  69855. static readonly Name: string;
  69856. /**
  69857. * The (Babylon) version of this module.
  69858. * This is an integer representing the implementation version.
  69859. * This number does not correspond to the WebXR specs version
  69860. */
  69861. static readonly Version: number;
  69862. /**
  69863. * When set to true, each hit test will have its own position/rotation objects
  69864. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  69865. * the developers will clone them or copy them as they see fit.
  69866. */
  69867. autoCloneTransformation: boolean;
  69868. /**
  69869. * Populated with the last native XR Hit Results
  69870. */
  69871. lastNativeXRHitResults: XRHitResult[];
  69872. /**
  69873. * Triggered when new babylon (transformed) hit test results are available
  69874. */
  69875. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  69876. /**
  69877. * Use this to temporarily pause hit test checks.
  69878. */
  69879. paused: boolean;
  69880. /**
  69881. * Creates a new instance of the hit test feature
  69882. * @param _xrSessionManager an instance of WebXRSessionManager
  69883. * @param options options to use when constructing this feature
  69884. */
  69885. constructor(_xrSessionManager: WebXRSessionManager,
  69886. /**
  69887. * options to use when constructing this feature
  69888. */
  69889. options?: IWebXRHitTestOptions);
  69890. /**
  69891. * attach this feature
  69892. * Will usually be called by the features manager
  69893. *
  69894. * @returns true if successful.
  69895. */
  69896. attach(): boolean;
  69897. /**
  69898. * detach this feature.
  69899. * Will usually be called by the features manager
  69900. *
  69901. * @returns true if successful.
  69902. */
  69903. detach(): boolean;
  69904. /**
  69905. * Dispose this feature and all of the resources attached
  69906. */
  69907. dispose(): void;
  69908. protected _onXRFrame(frame: XRFrame): void;
  69909. private _processWebXRHitTestResult;
  69910. }
  69911. }
  69912. declare module BABYLON {
  69913. /**
  69914. * The motion controller class for all microsoft mixed reality controllers
  69915. */
  69916. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  69917. protected readonly _mapping: {
  69918. defaultButton: {
  69919. "valueNodeName": string;
  69920. "unpressedNodeName": string;
  69921. "pressedNodeName": string;
  69922. };
  69923. defaultAxis: {
  69924. "valueNodeName": string;
  69925. "minNodeName": string;
  69926. "maxNodeName": string;
  69927. };
  69928. buttons: {
  69929. "xr-standard-trigger": {
  69930. "rootNodeName": string;
  69931. "componentProperty": string;
  69932. "states": string[];
  69933. };
  69934. "xr-standard-squeeze": {
  69935. "rootNodeName": string;
  69936. "componentProperty": string;
  69937. "states": string[];
  69938. };
  69939. "xr-standard-touchpad": {
  69940. "rootNodeName": string;
  69941. "labelAnchorNodeName": string;
  69942. "touchPointNodeName": string;
  69943. };
  69944. "xr-standard-thumbstick": {
  69945. "rootNodeName": string;
  69946. "componentProperty": string;
  69947. "states": string[];
  69948. };
  69949. };
  69950. axes: {
  69951. "xr-standard-touchpad": {
  69952. "x-axis": {
  69953. "rootNodeName": string;
  69954. };
  69955. "y-axis": {
  69956. "rootNodeName": string;
  69957. };
  69958. };
  69959. "xr-standard-thumbstick": {
  69960. "x-axis": {
  69961. "rootNodeName": string;
  69962. };
  69963. "y-axis": {
  69964. "rootNodeName": string;
  69965. };
  69966. };
  69967. };
  69968. };
  69969. /**
  69970. * The base url used to load the left and right controller models
  69971. */
  69972. static MODEL_BASE_URL: string;
  69973. /**
  69974. * The name of the left controller model file
  69975. */
  69976. static MODEL_LEFT_FILENAME: string;
  69977. /**
  69978. * The name of the right controller model file
  69979. */
  69980. static MODEL_RIGHT_FILENAME: string;
  69981. profileId: string;
  69982. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  69983. protected _getFilenameAndPath(): {
  69984. filename: string;
  69985. path: string;
  69986. };
  69987. protected _getModelLoadingConstraints(): boolean;
  69988. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69989. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69990. protected _updateModel(): void;
  69991. }
  69992. }
  69993. declare module BABYLON {
  69994. /**
  69995. * The motion controller class for oculus touch (quest, rift).
  69996. * This class supports legacy mapping as well the standard xr mapping
  69997. */
  69998. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  69999. private _forceLegacyControllers;
  70000. private _modelRootNode;
  70001. /**
  70002. * The base url used to load the left and right controller models
  70003. */
  70004. static MODEL_BASE_URL: string;
  70005. /**
  70006. * The name of the left controller model file
  70007. */
  70008. static MODEL_LEFT_FILENAME: string;
  70009. /**
  70010. * The name of the right controller model file
  70011. */
  70012. static MODEL_RIGHT_FILENAME: string;
  70013. /**
  70014. * Base Url for the Quest controller model.
  70015. */
  70016. static QUEST_MODEL_BASE_URL: string;
  70017. profileId: string;
  70018. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  70019. protected _getFilenameAndPath(): {
  70020. filename: string;
  70021. path: string;
  70022. };
  70023. protected _getModelLoadingConstraints(): boolean;
  70024. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70025. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70026. protected _updateModel(): void;
  70027. /**
  70028. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  70029. * between the touch and touch 2.
  70030. */
  70031. private _isQuest;
  70032. }
  70033. }
  70034. declare module BABYLON {
  70035. /**
  70036. * The motion controller class for the standard HTC-Vive controllers
  70037. */
  70038. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  70039. private _modelRootNode;
  70040. /**
  70041. * The base url used to load the left and right controller models
  70042. */
  70043. static MODEL_BASE_URL: string;
  70044. /**
  70045. * File name for the controller model.
  70046. */
  70047. static MODEL_FILENAME: string;
  70048. profileId: string;
  70049. /**
  70050. * Create a new Vive motion controller object
  70051. * @param scene the scene to use to create this controller
  70052. * @param gamepadObject the corresponding gamepad object
  70053. * @param handness the handness of the controller
  70054. */
  70055. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  70056. protected _getFilenameAndPath(): {
  70057. filename: string;
  70058. path: string;
  70059. };
  70060. protected _getModelLoadingConstraints(): boolean;
  70061. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70062. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70063. protected _updateModel(): void;
  70064. }
  70065. }
  70066. declare module BABYLON {
  70067. /**
  70068. * A cursor which tracks a point on a path
  70069. */
  70070. export class PathCursor {
  70071. private path;
  70072. /**
  70073. * Stores path cursor callbacks for when an onchange event is triggered
  70074. */
  70075. private _onchange;
  70076. /**
  70077. * The value of the path cursor
  70078. */
  70079. value: number;
  70080. /**
  70081. * The animation array of the path cursor
  70082. */
  70083. animations: Animation[];
  70084. /**
  70085. * Initializes the path cursor
  70086. * @param path The path to track
  70087. */
  70088. constructor(path: Path2);
  70089. /**
  70090. * Gets the cursor point on the path
  70091. * @returns A point on the path cursor at the cursor location
  70092. */
  70093. getPoint(): Vector3;
  70094. /**
  70095. * Moves the cursor ahead by the step amount
  70096. * @param step The amount to move the cursor forward
  70097. * @returns This path cursor
  70098. */
  70099. moveAhead(step?: number): PathCursor;
  70100. /**
  70101. * Moves the cursor behind by the step amount
  70102. * @param step The amount to move the cursor back
  70103. * @returns This path cursor
  70104. */
  70105. moveBack(step?: number): PathCursor;
  70106. /**
  70107. * Moves the cursor by the step amount
  70108. * If the step amount is greater than one, an exception is thrown
  70109. * @param step The amount to move the cursor
  70110. * @returns This path cursor
  70111. */
  70112. move(step: number): PathCursor;
  70113. /**
  70114. * Ensures that the value is limited between zero and one
  70115. * @returns This path cursor
  70116. */
  70117. private ensureLimits;
  70118. /**
  70119. * Runs onchange callbacks on change (used by the animation engine)
  70120. * @returns This path cursor
  70121. */
  70122. private raiseOnChange;
  70123. /**
  70124. * Executes a function on change
  70125. * @param f A path cursor onchange callback
  70126. * @returns This path cursor
  70127. */
  70128. onchange(f: (cursor: PathCursor) => void): PathCursor;
  70129. }
  70130. }
  70131. declare module BABYLON {
  70132. /** @hidden */
  70133. export var blurPixelShader: {
  70134. name: string;
  70135. shader: string;
  70136. };
  70137. }
  70138. declare module BABYLON {
  70139. /** @hidden */
  70140. export var pointCloudVertexDeclaration: {
  70141. name: string;
  70142. shader: string;
  70143. };
  70144. }
  70145. // Mixins
  70146. interface Window {
  70147. mozIndexedDB: IDBFactory;
  70148. webkitIndexedDB: IDBFactory;
  70149. msIndexedDB: IDBFactory;
  70150. webkitURL: typeof URL;
  70151. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  70152. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  70153. WebGLRenderingContext: WebGLRenderingContext;
  70154. MSGesture: MSGesture;
  70155. CANNON: any;
  70156. AudioContext: AudioContext;
  70157. webkitAudioContext: AudioContext;
  70158. PointerEvent: any;
  70159. Math: Math;
  70160. Uint8Array: Uint8ArrayConstructor;
  70161. Float32Array: Float32ArrayConstructor;
  70162. mozURL: typeof URL;
  70163. msURL: typeof URL;
  70164. VRFrameData: any; // WebVR, from specs 1.1
  70165. DracoDecoderModule: any;
  70166. setImmediate(handler: (...args: any[]) => void): number;
  70167. }
  70168. interface HTMLCanvasElement {
  70169. requestPointerLock(): void;
  70170. msRequestPointerLock?(): void;
  70171. mozRequestPointerLock?(): void;
  70172. webkitRequestPointerLock?(): void;
  70173. /** Track wether a record is in progress */
  70174. isRecording: boolean;
  70175. /** Capture Stream method defined by some browsers */
  70176. captureStream(fps?: number): MediaStream;
  70177. }
  70178. interface CanvasRenderingContext2D {
  70179. msImageSmoothingEnabled: boolean;
  70180. }
  70181. interface MouseEvent {
  70182. mozMovementX: number;
  70183. mozMovementY: number;
  70184. webkitMovementX: number;
  70185. webkitMovementY: number;
  70186. msMovementX: number;
  70187. msMovementY: number;
  70188. }
  70189. interface Navigator {
  70190. mozGetVRDevices: (any: any) => any;
  70191. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70192. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70193. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70194. webkitGetGamepads(): Gamepad[];
  70195. msGetGamepads(): Gamepad[];
  70196. webkitGamepads(): Gamepad[];
  70197. }
  70198. interface HTMLVideoElement {
  70199. mozSrcObject: any;
  70200. }
  70201. interface Math {
  70202. fround(x: number): number;
  70203. imul(a: number, b: number): number;
  70204. }
  70205. interface WebGLRenderingContext {
  70206. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  70207. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  70208. vertexAttribDivisor(index: number, divisor: number): void;
  70209. createVertexArray(): any;
  70210. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  70211. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  70212. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  70213. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  70214. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  70215. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  70216. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  70217. // Queries
  70218. createQuery(): WebGLQuery;
  70219. deleteQuery(query: WebGLQuery): void;
  70220. beginQuery(target: number, query: WebGLQuery): void;
  70221. endQuery(target: number): void;
  70222. getQueryParameter(query: WebGLQuery, pname: number): any;
  70223. getQuery(target: number, pname: number): any;
  70224. MAX_SAMPLES: number;
  70225. RGBA8: number;
  70226. READ_FRAMEBUFFER: number;
  70227. DRAW_FRAMEBUFFER: number;
  70228. UNIFORM_BUFFER: number;
  70229. HALF_FLOAT_OES: number;
  70230. RGBA16F: number;
  70231. RGBA32F: number;
  70232. R32F: number;
  70233. RG32F: number;
  70234. RGB32F: number;
  70235. R16F: number;
  70236. RG16F: number;
  70237. RGB16F: number;
  70238. RED: number;
  70239. RG: number;
  70240. R8: number;
  70241. RG8: number;
  70242. UNSIGNED_INT_24_8: number;
  70243. DEPTH24_STENCIL8: number;
  70244. MIN: number;
  70245. MAX: number;
  70246. /* Multiple Render Targets */
  70247. drawBuffers(buffers: number[]): void;
  70248. readBuffer(src: number): void;
  70249. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  70250. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  70251. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  70252. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  70253. // Occlusion Query
  70254. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  70255. ANY_SAMPLES_PASSED: number;
  70256. QUERY_RESULT_AVAILABLE: number;
  70257. QUERY_RESULT: number;
  70258. }
  70259. interface WebGLProgram {
  70260. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  70261. }
  70262. interface EXT_disjoint_timer_query {
  70263. QUERY_COUNTER_BITS_EXT: number;
  70264. TIME_ELAPSED_EXT: number;
  70265. TIMESTAMP_EXT: number;
  70266. GPU_DISJOINT_EXT: number;
  70267. QUERY_RESULT_EXT: number;
  70268. QUERY_RESULT_AVAILABLE_EXT: number;
  70269. queryCounterEXT(query: WebGLQuery, target: number): void;
  70270. createQueryEXT(): WebGLQuery;
  70271. beginQueryEXT(target: number, query: WebGLQuery): void;
  70272. endQueryEXT(target: number): void;
  70273. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  70274. deleteQueryEXT(query: WebGLQuery): void;
  70275. }
  70276. interface WebGLUniformLocation {
  70277. _currentState: any;
  70278. }
  70279. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  70280. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  70281. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  70282. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  70283. interface WebGLRenderingContext {
  70284. readonly RASTERIZER_DISCARD: number;
  70285. readonly DEPTH_COMPONENT24: number;
  70286. readonly TEXTURE_3D: number;
  70287. readonly TEXTURE_2D_ARRAY: number;
  70288. readonly TEXTURE_COMPARE_FUNC: number;
  70289. readonly TEXTURE_COMPARE_MODE: number;
  70290. readonly COMPARE_REF_TO_TEXTURE: number;
  70291. readonly TEXTURE_WRAP_R: number;
  70292. readonly HALF_FLOAT: number;
  70293. readonly RGB8: number;
  70294. readonly RED_INTEGER: number;
  70295. readonly RG_INTEGER: number;
  70296. readonly RGB_INTEGER: number;
  70297. readonly RGBA_INTEGER: number;
  70298. readonly R8_SNORM: number;
  70299. readonly RG8_SNORM: number;
  70300. readonly RGB8_SNORM: number;
  70301. readonly RGBA8_SNORM: number;
  70302. readonly R8I: number;
  70303. readonly RG8I: number;
  70304. readonly RGB8I: number;
  70305. readonly RGBA8I: number;
  70306. readonly R8UI: number;
  70307. readonly RG8UI: number;
  70308. readonly RGB8UI: number;
  70309. readonly RGBA8UI: number;
  70310. readonly R16I: number;
  70311. readonly RG16I: number;
  70312. readonly RGB16I: number;
  70313. readonly RGBA16I: number;
  70314. readonly R16UI: number;
  70315. readonly RG16UI: number;
  70316. readonly RGB16UI: number;
  70317. readonly RGBA16UI: number;
  70318. readonly R32I: number;
  70319. readonly RG32I: number;
  70320. readonly RGB32I: number;
  70321. readonly RGBA32I: number;
  70322. readonly R32UI: number;
  70323. readonly RG32UI: number;
  70324. readonly RGB32UI: number;
  70325. readonly RGBA32UI: number;
  70326. readonly RGB10_A2UI: number;
  70327. readonly R11F_G11F_B10F: number;
  70328. readonly RGB9_E5: number;
  70329. readonly RGB10_A2: number;
  70330. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  70331. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  70332. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  70333. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  70334. readonly DEPTH_COMPONENT32F: number;
  70335. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  70336. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  70337. 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;
  70338. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  70339. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  70340. readonly TRANSFORM_FEEDBACK: number;
  70341. readonly INTERLEAVED_ATTRIBS: number;
  70342. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  70343. createTransformFeedback(): WebGLTransformFeedback;
  70344. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  70345. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  70346. beginTransformFeedback(primitiveMode: number): void;
  70347. endTransformFeedback(): void;
  70348. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  70349. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70350. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70351. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70352. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  70353. }
  70354. interface ImageBitmap {
  70355. readonly width: number;
  70356. readonly height: number;
  70357. close(): void;
  70358. }
  70359. interface WebGLQuery extends WebGLObject {
  70360. }
  70361. declare var WebGLQuery: {
  70362. prototype: WebGLQuery;
  70363. new(): WebGLQuery;
  70364. };
  70365. interface WebGLSampler extends WebGLObject {
  70366. }
  70367. declare var WebGLSampler: {
  70368. prototype: WebGLSampler;
  70369. new(): WebGLSampler;
  70370. };
  70371. interface WebGLSync extends WebGLObject {
  70372. }
  70373. declare var WebGLSync: {
  70374. prototype: WebGLSync;
  70375. new(): WebGLSync;
  70376. };
  70377. interface WebGLTransformFeedback extends WebGLObject {
  70378. }
  70379. declare var WebGLTransformFeedback: {
  70380. prototype: WebGLTransformFeedback;
  70381. new(): WebGLTransformFeedback;
  70382. };
  70383. interface WebGLVertexArrayObject extends WebGLObject {
  70384. }
  70385. declare var WebGLVertexArrayObject: {
  70386. prototype: WebGLVertexArrayObject;
  70387. new(): WebGLVertexArrayObject;
  70388. };
  70389. // Type definitions for WebVR API
  70390. // Project: https://w3c.github.io/webvr/
  70391. // Definitions by: six a <https://github.com/lostfictions>
  70392. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  70393. interface VRDisplay extends EventTarget {
  70394. /**
  70395. * Dictionary of capabilities describing the VRDisplay.
  70396. */
  70397. readonly capabilities: VRDisplayCapabilities;
  70398. /**
  70399. * z-depth defining the far plane of the eye view frustum
  70400. * enables mapping of values in the render target depth
  70401. * attachment to scene coordinates. Initially set to 10000.0.
  70402. */
  70403. depthFar: number;
  70404. /**
  70405. * z-depth defining the near plane of the eye view frustum
  70406. * enables mapping of values in the render target depth
  70407. * attachment to scene coordinates. Initially set to 0.01.
  70408. */
  70409. depthNear: number;
  70410. /**
  70411. * An identifier for this distinct VRDisplay. Used as an
  70412. * association point in the Gamepad API.
  70413. */
  70414. readonly displayId: number;
  70415. /**
  70416. * A display name, a user-readable name identifying it.
  70417. */
  70418. readonly displayName: string;
  70419. readonly isConnected: boolean;
  70420. readonly isPresenting: boolean;
  70421. /**
  70422. * If this VRDisplay supports room-scale experiences, the optional
  70423. * stage attribute contains details on the room-scale parameters.
  70424. */
  70425. readonly stageParameters: VRStageParameters | null;
  70426. /**
  70427. * Passing the value returned by `requestAnimationFrame` to
  70428. * `cancelAnimationFrame` will unregister the callback.
  70429. * @param handle Define the hanle of the request to cancel
  70430. */
  70431. cancelAnimationFrame(handle: number): void;
  70432. /**
  70433. * Stops presenting to the VRDisplay.
  70434. * @returns a promise to know when it stopped
  70435. */
  70436. exitPresent(): Promise<void>;
  70437. /**
  70438. * Return the current VREyeParameters for the given eye.
  70439. * @param whichEye Define the eye we want the parameter for
  70440. * @returns the eye parameters
  70441. */
  70442. getEyeParameters(whichEye: string): VREyeParameters;
  70443. /**
  70444. * Populates the passed VRFrameData with the information required to render
  70445. * the current frame.
  70446. * @param frameData Define the data structure to populate
  70447. * @returns true if ok otherwise false
  70448. */
  70449. getFrameData(frameData: VRFrameData): boolean;
  70450. /**
  70451. * Get the layers currently being presented.
  70452. * @returns the list of VR layers
  70453. */
  70454. getLayers(): VRLayer[];
  70455. /**
  70456. * Return a VRPose containing the future predicted pose of the VRDisplay
  70457. * when the current frame will be presented. The value returned will not
  70458. * change until JavaScript has returned control to the browser.
  70459. *
  70460. * The VRPose will contain the position, orientation, velocity,
  70461. * and acceleration of each of these properties.
  70462. * @returns the pose object
  70463. */
  70464. getPose(): VRPose;
  70465. /**
  70466. * Return the current instantaneous pose of the VRDisplay, with no
  70467. * prediction applied.
  70468. * @returns the current instantaneous pose
  70469. */
  70470. getImmediatePose(): VRPose;
  70471. /**
  70472. * The callback passed to `requestAnimationFrame` will be called
  70473. * any time a new frame should be rendered. When the VRDisplay is
  70474. * presenting the callback will be called at the native refresh
  70475. * rate of the HMD. When not presenting this function acts
  70476. * identically to how window.requestAnimationFrame acts. Content should
  70477. * make no assumptions of frame rate or vsync behavior as the HMD runs
  70478. * asynchronously from other displays and at differing refresh rates.
  70479. * @param callback Define the eaction to run next frame
  70480. * @returns the request handle it
  70481. */
  70482. requestAnimationFrame(callback: FrameRequestCallback): number;
  70483. /**
  70484. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  70485. * Repeat calls while already presenting will update the VRLayers being displayed.
  70486. * @param layers Define the list of layer to present
  70487. * @returns a promise to know when the request has been fulfilled
  70488. */
  70489. requestPresent(layers: VRLayer[]): Promise<void>;
  70490. /**
  70491. * Reset the pose for this display, treating its current position and
  70492. * orientation as the "origin/zero" values. VRPose.position,
  70493. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  70494. * updated when calling resetPose(). This should be called in only
  70495. * sitting-space experiences.
  70496. */
  70497. resetPose(): void;
  70498. /**
  70499. * The VRLayer provided to the VRDisplay will be captured and presented
  70500. * in the HMD. Calling this function has the same effect on the source
  70501. * canvas as any other operation that uses its source image, and canvases
  70502. * created without preserveDrawingBuffer set to true will be cleared.
  70503. * @param pose Define the pose to submit
  70504. */
  70505. submitFrame(pose?: VRPose): void;
  70506. }
  70507. declare var VRDisplay: {
  70508. prototype: VRDisplay;
  70509. new(): VRDisplay;
  70510. };
  70511. interface VRLayer {
  70512. leftBounds?: number[] | Float32Array | null;
  70513. rightBounds?: number[] | Float32Array | null;
  70514. source?: HTMLCanvasElement | null;
  70515. }
  70516. interface VRDisplayCapabilities {
  70517. readonly canPresent: boolean;
  70518. readonly hasExternalDisplay: boolean;
  70519. readonly hasOrientation: boolean;
  70520. readonly hasPosition: boolean;
  70521. readonly maxLayers: number;
  70522. }
  70523. interface VREyeParameters {
  70524. /** @deprecated */
  70525. readonly fieldOfView: VRFieldOfView;
  70526. readonly offset: Float32Array;
  70527. readonly renderHeight: number;
  70528. readonly renderWidth: number;
  70529. }
  70530. interface VRFieldOfView {
  70531. readonly downDegrees: number;
  70532. readonly leftDegrees: number;
  70533. readonly rightDegrees: number;
  70534. readonly upDegrees: number;
  70535. }
  70536. interface VRFrameData {
  70537. readonly leftProjectionMatrix: Float32Array;
  70538. readonly leftViewMatrix: Float32Array;
  70539. readonly pose: VRPose;
  70540. readonly rightProjectionMatrix: Float32Array;
  70541. readonly rightViewMatrix: Float32Array;
  70542. readonly timestamp: number;
  70543. }
  70544. interface VRPose {
  70545. readonly angularAcceleration: Float32Array | null;
  70546. readonly angularVelocity: Float32Array | null;
  70547. readonly linearAcceleration: Float32Array | null;
  70548. readonly linearVelocity: Float32Array | null;
  70549. readonly orientation: Float32Array | null;
  70550. readonly position: Float32Array | null;
  70551. readonly timestamp: number;
  70552. }
  70553. interface VRStageParameters {
  70554. sittingToStandingTransform?: Float32Array;
  70555. sizeX?: number;
  70556. sizeY?: number;
  70557. }
  70558. interface Navigator {
  70559. getVRDisplays(): Promise<VRDisplay[]>;
  70560. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  70561. }
  70562. interface Window {
  70563. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  70564. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  70565. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  70566. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  70567. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  70568. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  70569. }
  70570. interface Gamepad {
  70571. readonly displayId: number;
  70572. }
  70573. type XRSessionMode =
  70574. | "inline"
  70575. | "immersive-vr"
  70576. | "immersive-ar";
  70577. type XRReferenceSpaceType =
  70578. | "viewer"
  70579. | "local"
  70580. | "local-floor"
  70581. | "bounded-floor"
  70582. | "unbounded";
  70583. type XREnvironmentBlendMode =
  70584. | "opaque"
  70585. | "additive"
  70586. | "alpha-blend";
  70587. type XRVisibilityState =
  70588. | "visible"
  70589. | "visible-blurred"
  70590. | "hidden";
  70591. type XRHandedness =
  70592. | "none"
  70593. | "left"
  70594. | "right";
  70595. type XRTargetRayMode =
  70596. | "gaze"
  70597. | "tracked-pointer"
  70598. | "screen";
  70599. type XREye =
  70600. | "none"
  70601. | "left"
  70602. | "right";
  70603. interface XRSpace extends EventTarget {
  70604. }
  70605. interface XRRenderState {
  70606. depthNear?: number;
  70607. depthFar?: number;
  70608. inlineVerticalFieldOfView?: number;
  70609. baseLayer?: XRWebGLLayer;
  70610. }
  70611. interface XRInputSource {
  70612. handedness: XRHandedness;
  70613. targetRayMode: XRTargetRayMode;
  70614. targetRaySpace: XRSpace;
  70615. gripSpace: XRSpace | undefined;
  70616. gamepad: Gamepad | undefined;
  70617. profiles: Array<string>;
  70618. }
  70619. interface XRSessionInit {
  70620. optionalFeatures?: XRReferenceSpaceType[];
  70621. requiredFeatures?: XRReferenceSpaceType[];
  70622. }
  70623. interface XRSession extends XRAnchorCreator {
  70624. addEventListener: Function;
  70625. removeEventListener: Function;
  70626. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  70627. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  70628. requestAnimationFrame: Function;
  70629. end(): Promise<void>;
  70630. renderState: XRRenderState;
  70631. inputSources: Array<XRInputSource>;
  70632. // hit test
  70633. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  70634. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  70635. // legacy AR hit test
  70636. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  70637. // legacy plane detection
  70638. updateWorldTrackingState(options: {
  70639. planeDetectionState?: { enabled: boolean; }
  70640. }): void;
  70641. }
  70642. interface XRReferenceSpace extends XRSpace {
  70643. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  70644. onreset: any;
  70645. }
  70646. type XRPlaneSet = Set<XRPlane>;
  70647. type XRAnchorSet = Set<XRAnchor>;
  70648. interface XRFrame {
  70649. session: XRSession;
  70650. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  70651. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  70652. // AR
  70653. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  70654. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  70655. // Anchors
  70656. trackedAnchors?: XRAnchorSet;
  70657. // Planes
  70658. worldInformation: {
  70659. detectedPlanes?: XRPlaneSet;
  70660. };
  70661. }
  70662. interface XRViewerPose extends XRPose {
  70663. views: Array<XRView>;
  70664. }
  70665. interface XRPose {
  70666. transform: XRRigidTransform;
  70667. emulatedPosition: boolean;
  70668. }
  70669. interface XRWebGLLayerOptions {
  70670. antialias?: boolean;
  70671. depth?: boolean;
  70672. stencil?: boolean;
  70673. alpha?: boolean;
  70674. multiview?: boolean;
  70675. framebufferScaleFactor?: number;
  70676. }
  70677. declare var XRWebGLLayer: {
  70678. prototype: XRWebGLLayer;
  70679. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  70680. };
  70681. interface XRWebGLLayer {
  70682. framebuffer: WebGLFramebuffer;
  70683. framebufferWidth: number;
  70684. framebufferHeight: number;
  70685. getViewport: Function;
  70686. }
  70687. declare class XRRigidTransform {
  70688. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  70689. position: DOMPointReadOnly;
  70690. orientation: DOMPointReadOnly;
  70691. matrix: Float32Array;
  70692. inverse: XRRigidTransform;
  70693. }
  70694. interface XRView {
  70695. eye: XREye;
  70696. projectionMatrix: Float32Array;
  70697. transform: XRRigidTransform;
  70698. }
  70699. interface XRInputSourceChangeEvent {
  70700. session: XRSession;
  70701. removed: Array<XRInputSource>;
  70702. added: Array<XRInputSource>;
  70703. }
  70704. interface XRInputSourceEvent extends Event {
  70705. readonly frame: XRFrame;
  70706. readonly inputSource: XRInputSource;
  70707. }
  70708. // Experimental(er) features
  70709. declare class XRRay {
  70710. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  70711. origin: DOMPointReadOnly;
  70712. direction: DOMPointReadOnly;
  70713. matrix: Float32Array;
  70714. }
  70715. declare enum XRHitTestTrackableType {
  70716. "point",
  70717. "plane"
  70718. }
  70719. interface XRHitResult {
  70720. hitMatrix: Float32Array;
  70721. }
  70722. interface XRTransientInputHitTestResult {
  70723. readonly inputSource: XRInputSource;
  70724. readonly results: Array<XRHitTestResult>;
  70725. }
  70726. interface XRHitTestResult {
  70727. getPose(baseSpace: XRSpace): XRPose | undefined;
  70728. }
  70729. interface XRHitTestSource {
  70730. cancel(): void;
  70731. }
  70732. interface XRTransientInputHitTestSource {
  70733. cancel(): void;
  70734. }
  70735. interface XRHitTestOptionsInit {
  70736. space: XRSpace;
  70737. entityTypes?: Array<XRHitTestTrackableType>;
  70738. offsetRay?: XRRay;
  70739. }
  70740. interface XRTransientInputHitTestOptionsInit {
  70741. profile: string;
  70742. entityTypes?: Array<XRHitTestTrackableType>;
  70743. offsetRay?: XRRay;
  70744. }
  70745. interface XRAnchor {
  70746. // remove?
  70747. id?: string;
  70748. anchorSpace: XRSpace;
  70749. lastChangedTime: number;
  70750. detach(): void;
  70751. }
  70752. interface XRPlane extends XRAnchorCreator {
  70753. orientation: "Horizontal" | "Vertical";
  70754. planeSpace: XRSpace;
  70755. polygon: Array<DOMPointReadOnly>;
  70756. lastChangedTime: number;
  70757. }
  70758. interface XRAnchorCreator {
  70759. // AR Anchors
  70760. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  70761. }
  70762. /**
  70763. * @ignore
  70764. */
  70765. declare module BABYLON.GLTF2.Exporter {
  70766. }
  70767. /**
  70768. * @ignore
  70769. */
  70770. declare module BABYLON.GLTF1 {
  70771. }
  70772. declare module BABYLON.GUI {
  70773. /**
  70774. * Class used to specific a value and its associated unit
  70775. */
  70776. export class ValueAndUnit {
  70777. /** defines the unit to store */
  70778. unit: number;
  70779. /** defines a boolean indicating if the value can be negative */
  70780. negativeValueAllowed: boolean;
  70781. private _value;
  70782. private _originalUnit;
  70783. /**
  70784. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  70785. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70786. */
  70787. ignoreAdaptiveScaling: boolean;
  70788. /**
  70789. * Creates a new ValueAndUnit
  70790. * @param value defines the value to store
  70791. * @param unit defines the unit to store
  70792. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  70793. */
  70794. constructor(value: number,
  70795. /** defines the unit to store */
  70796. unit?: number,
  70797. /** defines a boolean indicating if the value can be negative */
  70798. negativeValueAllowed?: boolean);
  70799. /** Gets a boolean indicating if the value is a percentage */
  70800. get isPercentage(): boolean;
  70801. /** Gets a boolean indicating if the value is store as pixel */
  70802. get isPixel(): boolean;
  70803. /** Gets direct internal value */
  70804. get internalValue(): number;
  70805. /**
  70806. * Gets value as pixel
  70807. * @param host defines the root host
  70808. * @param refValue defines the reference value for percentages
  70809. * @returns the value as pixel
  70810. */
  70811. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  70812. /**
  70813. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  70814. * @param value defines the value to store
  70815. * @param unit defines the unit to store
  70816. * @returns the current ValueAndUnit
  70817. */
  70818. updateInPlace(value: number, unit?: number): ValueAndUnit;
  70819. /**
  70820. * Gets the value accordingly to its unit
  70821. * @param host defines the root host
  70822. * @returns the value
  70823. */
  70824. getValue(host: AdvancedDynamicTexture): number;
  70825. /**
  70826. * Gets a string representation of the value
  70827. * @param host defines the root host
  70828. * @param decimals defines an optional number of decimals to display
  70829. * @returns a string
  70830. */
  70831. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  70832. /**
  70833. * Store a value parsed from a string
  70834. * @param source defines the source string
  70835. * @returns true if the value was successfully parsed
  70836. */
  70837. fromString(source: string | number): boolean;
  70838. private static _Regex;
  70839. private static _UNITMODE_PERCENTAGE;
  70840. private static _UNITMODE_PIXEL;
  70841. /** UNITMODE_PERCENTAGE */
  70842. static get UNITMODE_PERCENTAGE(): number;
  70843. /** UNITMODE_PIXEL */
  70844. static get UNITMODE_PIXEL(): number;
  70845. }
  70846. }
  70847. declare module BABYLON.GUI {
  70848. /**
  70849. * Define a style used by control to automatically setup properties based on a template.
  70850. * Only support font related properties so far
  70851. */
  70852. export class Style implements BABYLON.IDisposable {
  70853. private _fontFamily;
  70854. private _fontStyle;
  70855. private _fontWeight;
  70856. /** @hidden */
  70857. _host: AdvancedDynamicTexture;
  70858. /** @hidden */
  70859. _fontSize: ValueAndUnit;
  70860. /**
  70861. * BABYLON.Observable raised when the style values are changed
  70862. */
  70863. onChangedObservable: BABYLON.Observable<Style>;
  70864. /**
  70865. * Creates a new style object
  70866. * @param host defines the AdvancedDynamicTexture which hosts this style
  70867. */
  70868. constructor(host: AdvancedDynamicTexture);
  70869. /**
  70870. * Gets or sets the font size
  70871. */
  70872. get fontSize(): string | number;
  70873. set fontSize(value: string | number);
  70874. /**
  70875. * Gets or sets the font family
  70876. */
  70877. get fontFamily(): string;
  70878. set fontFamily(value: string);
  70879. /**
  70880. * Gets or sets the font style
  70881. */
  70882. get fontStyle(): string;
  70883. set fontStyle(value: string);
  70884. /** Gets or sets font weight */
  70885. get fontWeight(): string;
  70886. set fontWeight(value: string);
  70887. /** Dispose all associated resources */
  70888. dispose(): void;
  70889. }
  70890. }
  70891. declare module BABYLON.GUI {
  70892. /**
  70893. * Class used to transport BABYLON.Vector2 information for pointer events
  70894. */
  70895. export class Vector2WithInfo extends BABYLON.Vector2 {
  70896. /** defines the current mouse button index */
  70897. buttonIndex: number;
  70898. /**
  70899. * Creates a new Vector2WithInfo
  70900. * @param source defines the vector2 data to transport
  70901. * @param buttonIndex defines the current mouse button index
  70902. */
  70903. constructor(source: BABYLON.Vector2,
  70904. /** defines the current mouse button index */
  70905. buttonIndex?: number);
  70906. }
  70907. /** Class used to provide 2D matrix features */
  70908. export class Matrix2D {
  70909. /** Gets the internal array of 6 floats used to store matrix data */
  70910. m: Float32Array;
  70911. /**
  70912. * Creates a new matrix
  70913. * @param m00 defines value for (0, 0)
  70914. * @param m01 defines value for (0, 1)
  70915. * @param m10 defines value for (1, 0)
  70916. * @param m11 defines value for (1, 1)
  70917. * @param m20 defines value for (2, 0)
  70918. * @param m21 defines value for (2, 1)
  70919. */
  70920. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  70921. /**
  70922. * Fills the matrix from direct values
  70923. * @param m00 defines value for (0, 0)
  70924. * @param m01 defines value for (0, 1)
  70925. * @param m10 defines value for (1, 0)
  70926. * @param m11 defines value for (1, 1)
  70927. * @param m20 defines value for (2, 0)
  70928. * @param m21 defines value for (2, 1)
  70929. * @returns the current modified matrix
  70930. */
  70931. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  70932. /**
  70933. * Gets matrix determinant
  70934. * @returns the determinant
  70935. */
  70936. determinant(): number;
  70937. /**
  70938. * Inverses the matrix and stores it in a target matrix
  70939. * @param result defines the target matrix
  70940. * @returns the current matrix
  70941. */
  70942. invertToRef(result: Matrix2D): Matrix2D;
  70943. /**
  70944. * Multiplies the current matrix with another one
  70945. * @param other defines the second operand
  70946. * @param result defines the target matrix
  70947. * @returns the current matrix
  70948. */
  70949. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  70950. /**
  70951. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  70952. * @param x defines the x coordinate to transform
  70953. * @param y defines the x coordinate to transform
  70954. * @param result defines the target vector2
  70955. * @returns the current matrix
  70956. */
  70957. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  70958. /**
  70959. * Creates an identity matrix
  70960. * @returns a new matrix
  70961. */
  70962. static Identity(): Matrix2D;
  70963. /**
  70964. * Creates a translation matrix and stores it in a target matrix
  70965. * @param x defines the x coordinate of the translation
  70966. * @param y defines the y coordinate of the translation
  70967. * @param result defines the target matrix
  70968. */
  70969. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  70970. /**
  70971. * Creates a scaling matrix and stores it in a target matrix
  70972. * @param x defines the x coordinate of the scaling
  70973. * @param y defines the y coordinate of the scaling
  70974. * @param result defines the target matrix
  70975. */
  70976. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  70977. /**
  70978. * Creates a rotation matrix and stores it in a target matrix
  70979. * @param angle defines the rotation angle
  70980. * @param result defines the target matrix
  70981. */
  70982. static RotationToRef(angle: number, result: Matrix2D): void;
  70983. private static _TempPreTranslationMatrix;
  70984. private static _TempPostTranslationMatrix;
  70985. private static _TempRotationMatrix;
  70986. private static _TempScalingMatrix;
  70987. private static _TempCompose0;
  70988. private static _TempCompose1;
  70989. private static _TempCompose2;
  70990. /**
  70991. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  70992. * @param tx defines the x coordinate of the translation
  70993. * @param ty defines the y coordinate of the translation
  70994. * @param angle defines the rotation angle
  70995. * @param scaleX defines the x coordinate of the scaling
  70996. * @param scaleY defines the y coordinate of the scaling
  70997. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  70998. * @param result defines the target matrix
  70999. */
  71000. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  71001. }
  71002. }
  71003. declare module BABYLON.GUI {
  71004. /**
  71005. * Class used to store 2D control sizes
  71006. */
  71007. export class Measure {
  71008. /** defines left coordinate */
  71009. left: number;
  71010. /** defines top coordinate */
  71011. top: number;
  71012. /** defines width dimension */
  71013. width: number;
  71014. /** defines height dimension */
  71015. height: number;
  71016. /**
  71017. * Creates a new measure
  71018. * @param left defines left coordinate
  71019. * @param top defines top coordinate
  71020. * @param width defines width dimension
  71021. * @param height defines height dimension
  71022. */
  71023. constructor(
  71024. /** defines left coordinate */
  71025. left: number,
  71026. /** defines top coordinate */
  71027. top: number,
  71028. /** defines width dimension */
  71029. width: number,
  71030. /** defines height dimension */
  71031. height: number);
  71032. /**
  71033. * Copy from another measure
  71034. * @param other defines the other measure to copy from
  71035. */
  71036. copyFrom(other: Measure): void;
  71037. /**
  71038. * Copy from a group of 4 floats
  71039. * @param left defines left coordinate
  71040. * @param top defines top coordinate
  71041. * @param width defines width dimension
  71042. * @param height defines height dimension
  71043. */
  71044. copyFromFloats(left: number, top: number, width: number, height: number): void;
  71045. /**
  71046. * Computes the axis aligned bounding box measure for two given measures
  71047. * @param a Input measure
  71048. * @param b Input measure
  71049. * @param result the resulting bounding measure
  71050. */
  71051. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  71052. /**
  71053. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  71054. * @param transform the matrix to transform the measure before computing the AABB
  71055. * @param result the resulting AABB
  71056. */
  71057. transformToRef(transform: Matrix2D, result: Measure): void;
  71058. /**
  71059. * Check equality between this measure and another one
  71060. * @param other defines the other measures
  71061. * @returns true if both measures are equals
  71062. */
  71063. isEqualsTo(other: Measure): boolean;
  71064. /**
  71065. * Creates an empty measure
  71066. * @returns a new measure
  71067. */
  71068. static Empty(): Measure;
  71069. }
  71070. }
  71071. declare module BABYLON.GUI {
  71072. /**
  71073. * Interface used to define a control that can receive focus
  71074. */
  71075. export interface IFocusableControl {
  71076. /**
  71077. * Function called when the control receives the focus
  71078. */
  71079. onFocus(): void;
  71080. /**
  71081. * Function called when the control loses the focus
  71082. */
  71083. onBlur(): void;
  71084. /**
  71085. * Function called to let the control handle keyboard events
  71086. * @param evt defines the current keyboard event
  71087. */
  71088. processKeyboard(evt: KeyboardEvent): void;
  71089. /**
  71090. * Function called to get the list of controls that should not steal the focus from this control
  71091. * @returns an array of controls
  71092. */
  71093. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  71094. }
  71095. /**
  71096. * Class used to create texture to support 2D GUI elements
  71097. * @see http://doc.babylonjs.com/how_to/gui
  71098. */
  71099. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  71100. private _isDirty;
  71101. private _renderObserver;
  71102. private _resizeObserver;
  71103. private _preKeyboardObserver;
  71104. private _pointerMoveObserver;
  71105. private _pointerObserver;
  71106. private _canvasPointerOutObserver;
  71107. private _background;
  71108. /** @hidden */
  71109. _rootContainer: Container;
  71110. /** @hidden */
  71111. _lastPickedControl: Control;
  71112. /** @hidden */
  71113. _lastControlOver: {
  71114. [pointerId: number]: Control;
  71115. };
  71116. /** @hidden */
  71117. _lastControlDown: {
  71118. [pointerId: number]: Control;
  71119. };
  71120. /** @hidden */
  71121. _capturingControl: {
  71122. [pointerId: number]: Control;
  71123. };
  71124. /** @hidden */
  71125. _shouldBlockPointer: boolean;
  71126. /** @hidden */
  71127. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  71128. /** @hidden */
  71129. _linkedControls: Control[];
  71130. private _isFullscreen;
  71131. private _fullscreenViewport;
  71132. private _idealWidth;
  71133. private _idealHeight;
  71134. private _useSmallestIdeal;
  71135. private _renderAtIdealSize;
  71136. private _focusedControl;
  71137. private _blockNextFocusCheck;
  71138. private _renderScale;
  71139. private _rootElement;
  71140. private _cursorChanged;
  71141. private _defaultMousePointerId;
  71142. /** @hidden */
  71143. _numLayoutCalls: number;
  71144. /** Gets the number of layout calls made the last time the ADT has been rendered */
  71145. get numLayoutCalls(): number;
  71146. /** @hidden */
  71147. _numRenderCalls: number;
  71148. /** Gets the number of render calls made the last time the ADT has been rendered */
  71149. get numRenderCalls(): number;
  71150. /**
  71151. * Define type to string to ensure compatibility across browsers
  71152. * Safari doesn't support DataTransfer constructor
  71153. */
  71154. private _clipboardData;
  71155. /**
  71156. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  71157. */
  71158. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  71159. /**
  71160. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  71161. */
  71162. onControlPickedObservable: BABYLON.Observable<Control>;
  71163. /**
  71164. * BABYLON.Observable event triggered before layout is evaluated
  71165. */
  71166. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71167. /**
  71168. * BABYLON.Observable event triggered after the layout was evaluated
  71169. */
  71170. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71171. /**
  71172. * BABYLON.Observable event triggered before the texture is rendered
  71173. */
  71174. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71175. /**
  71176. * BABYLON.Observable event triggered after the texture was rendered
  71177. */
  71178. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71179. /**
  71180. * Gets or sets a boolean defining if alpha is stored as premultiplied
  71181. */
  71182. premulAlpha: boolean;
  71183. /**
  71184. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  71185. * Useful when you want more antialiasing
  71186. */
  71187. get renderScale(): number;
  71188. set renderScale(value: number);
  71189. /** Gets or sets the background color */
  71190. get background(): string;
  71191. set background(value: string);
  71192. /**
  71193. * Gets or sets the ideal width used to design controls.
  71194. * The GUI will then rescale everything accordingly
  71195. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71196. */
  71197. get idealWidth(): number;
  71198. set idealWidth(value: number);
  71199. /**
  71200. * Gets or sets the ideal height used to design controls.
  71201. * The GUI will then rescale everything accordingly
  71202. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71203. */
  71204. get idealHeight(): number;
  71205. set idealHeight(value: number);
  71206. /**
  71207. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  71208. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71209. */
  71210. get useSmallestIdeal(): boolean;
  71211. set useSmallestIdeal(value: boolean);
  71212. /**
  71213. * Gets or sets a boolean indicating if adaptive scaling must be used
  71214. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71215. */
  71216. get renderAtIdealSize(): boolean;
  71217. set renderAtIdealSize(value: boolean);
  71218. /**
  71219. * Gets the ratio used when in "ideal mode"
  71220. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71221. * */
  71222. get idealRatio(): number;
  71223. /**
  71224. * Gets the underlying layer used to render the texture when in fullscreen mode
  71225. */
  71226. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  71227. /**
  71228. * Gets the root container control
  71229. */
  71230. get rootContainer(): Container;
  71231. /**
  71232. * Returns an array containing the root container.
  71233. * This is mostly used to let the Inspector introspects the ADT
  71234. * @returns an array containing the rootContainer
  71235. */
  71236. getChildren(): Array<Container>;
  71237. /**
  71238. * Will return all controls that are inside this texture
  71239. * @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
  71240. * @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
  71241. * @return all child controls
  71242. */
  71243. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  71244. /**
  71245. * Gets or sets the current focused control
  71246. */
  71247. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  71248. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  71249. /**
  71250. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  71251. */
  71252. get isForeground(): boolean;
  71253. set isForeground(value: boolean);
  71254. /**
  71255. * Gets or set information about clipboardData
  71256. */
  71257. get clipboardData(): string;
  71258. set clipboardData(value: string);
  71259. /**
  71260. * Creates a new AdvancedDynamicTexture
  71261. * @param name defines the name of the texture
  71262. * @param width defines the width of the texture
  71263. * @param height defines the height of the texture
  71264. * @param scene defines the hosting scene
  71265. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  71266. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  71267. */
  71268. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  71269. /**
  71270. * Get the current class name of the texture useful for serialization or dynamic coding.
  71271. * @returns "AdvancedDynamicTexture"
  71272. */
  71273. getClassName(): string;
  71274. /**
  71275. * Function used to execute a function on all controls
  71276. * @param func defines the function to execute
  71277. * @param container defines the container where controls belong. If null the root container will be used
  71278. */
  71279. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  71280. private _useInvalidateRectOptimization;
  71281. /**
  71282. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  71283. */
  71284. get useInvalidateRectOptimization(): boolean;
  71285. set useInvalidateRectOptimization(value: boolean);
  71286. private _invalidatedRectangle;
  71287. /**
  71288. * Invalidates a rectangle area on the gui texture
  71289. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  71290. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  71291. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  71292. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  71293. */
  71294. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  71295. /**
  71296. * Marks the texture as dirty forcing a complete update
  71297. */
  71298. markAsDirty(): void;
  71299. /**
  71300. * Helper function used to create a new style
  71301. * @returns a new style
  71302. * @see http://doc.babylonjs.com/how_to/gui#styles
  71303. */
  71304. createStyle(): Style;
  71305. /**
  71306. * Adds a new control to the root container
  71307. * @param control defines the control to add
  71308. * @returns the current texture
  71309. */
  71310. addControl(control: Control): AdvancedDynamicTexture;
  71311. /**
  71312. * Removes a control from the root container
  71313. * @param control defines the control to remove
  71314. * @returns the current texture
  71315. */
  71316. removeControl(control: Control): AdvancedDynamicTexture;
  71317. /**
  71318. * Release all resources
  71319. */
  71320. dispose(): void;
  71321. private _onResize;
  71322. /** @hidden */
  71323. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  71324. /**
  71325. * Get screen coordinates for a vector3
  71326. * @param position defines the position to project
  71327. * @param worldMatrix defines the world matrix to use
  71328. * @returns the projected position
  71329. */
  71330. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  71331. private _checkUpdate;
  71332. private _clearMeasure;
  71333. private _render;
  71334. /** @hidden */
  71335. _changeCursor(cursor: string): void;
  71336. /** @hidden */
  71337. _registerLastControlDown(control: Control, pointerId: number): void;
  71338. private _doPicking;
  71339. /** @hidden */
  71340. _cleanControlAfterRemovalFromList(list: {
  71341. [pointerId: number]: Control;
  71342. }, control: Control): void;
  71343. /** @hidden */
  71344. _cleanControlAfterRemoval(control: Control): void;
  71345. /** Attach to all scene events required to support pointer events */
  71346. attach(): void;
  71347. /** @hidden */
  71348. private onClipboardCopy;
  71349. /** @hidden */
  71350. private onClipboardCut;
  71351. /** @hidden */
  71352. private onClipboardPaste;
  71353. /**
  71354. * Register the clipboard Events onto the canvas
  71355. */
  71356. registerClipboardEvents(): void;
  71357. /**
  71358. * Unregister the clipboard Events from the canvas
  71359. */
  71360. unRegisterClipboardEvents(): void;
  71361. /**
  71362. * Connect the texture to a hosting mesh to enable interactions
  71363. * @param mesh defines the mesh to attach to
  71364. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  71365. */
  71366. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  71367. /**
  71368. * Move the focus to a specific control
  71369. * @param control defines the control which will receive the focus
  71370. */
  71371. moveFocusToControl(control: IFocusableControl): void;
  71372. private _manageFocus;
  71373. private _attachToOnPointerOut;
  71374. /**
  71375. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  71376. * @param mesh defines the mesh which will receive the texture
  71377. * @param width defines the texture width (1024 by default)
  71378. * @param height defines the texture height (1024 by default)
  71379. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  71380. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  71381. * @returns a new AdvancedDynamicTexture
  71382. */
  71383. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  71384. /**
  71385. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  71386. * In this mode the texture will rely on a layer for its rendering.
  71387. * This allows it to be treated like any other layer.
  71388. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  71389. * LayerMask is set through advancedTexture.layer.layerMask
  71390. * @param name defines name for the texture
  71391. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  71392. * @param scene defines the hsoting scene
  71393. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  71394. * @returns a new AdvancedDynamicTexture
  71395. */
  71396. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  71397. }
  71398. }
  71399. declare module BABYLON.GUI {
  71400. /**
  71401. * Root class used for all 2D controls
  71402. * @see http://doc.babylonjs.com/how_to/gui#controls
  71403. */
  71404. export class Control {
  71405. /** defines the name of the control */
  71406. name?: string | undefined;
  71407. /**
  71408. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  71409. */
  71410. static AllowAlphaInheritance: boolean;
  71411. private _alpha;
  71412. private _alphaSet;
  71413. private _zIndex;
  71414. /** @hidden */
  71415. _host: AdvancedDynamicTexture;
  71416. /** Gets or sets the control parent */
  71417. parent: BABYLON.Nullable<Container>;
  71418. /** @hidden */
  71419. _currentMeasure: Measure;
  71420. private _fontFamily;
  71421. private _fontStyle;
  71422. private _fontWeight;
  71423. private _fontSize;
  71424. private _font;
  71425. /** @hidden */
  71426. _width: ValueAndUnit;
  71427. /** @hidden */
  71428. _height: ValueAndUnit;
  71429. /** @hidden */
  71430. protected _fontOffset: {
  71431. ascent: number;
  71432. height: number;
  71433. descent: number;
  71434. };
  71435. private _color;
  71436. private _style;
  71437. private _styleObserver;
  71438. /** @hidden */
  71439. protected _horizontalAlignment: number;
  71440. /** @hidden */
  71441. protected _verticalAlignment: number;
  71442. /** @hidden */
  71443. protected _isDirty: boolean;
  71444. /** @hidden */
  71445. protected _wasDirty: boolean;
  71446. /** @hidden */
  71447. _tempParentMeasure: Measure;
  71448. /** @hidden */
  71449. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  71450. /** @hidden */
  71451. protected _cachedParentMeasure: Measure;
  71452. private _paddingLeft;
  71453. private _paddingRight;
  71454. private _paddingTop;
  71455. private _paddingBottom;
  71456. /** @hidden */
  71457. _left: ValueAndUnit;
  71458. /** @hidden */
  71459. _top: ValueAndUnit;
  71460. private _scaleX;
  71461. private _scaleY;
  71462. private _rotation;
  71463. private _transformCenterX;
  71464. private _transformCenterY;
  71465. /** @hidden */
  71466. _transformMatrix: Matrix2D;
  71467. /** @hidden */
  71468. protected _invertTransformMatrix: Matrix2D;
  71469. /** @hidden */
  71470. protected _transformedPosition: BABYLON.Vector2;
  71471. private _isMatrixDirty;
  71472. private _cachedOffsetX;
  71473. private _cachedOffsetY;
  71474. private _isVisible;
  71475. private _isHighlighted;
  71476. /** @hidden */
  71477. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  71478. private _fontSet;
  71479. private _dummyVector2;
  71480. private _downCount;
  71481. private _enterCount;
  71482. private _doNotRender;
  71483. private _downPointerIds;
  71484. protected _isEnabled: boolean;
  71485. protected _disabledColor: string;
  71486. protected _disabledColorItem: string;
  71487. /** @hidden */
  71488. protected _rebuildLayout: boolean;
  71489. /** @hidden */
  71490. _customData: any;
  71491. /** @hidden */
  71492. _isClipped: boolean;
  71493. /** @hidden */
  71494. _automaticSize: boolean;
  71495. /** @hidden */
  71496. _tag: any;
  71497. /**
  71498. * 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
  71499. */
  71500. uniqueId: number;
  71501. /**
  71502. * Gets or sets an object used to store user defined information for the node
  71503. */
  71504. metadata: any;
  71505. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  71506. isHitTestVisible: boolean;
  71507. /** Gets or sets a boolean indicating if the control can block pointer events */
  71508. isPointerBlocker: boolean;
  71509. /** Gets or sets a boolean indicating if the control can be focusable */
  71510. isFocusInvisible: boolean;
  71511. /**
  71512. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  71513. * 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
  71514. */
  71515. clipChildren: boolean;
  71516. /**
  71517. * Gets or sets a boolean indicating that control content must be clipped
  71518. * 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
  71519. */
  71520. clipContent: boolean;
  71521. /**
  71522. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  71523. */
  71524. useBitmapCache: boolean;
  71525. private _cacheData;
  71526. private _shadowOffsetX;
  71527. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  71528. get shadowOffsetX(): number;
  71529. set shadowOffsetX(value: number);
  71530. private _shadowOffsetY;
  71531. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  71532. get shadowOffsetY(): number;
  71533. set shadowOffsetY(value: number);
  71534. private _shadowBlur;
  71535. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  71536. get shadowBlur(): number;
  71537. set shadowBlur(value: number);
  71538. private _shadowColor;
  71539. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  71540. get shadowColor(): string;
  71541. set shadowColor(value: string);
  71542. /** Gets or sets the cursor to use when the control is hovered */
  71543. hoverCursor: string;
  71544. /** @hidden */
  71545. protected _linkOffsetX: ValueAndUnit;
  71546. /** @hidden */
  71547. protected _linkOffsetY: ValueAndUnit;
  71548. /** Gets the control type name */
  71549. get typeName(): string;
  71550. /**
  71551. * Get the current class name of the control.
  71552. * @returns current class name
  71553. */
  71554. getClassName(): string;
  71555. /**
  71556. * An event triggered when pointer wheel is scrolled
  71557. */
  71558. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  71559. /**
  71560. * An event triggered when the pointer move over the control.
  71561. */
  71562. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  71563. /**
  71564. * An event triggered when the pointer move out of the control.
  71565. */
  71566. onPointerOutObservable: BABYLON.Observable<Control>;
  71567. /**
  71568. * An event triggered when the pointer taps the control
  71569. */
  71570. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  71571. /**
  71572. * An event triggered when pointer up
  71573. */
  71574. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  71575. /**
  71576. * An event triggered when a control is clicked on
  71577. */
  71578. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  71579. /**
  71580. * An event triggered when pointer enters the control
  71581. */
  71582. onPointerEnterObservable: BABYLON.Observable<Control>;
  71583. /**
  71584. * An event triggered when the control is marked as dirty
  71585. */
  71586. onDirtyObservable: BABYLON.Observable<Control>;
  71587. /**
  71588. * An event triggered before drawing the control
  71589. */
  71590. onBeforeDrawObservable: BABYLON.Observable<Control>;
  71591. /**
  71592. * An event triggered after the control was drawn
  71593. */
  71594. onAfterDrawObservable: BABYLON.Observable<Control>;
  71595. /**
  71596. * Get the hosting AdvancedDynamicTexture
  71597. */
  71598. get host(): AdvancedDynamicTexture;
  71599. /** Gets or set information about font offsets (used to render and align text) */
  71600. get fontOffset(): {
  71601. ascent: number;
  71602. height: number;
  71603. descent: number;
  71604. };
  71605. set fontOffset(offset: {
  71606. ascent: number;
  71607. height: number;
  71608. descent: number;
  71609. });
  71610. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  71611. get alpha(): number;
  71612. set alpha(value: number);
  71613. /**
  71614. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  71615. */
  71616. get isHighlighted(): boolean;
  71617. set isHighlighted(value: boolean);
  71618. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  71619. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71620. */
  71621. get scaleX(): number;
  71622. set scaleX(value: number);
  71623. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  71624. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71625. */
  71626. get scaleY(): number;
  71627. set scaleY(value: number);
  71628. /** Gets or sets the rotation angle (0 by default)
  71629. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71630. */
  71631. get rotation(): number;
  71632. set rotation(value: number);
  71633. /** Gets or sets the transformation center on Y axis (0 by default)
  71634. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71635. */
  71636. get transformCenterY(): number;
  71637. set transformCenterY(value: number);
  71638. /** Gets or sets the transformation center on X axis (0 by default)
  71639. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71640. */
  71641. get transformCenterX(): number;
  71642. set transformCenterX(value: number);
  71643. /**
  71644. * Gets or sets the horizontal alignment
  71645. * @see http://doc.babylonjs.com/how_to/gui#alignments
  71646. */
  71647. get horizontalAlignment(): number;
  71648. set horizontalAlignment(value: number);
  71649. /**
  71650. * Gets or sets the vertical alignment
  71651. * @see http://doc.babylonjs.com/how_to/gui#alignments
  71652. */
  71653. get verticalAlignment(): number;
  71654. set verticalAlignment(value: number);
  71655. /**
  71656. * Gets or sets control width
  71657. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71658. */
  71659. get width(): string | number;
  71660. set width(value: string | number);
  71661. /**
  71662. * Gets or sets the control width in pixel
  71663. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71664. */
  71665. get widthInPixels(): number;
  71666. set widthInPixels(value: number);
  71667. /**
  71668. * Gets or sets control height
  71669. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71670. */
  71671. get height(): string | number;
  71672. set height(value: string | number);
  71673. /**
  71674. * Gets or sets control height in pixel
  71675. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71676. */
  71677. get heightInPixels(): number;
  71678. set heightInPixels(value: number);
  71679. /** Gets or set font family */
  71680. get fontFamily(): string;
  71681. set fontFamily(value: string);
  71682. /** Gets or sets font style */
  71683. get fontStyle(): string;
  71684. set fontStyle(value: string);
  71685. /** Gets or sets font weight */
  71686. get fontWeight(): string;
  71687. set fontWeight(value: string);
  71688. /**
  71689. * Gets or sets style
  71690. * @see http://doc.babylonjs.com/how_to/gui#styles
  71691. */
  71692. get style(): BABYLON.Nullable<Style>;
  71693. set style(value: BABYLON.Nullable<Style>);
  71694. /** @hidden */
  71695. get _isFontSizeInPercentage(): boolean;
  71696. /** Gets or sets font size in pixels */
  71697. get fontSizeInPixels(): number;
  71698. set fontSizeInPixels(value: number);
  71699. /** Gets or sets font size */
  71700. get fontSize(): string | number;
  71701. set fontSize(value: string | number);
  71702. /** Gets or sets foreground color */
  71703. get color(): string;
  71704. set color(value: string);
  71705. /** Gets or sets z index which is used to reorder controls on the z axis */
  71706. get zIndex(): number;
  71707. set zIndex(value: number);
  71708. /** Gets or sets a boolean indicating if the control can be rendered */
  71709. get notRenderable(): boolean;
  71710. set notRenderable(value: boolean);
  71711. /** Gets or sets a boolean indicating if the control is visible */
  71712. get isVisible(): boolean;
  71713. set isVisible(value: boolean);
  71714. /** Gets a boolean indicating that the control needs to update its rendering */
  71715. get isDirty(): boolean;
  71716. /**
  71717. * Gets the current linked mesh (or null if none)
  71718. */
  71719. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  71720. /**
  71721. * Gets or sets a value indicating the padding to use on the left of the control
  71722. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71723. */
  71724. get paddingLeft(): string | number;
  71725. set paddingLeft(value: string | number);
  71726. /**
  71727. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  71728. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71729. */
  71730. get paddingLeftInPixels(): number;
  71731. set paddingLeftInPixels(value: number);
  71732. /**
  71733. * Gets or sets a value indicating the padding to use on the right of the control
  71734. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71735. */
  71736. get paddingRight(): string | number;
  71737. set paddingRight(value: string | number);
  71738. /**
  71739. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  71740. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71741. */
  71742. get paddingRightInPixels(): number;
  71743. set paddingRightInPixels(value: number);
  71744. /**
  71745. * Gets or sets a value indicating the padding to use on the top of the control
  71746. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71747. */
  71748. get paddingTop(): string | number;
  71749. set paddingTop(value: string | number);
  71750. /**
  71751. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  71752. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71753. */
  71754. get paddingTopInPixels(): number;
  71755. set paddingTopInPixels(value: number);
  71756. /**
  71757. * Gets or sets a value indicating the padding to use on the bottom of the control
  71758. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71759. */
  71760. get paddingBottom(): string | number;
  71761. set paddingBottom(value: string | number);
  71762. /**
  71763. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  71764. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71765. */
  71766. get paddingBottomInPixels(): number;
  71767. set paddingBottomInPixels(value: number);
  71768. /**
  71769. * Gets or sets a value indicating the left coordinate of the control
  71770. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71771. */
  71772. get left(): string | number;
  71773. set left(value: string | number);
  71774. /**
  71775. * Gets or sets a value indicating the left coordinate in pixels of the control
  71776. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71777. */
  71778. get leftInPixels(): number;
  71779. set leftInPixels(value: number);
  71780. /**
  71781. * Gets or sets a value indicating the top coordinate of the control
  71782. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71783. */
  71784. get top(): string | number;
  71785. set top(value: string | number);
  71786. /**
  71787. * Gets or sets a value indicating the top coordinate in pixels of the control
  71788. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71789. */
  71790. get topInPixels(): number;
  71791. set topInPixels(value: number);
  71792. /**
  71793. * Gets or sets a value indicating the offset on X axis to the linked mesh
  71794. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71795. */
  71796. get linkOffsetX(): string | number;
  71797. set linkOffsetX(value: string | number);
  71798. /**
  71799. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  71800. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71801. */
  71802. get linkOffsetXInPixels(): number;
  71803. set linkOffsetXInPixels(value: number);
  71804. /**
  71805. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  71806. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71807. */
  71808. get linkOffsetY(): string | number;
  71809. set linkOffsetY(value: string | number);
  71810. /**
  71811. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  71812. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71813. */
  71814. get linkOffsetYInPixels(): number;
  71815. set linkOffsetYInPixels(value: number);
  71816. /** Gets the center coordinate on X axis */
  71817. get centerX(): number;
  71818. /** Gets the center coordinate on Y axis */
  71819. get centerY(): number;
  71820. /** Gets or sets if control is Enabled*/
  71821. get isEnabled(): boolean;
  71822. set isEnabled(value: boolean);
  71823. /** Gets or sets background color of control if it's disabled*/
  71824. get disabledColor(): string;
  71825. set disabledColor(value: string);
  71826. /** Gets or sets front color of control if it's disabled*/
  71827. get disabledColorItem(): string;
  71828. set disabledColorItem(value: string);
  71829. /**
  71830. * Creates a new control
  71831. * @param name defines the name of the control
  71832. */
  71833. constructor(
  71834. /** defines the name of the control */
  71835. name?: string | undefined);
  71836. /** @hidden */
  71837. protected _getTypeName(): string;
  71838. /**
  71839. * Gets the first ascendant in the hierarchy of the given type
  71840. * @param className defines the required type
  71841. * @returns the ascendant or null if not found
  71842. */
  71843. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  71844. /** @hidden */
  71845. _resetFontCache(): void;
  71846. /**
  71847. * Determines if a container is an ascendant of the current control
  71848. * @param container defines the container to look for
  71849. * @returns true if the container is one of the ascendant of the control
  71850. */
  71851. isAscendant(container: Control): boolean;
  71852. /**
  71853. * Gets coordinates in local control space
  71854. * @param globalCoordinates defines the coordinates to transform
  71855. * @returns the new coordinates in local space
  71856. */
  71857. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  71858. /**
  71859. * Gets coordinates in local control space
  71860. * @param globalCoordinates defines the coordinates to transform
  71861. * @param result defines the target vector2 where to store the result
  71862. * @returns the current control
  71863. */
  71864. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  71865. /**
  71866. * Gets coordinates in parent local control space
  71867. * @param globalCoordinates defines the coordinates to transform
  71868. * @returns the new coordinates in parent local space
  71869. */
  71870. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  71871. /**
  71872. * Move the current control to a vector3 position projected onto the screen.
  71873. * @param position defines the target position
  71874. * @param scene defines the hosting scene
  71875. */
  71876. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  71877. /**
  71878. * Will store all controls that have this control as ascendant in a given array
  71879. * @param results defines the array where to store the descendants
  71880. * @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
  71881. * @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
  71882. */
  71883. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  71884. /**
  71885. * Will return all controls that have this control as ascendant
  71886. * @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
  71887. * @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
  71888. * @return all child controls
  71889. */
  71890. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  71891. /**
  71892. * Link current control with a target mesh
  71893. * @param mesh defines the mesh to link with
  71894. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71895. */
  71896. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  71897. /** @hidden */
  71898. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  71899. /** @hidden */
  71900. _offsetLeft(offset: number): void;
  71901. /** @hidden */
  71902. _offsetTop(offset: number): void;
  71903. /** @hidden */
  71904. _markMatrixAsDirty(): void;
  71905. /** @hidden */
  71906. _flagDescendantsAsMatrixDirty(): void;
  71907. /** @hidden */
  71908. _intersectsRect(rect: Measure): boolean;
  71909. /** @hidden */
  71910. protected invalidateRect(): void;
  71911. /** @hidden */
  71912. _markAsDirty(force?: boolean): void;
  71913. /** @hidden */
  71914. _markAllAsDirty(): void;
  71915. /** @hidden */
  71916. _link(host: AdvancedDynamicTexture): void;
  71917. /** @hidden */
  71918. protected _transform(context?: CanvasRenderingContext2D): void;
  71919. /** @hidden */
  71920. _renderHighlight(context: CanvasRenderingContext2D): void;
  71921. /** @hidden */
  71922. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  71923. /** @hidden */
  71924. protected _applyStates(context: CanvasRenderingContext2D): void;
  71925. /** @hidden */
  71926. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  71927. /** @hidden */
  71928. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71929. protected _evaluateClippingState(parentMeasure: Measure): void;
  71930. /** @hidden */
  71931. _measure(): void;
  71932. /** @hidden */
  71933. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71934. /** @hidden */
  71935. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71936. /** @hidden */
  71937. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71938. /** @hidden */
  71939. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  71940. private static _ClipMeasure;
  71941. private _tmpMeasureA;
  71942. private _clip;
  71943. /** @hidden */
  71944. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  71945. /** @hidden */
  71946. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71947. /**
  71948. * Tests if a given coordinates belong to the current control
  71949. * @param x defines x coordinate to test
  71950. * @param y defines y coordinate to test
  71951. * @returns true if the coordinates are inside the control
  71952. */
  71953. contains(x: number, y: number): boolean;
  71954. /** @hidden */
  71955. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  71956. /** @hidden */
  71957. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  71958. /** @hidden */
  71959. _onPointerEnter(target: Control): boolean;
  71960. /** @hidden */
  71961. _onPointerOut(target: Control, force?: boolean): void;
  71962. /** @hidden */
  71963. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71964. /** @hidden */
  71965. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71966. /** @hidden */
  71967. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  71968. /** @hidden */
  71969. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  71970. /** @hidden */
  71971. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  71972. private _prepareFont;
  71973. /** Releases associated resources */
  71974. dispose(): void;
  71975. private static _HORIZONTAL_ALIGNMENT_LEFT;
  71976. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  71977. private static _HORIZONTAL_ALIGNMENT_CENTER;
  71978. private static _VERTICAL_ALIGNMENT_TOP;
  71979. private static _VERTICAL_ALIGNMENT_BOTTOM;
  71980. private static _VERTICAL_ALIGNMENT_CENTER;
  71981. /** HORIZONTAL_ALIGNMENT_LEFT */
  71982. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  71983. /** HORIZONTAL_ALIGNMENT_RIGHT */
  71984. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  71985. /** HORIZONTAL_ALIGNMENT_CENTER */
  71986. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  71987. /** VERTICAL_ALIGNMENT_TOP */
  71988. static get VERTICAL_ALIGNMENT_TOP(): number;
  71989. /** VERTICAL_ALIGNMENT_BOTTOM */
  71990. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  71991. /** VERTICAL_ALIGNMENT_CENTER */
  71992. static get VERTICAL_ALIGNMENT_CENTER(): number;
  71993. private static _FontHeightSizes;
  71994. /** @hidden */
  71995. static _GetFontOffset(font: string): {
  71996. ascent: number;
  71997. height: number;
  71998. descent: number;
  71999. };
  72000. /**
  72001. * Creates a stack panel that can be used to render headers
  72002. * @param control defines the control to associate with the header
  72003. * @param text defines the text of the header
  72004. * @param size defines the size of the header
  72005. * @param options defines options used to configure the header
  72006. * @returns a new StackPanel
  72007. * @ignore
  72008. * @hidden
  72009. */
  72010. static AddHeader: (control: Control, text: string, size: string | number, options: {
  72011. isHorizontal: boolean;
  72012. controlFirst: boolean;
  72013. }) => any;
  72014. /** @hidden */
  72015. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  72016. }
  72017. }
  72018. declare module BABYLON.GUI {
  72019. /**
  72020. * Root class for 2D containers
  72021. * @see http://doc.babylonjs.com/how_to/gui#containers
  72022. */
  72023. export class Container extends Control {
  72024. name?: string | undefined;
  72025. /** @hidden */
  72026. _children: Control[];
  72027. /** @hidden */
  72028. protected _measureForChildren: Measure;
  72029. /** @hidden */
  72030. protected _background: string;
  72031. /** @hidden */
  72032. protected _adaptWidthToChildren: boolean;
  72033. /** @hidden */
  72034. protected _adaptHeightToChildren: boolean;
  72035. /**
  72036. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  72037. */
  72038. logLayoutCycleErrors: boolean;
  72039. /**
  72040. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  72041. */
  72042. maxLayoutCycle: number;
  72043. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  72044. get adaptHeightToChildren(): boolean;
  72045. set adaptHeightToChildren(value: boolean);
  72046. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  72047. get adaptWidthToChildren(): boolean;
  72048. set adaptWidthToChildren(value: boolean);
  72049. /** Gets or sets background color */
  72050. get background(): string;
  72051. set background(value: string);
  72052. /** Gets the list of children */
  72053. get children(): Control[];
  72054. /**
  72055. * Creates a new Container
  72056. * @param name defines the name of the container
  72057. */
  72058. constructor(name?: string | undefined);
  72059. protected _getTypeName(): string;
  72060. _flagDescendantsAsMatrixDirty(): void;
  72061. /**
  72062. * Gets a child using its name
  72063. * @param name defines the child name to look for
  72064. * @returns the child control if found
  72065. */
  72066. getChildByName(name: string): BABYLON.Nullable<Control>;
  72067. /**
  72068. * Gets a child using its type and its name
  72069. * @param name defines the child name to look for
  72070. * @param type defines the child type to look for
  72071. * @returns the child control if found
  72072. */
  72073. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  72074. /**
  72075. * Search for a specific control in children
  72076. * @param control defines the control to look for
  72077. * @returns true if the control is in child list
  72078. */
  72079. containsControl(control: Control): boolean;
  72080. /**
  72081. * Adds a new control to the current container
  72082. * @param control defines the control to add
  72083. * @returns the current container
  72084. */
  72085. addControl(control: BABYLON.Nullable<Control>): Container;
  72086. /**
  72087. * Removes all controls from the current container
  72088. * @returns the current container
  72089. */
  72090. clearControls(): Container;
  72091. /**
  72092. * Removes a control from the current container
  72093. * @param control defines the control to remove
  72094. * @returns the current container
  72095. */
  72096. removeControl(control: Control): Container;
  72097. /** @hidden */
  72098. _reOrderControl(control: Control): void;
  72099. /** @hidden */
  72100. _offsetLeft(offset: number): void;
  72101. /** @hidden */
  72102. _offsetTop(offset: number): void;
  72103. /** @hidden */
  72104. _markAllAsDirty(): void;
  72105. /** @hidden */
  72106. protected _localDraw(context: CanvasRenderingContext2D): void;
  72107. /** @hidden */
  72108. _link(host: AdvancedDynamicTexture): void;
  72109. /** @hidden */
  72110. protected _beforeLayout(): void;
  72111. /** @hidden */
  72112. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72113. /** @hidden */
  72114. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  72115. protected _postMeasure(): void;
  72116. /** @hidden */
  72117. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  72118. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  72119. /** @hidden */
  72120. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72121. /** @hidden */
  72122. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72123. /** Releases associated resources */
  72124. dispose(): void;
  72125. }
  72126. }
  72127. declare module BABYLON.GUI {
  72128. /** Class used to create rectangle container */
  72129. export class Rectangle extends Container {
  72130. name?: string | undefined;
  72131. private _thickness;
  72132. private _cornerRadius;
  72133. /** Gets or sets border thickness */
  72134. get thickness(): number;
  72135. set thickness(value: number);
  72136. /** Gets or sets the corner radius angle */
  72137. get cornerRadius(): number;
  72138. set cornerRadius(value: number);
  72139. /**
  72140. * Creates a new Rectangle
  72141. * @param name defines the control name
  72142. */
  72143. constructor(name?: string | undefined);
  72144. protected _getTypeName(): string;
  72145. protected _localDraw(context: CanvasRenderingContext2D): void;
  72146. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72147. private _drawRoundedRect;
  72148. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72149. }
  72150. }
  72151. declare module BABYLON.GUI {
  72152. /**
  72153. * Enum that determines the text-wrapping mode to use.
  72154. */
  72155. export enum TextWrapping {
  72156. /**
  72157. * Clip the text when it's larger than Control.width; this is the default mode.
  72158. */
  72159. Clip = 0,
  72160. /**
  72161. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  72162. */
  72163. WordWrap = 1,
  72164. /**
  72165. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  72166. */
  72167. Ellipsis = 2
  72168. }
  72169. /**
  72170. * Class used to create text block control
  72171. */
  72172. export class TextBlock extends Control {
  72173. /**
  72174. * Defines the name of the control
  72175. */
  72176. name?: string | undefined;
  72177. private _text;
  72178. private _textWrapping;
  72179. private _textHorizontalAlignment;
  72180. private _textVerticalAlignment;
  72181. private _lines;
  72182. private _resizeToFit;
  72183. private _lineSpacing;
  72184. private _outlineWidth;
  72185. private _outlineColor;
  72186. /**
  72187. * An event triggered after the text is changed
  72188. */
  72189. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  72190. /**
  72191. * An event triggered after the text was broken up into lines
  72192. */
  72193. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  72194. /**
  72195. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  72196. */
  72197. get lines(): any[];
  72198. /**
  72199. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  72200. */
  72201. get resizeToFit(): boolean;
  72202. /**
  72203. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  72204. */
  72205. set resizeToFit(value: boolean);
  72206. /**
  72207. * Gets or sets a boolean indicating if text must be wrapped
  72208. */
  72209. get textWrapping(): TextWrapping | boolean;
  72210. /**
  72211. * Gets or sets a boolean indicating if text must be wrapped
  72212. */
  72213. set textWrapping(value: TextWrapping | boolean);
  72214. /**
  72215. * Gets or sets text to display
  72216. */
  72217. get text(): string;
  72218. /**
  72219. * Gets or sets text to display
  72220. */
  72221. set text(value: string);
  72222. /**
  72223. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  72224. */
  72225. get textHorizontalAlignment(): number;
  72226. /**
  72227. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  72228. */
  72229. set textHorizontalAlignment(value: number);
  72230. /**
  72231. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  72232. */
  72233. get textVerticalAlignment(): number;
  72234. /**
  72235. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  72236. */
  72237. set textVerticalAlignment(value: number);
  72238. /**
  72239. * Gets or sets line spacing value
  72240. */
  72241. set lineSpacing(value: string | number);
  72242. /**
  72243. * Gets or sets line spacing value
  72244. */
  72245. get lineSpacing(): string | number;
  72246. /**
  72247. * Gets or sets outlineWidth of the text to display
  72248. */
  72249. get outlineWidth(): number;
  72250. /**
  72251. * Gets or sets outlineWidth of the text to display
  72252. */
  72253. set outlineWidth(value: number);
  72254. /**
  72255. * Gets or sets outlineColor of the text to display
  72256. */
  72257. get outlineColor(): string;
  72258. /**
  72259. * Gets or sets outlineColor of the text to display
  72260. */
  72261. set outlineColor(value: string);
  72262. /**
  72263. * Creates a new TextBlock object
  72264. * @param name defines the name of the control
  72265. * @param text defines the text to display (emptry string by default)
  72266. */
  72267. constructor(
  72268. /**
  72269. * Defines the name of the control
  72270. */
  72271. name?: string | undefined, text?: string);
  72272. protected _getTypeName(): string;
  72273. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72274. private _drawText;
  72275. /** @hidden */
  72276. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72277. protected _applyStates(context: CanvasRenderingContext2D): void;
  72278. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  72279. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  72280. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  72281. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  72282. protected _renderLines(context: CanvasRenderingContext2D): void;
  72283. /**
  72284. * Given a width constraint applied on the text block, find the expected height
  72285. * @returns expected height
  72286. */
  72287. computeExpectedHeight(): number;
  72288. dispose(): void;
  72289. }
  72290. }
  72291. declare module BABYLON.GUI {
  72292. /**
  72293. * Class used to create 2D images
  72294. */
  72295. export class Image extends Control {
  72296. name?: string | undefined;
  72297. private _workingCanvas;
  72298. private _domImage;
  72299. private _imageWidth;
  72300. private _imageHeight;
  72301. private _loaded;
  72302. private _stretch;
  72303. private _source;
  72304. private _autoScale;
  72305. private _sourceLeft;
  72306. private _sourceTop;
  72307. private _sourceWidth;
  72308. private _sourceHeight;
  72309. private _svgAttributesComputationCompleted;
  72310. private _isSVG;
  72311. private _cellWidth;
  72312. private _cellHeight;
  72313. private _cellId;
  72314. private _populateNinePatchSlicesFromImage;
  72315. private _sliceLeft;
  72316. private _sliceRight;
  72317. private _sliceTop;
  72318. private _sliceBottom;
  72319. private _detectPointerOnOpaqueOnly;
  72320. /**
  72321. * BABYLON.Observable notified when the content is loaded
  72322. */
  72323. onImageLoadedObservable: BABYLON.Observable<Image>;
  72324. /**
  72325. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  72326. */
  72327. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  72328. /**
  72329. * Gets a boolean indicating that the content is loaded
  72330. */
  72331. get isLoaded(): boolean;
  72332. /**
  72333. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  72334. */
  72335. get populateNinePatchSlicesFromImage(): boolean;
  72336. set populateNinePatchSlicesFromImage(value: boolean);
  72337. /**
  72338. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  72339. * Beware using this as this will comsume more memory as the image has to be stored twice
  72340. */
  72341. get detectPointerOnOpaqueOnly(): boolean;
  72342. set detectPointerOnOpaqueOnly(value: boolean);
  72343. /**
  72344. * Gets or sets the left value for slicing (9-patch)
  72345. */
  72346. get sliceLeft(): number;
  72347. set sliceLeft(value: number);
  72348. /**
  72349. * Gets or sets the right value for slicing (9-patch)
  72350. */
  72351. get sliceRight(): number;
  72352. set sliceRight(value: number);
  72353. /**
  72354. * Gets or sets the top value for slicing (9-patch)
  72355. */
  72356. get sliceTop(): number;
  72357. set sliceTop(value: number);
  72358. /**
  72359. * Gets or sets the bottom value for slicing (9-patch)
  72360. */
  72361. get sliceBottom(): number;
  72362. set sliceBottom(value: number);
  72363. /**
  72364. * Gets or sets the left coordinate in the source image
  72365. */
  72366. get sourceLeft(): number;
  72367. set sourceLeft(value: number);
  72368. /**
  72369. * Gets or sets the top coordinate in the source image
  72370. */
  72371. get sourceTop(): number;
  72372. set sourceTop(value: number);
  72373. /**
  72374. * Gets or sets the width to capture in the source image
  72375. */
  72376. get sourceWidth(): number;
  72377. set sourceWidth(value: number);
  72378. /**
  72379. * Gets or sets the height to capture in the source image
  72380. */
  72381. get sourceHeight(): number;
  72382. set sourceHeight(value: number);
  72383. /** Indicates if the format of the image is SVG */
  72384. get isSVG(): boolean;
  72385. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  72386. get svgAttributesComputationCompleted(): boolean;
  72387. /**
  72388. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  72389. * @see http://doc.babylonjs.com/how_to/gui#image
  72390. */
  72391. get autoScale(): boolean;
  72392. set autoScale(value: boolean);
  72393. /** Gets or sets the streching mode used by the image */
  72394. get stretch(): number;
  72395. set stretch(value: number);
  72396. /** @hidden */
  72397. _rotate90(n: number, preserveProperties?: boolean): Image;
  72398. private _handleRotationForSVGImage;
  72399. private _rotate90SourceProperties;
  72400. /**
  72401. * Gets or sets the internal DOM image used to render the control
  72402. */
  72403. set domImage(value: HTMLImageElement);
  72404. get domImage(): HTMLImageElement;
  72405. private _onImageLoaded;
  72406. private _extractNinePatchSliceDataFromImage;
  72407. /**
  72408. * Gets or sets image source url
  72409. */
  72410. set source(value: BABYLON.Nullable<string>);
  72411. /**
  72412. * Checks for svg document with icon id present
  72413. */
  72414. private _svgCheck;
  72415. /**
  72416. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  72417. * given external svg file and icon id
  72418. */
  72419. private _getSVGAttribs;
  72420. /**
  72421. * Gets or sets the cell width to use when animation sheet is enabled
  72422. * @see http://doc.babylonjs.com/how_to/gui#image
  72423. */
  72424. get cellWidth(): number;
  72425. set cellWidth(value: number);
  72426. /**
  72427. * Gets or sets the cell height to use when animation sheet is enabled
  72428. * @see http://doc.babylonjs.com/how_to/gui#image
  72429. */
  72430. get cellHeight(): number;
  72431. set cellHeight(value: number);
  72432. /**
  72433. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  72434. * @see http://doc.babylonjs.com/how_to/gui#image
  72435. */
  72436. get cellId(): number;
  72437. set cellId(value: number);
  72438. /**
  72439. * Creates a new Image
  72440. * @param name defines the control name
  72441. * @param url defines the image url
  72442. */
  72443. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  72444. /**
  72445. * Tests if a given coordinates belong to the current control
  72446. * @param x defines x coordinate to test
  72447. * @param y defines y coordinate to test
  72448. * @returns true if the coordinates are inside the control
  72449. */
  72450. contains(x: number, y: number): boolean;
  72451. protected _getTypeName(): string;
  72452. /** Force the control to synchronize with its content */
  72453. synchronizeSizeWithContent(): void;
  72454. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72455. private _prepareWorkingCanvasForOpaqueDetection;
  72456. private _drawImage;
  72457. _draw(context: CanvasRenderingContext2D): void;
  72458. private _renderCornerPatch;
  72459. private _renderNinePatch;
  72460. dispose(): void;
  72461. /** STRETCH_NONE */
  72462. static readonly STRETCH_NONE: number;
  72463. /** STRETCH_FILL */
  72464. static readonly STRETCH_FILL: number;
  72465. /** STRETCH_UNIFORM */
  72466. static readonly STRETCH_UNIFORM: number;
  72467. /** STRETCH_EXTEND */
  72468. static readonly STRETCH_EXTEND: number;
  72469. /** NINE_PATCH */
  72470. static readonly STRETCH_NINE_PATCH: number;
  72471. }
  72472. }
  72473. declare module BABYLON.GUI {
  72474. /**
  72475. * Class used to create 2D buttons
  72476. */
  72477. export class Button extends Rectangle {
  72478. name?: string | undefined;
  72479. /**
  72480. * Function called to generate a pointer enter animation
  72481. */
  72482. pointerEnterAnimation: () => void;
  72483. /**
  72484. * Function called to generate a pointer out animation
  72485. */
  72486. pointerOutAnimation: () => void;
  72487. /**
  72488. * Function called to generate a pointer down animation
  72489. */
  72490. pointerDownAnimation: () => void;
  72491. /**
  72492. * Function called to generate a pointer up animation
  72493. */
  72494. pointerUpAnimation: () => void;
  72495. /**
  72496. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  72497. */
  72498. delegatePickingToChildren: boolean;
  72499. private _image;
  72500. /**
  72501. * Returns the image part of the button (if any)
  72502. */
  72503. get image(): BABYLON.Nullable<Image>;
  72504. private _textBlock;
  72505. /**
  72506. * Returns the image part of the button (if any)
  72507. */
  72508. get textBlock(): BABYLON.Nullable<TextBlock>;
  72509. /**
  72510. * Creates a new Button
  72511. * @param name defines the name of the button
  72512. */
  72513. constructor(name?: string | undefined);
  72514. protected _getTypeName(): string;
  72515. /** @hidden */
  72516. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72517. /** @hidden */
  72518. _onPointerEnter(target: Control): boolean;
  72519. /** @hidden */
  72520. _onPointerOut(target: Control, force?: boolean): void;
  72521. /** @hidden */
  72522. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72523. /** @hidden */
  72524. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72525. /**
  72526. * Creates a new button made with an image and a text
  72527. * @param name defines the name of the button
  72528. * @param text defines the text of the button
  72529. * @param imageUrl defines the url of the image
  72530. * @returns a new Button
  72531. */
  72532. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  72533. /**
  72534. * Creates a new button made with an image
  72535. * @param name defines the name of the button
  72536. * @param imageUrl defines the url of the image
  72537. * @returns a new Button
  72538. */
  72539. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  72540. /**
  72541. * Creates a new button made with a text
  72542. * @param name defines the name of the button
  72543. * @param text defines the text of the button
  72544. * @returns a new Button
  72545. */
  72546. static CreateSimpleButton(name: string, text: string): Button;
  72547. /**
  72548. * Creates a new button made with an image and a centered text
  72549. * @param name defines the name of the button
  72550. * @param text defines the text of the button
  72551. * @param imageUrl defines the url of the image
  72552. * @returns a new Button
  72553. */
  72554. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  72555. }
  72556. }
  72557. declare module BABYLON.GUI {
  72558. /**
  72559. * Class used to create a 2D stack panel container
  72560. */
  72561. export class StackPanel extends Container {
  72562. name?: string | undefined;
  72563. private _isVertical;
  72564. private _manualWidth;
  72565. private _manualHeight;
  72566. private _doNotTrackManualChanges;
  72567. /**
  72568. * Gets or sets a boolean indicating that layou warnings should be ignored
  72569. */
  72570. ignoreLayoutWarnings: boolean;
  72571. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  72572. get isVertical(): boolean;
  72573. set isVertical(value: boolean);
  72574. /**
  72575. * Gets or sets panel width.
  72576. * This value should not be set when in horizontal mode as it will be computed automatically
  72577. */
  72578. set width(value: string | number);
  72579. get width(): string | number;
  72580. /**
  72581. * Gets or sets panel height.
  72582. * This value should not be set when in vertical mode as it will be computed automatically
  72583. */
  72584. set height(value: string | number);
  72585. get height(): string | number;
  72586. /**
  72587. * Creates a new StackPanel
  72588. * @param name defines control name
  72589. */
  72590. constructor(name?: string | undefined);
  72591. protected _getTypeName(): string;
  72592. /** @hidden */
  72593. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72594. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72595. protected _postMeasure(): void;
  72596. }
  72597. }
  72598. declare module BABYLON.GUI {
  72599. /**
  72600. * Class used to represent a 2D checkbox
  72601. */
  72602. export class Checkbox extends Control {
  72603. name?: string | undefined;
  72604. private _isChecked;
  72605. private _background;
  72606. private _checkSizeRatio;
  72607. private _thickness;
  72608. /** Gets or sets border thickness */
  72609. get thickness(): number;
  72610. set thickness(value: number);
  72611. /**
  72612. * BABYLON.Observable raised when isChecked property changes
  72613. */
  72614. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  72615. /** Gets or sets a value indicating the ratio between overall size and check size */
  72616. get checkSizeRatio(): number;
  72617. set checkSizeRatio(value: number);
  72618. /** Gets or sets background color */
  72619. get background(): string;
  72620. set background(value: string);
  72621. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  72622. get isChecked(): boolean;
  72623. set isChecked(value: boolean);
  72624. /**
  72625. * Creates a new CheckBox
  72626. * @param name defines the control name
  72627. */
  72628. constructor(name?: string | undefined);
  72629. protected _getTypeName(): string;
  72630. /** @hidden */
  72631. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72632. /** @hidden */
  72633. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72634. /**
  72635. * Utility function to easily create a checkbox with a header
  72636. * @param title defines the label to use for the header
  72637. * @param onValueChanged defines the callback to call when value changes
  72638. * @returns a StackPanel containing the checkbox and a textBlock
  72639. */
  72640. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  72641. }
  72642. }
  72643. declare module BABYLON.GUI {
  72644. /**
  72645. * Class used to store key control properties
  72646. */
  72647. export class KeyPropertySet {
  72648. /** Width */
  72649. width?: string;
  72650. /** Height */
  72651. height?: string;
  72652. /** Left padding */
  72653. paddingLeft?: string;
  72654. /** Right padding */
  72655. paddingRight?: string;
  72656. /** Top padding */
  72657. paddingTop?: string;
  72658. /** Bottom padding */
  72659. paddingBottom?: string;
  72660. /** Foreground color */
  72661. color?: string;
  72662. /** Background color */
  72663. background?: string;
  72664. }
  72665. /**
  72666. * Class used to create virtual keyboard
  72667. */
  72668. export class VirtualKeyboard extends StackPanel {
  72669. /** BABYLON.Observable raised when a key is pressed */
  72670. onKeyPressObservable: BABYLON.Observable<string>;
  72671. /** Gets or sets default key button width */
  72672. defaultButtonWidth: string;
  72673. /** Gets or sets default key button height */
  72674. defaultButtonHeight: string;
  72675. /** Gets or sets default key button left padding */
  72676. defaultButtonPaddingLeft: string;
  72677. /** Gets or sets default key button right padding */
  72678. defaultButtonPaddingRight: string;
  72679. /** Gets or sets default key button top padding */
  72680. defaultButtonPaddingTop: string;
  72681. /** Gets or sets default key button bottom padding */
  72682. defaultButtonPaddingBottom: string;
  72683. /** Gets or sets default key button foreground color */
  72684. defaultButtonColor: string;
  72685. /** Gets or sets default key button background color */
  72686. defaultButtonBackground: string;
  72687. /** Gets or sets shift button foreground color */
  72688. shiftButtonColor: string;
  72689. /** Gets or sets shift button thickness*/
  72690. selectedShiftThickness: number;
  72691. /** Gets shift key state */
  72692. shiftState: number;
  72693. protected _getTypeName(): string;
  72694. private _createKey;
  72695. /**
  72696. * Adds a new row of keys
  72697. * @param keys defines the list of keys to add
  72698. * @param propertySets defines the associated property sets
  72699. */
  72700. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  72701. /**
  72702. * Set the shift key to a specific state
  72703. * @param shiftState defines the new shift state
  72704. */
  72705. applyShiftState(shiftState: number): void;
  72706. private _currentlyConnectedInputText;
  72707. private _connectedInputTexts;
  72708. private _onKeyPressObserver;
  72709. /** Gets the input text control currently attached to the keyboard */
  72710. get connectedInputText(): BABYLON.Nullable<InputText>;
  72711. /**
  72712. * Connects the keyboard with an input text control
  72713. *
  72714. * @param input defines the target control
  72715. */
  72716. connect(input: InputText): void;
  72717. /**
  72718. * Disconnects the keyboard from connected InputText controls
  72719. *
  72720. * @param input optionally defines a target control, otherwise all are disconnected
  72721. */
  72722. disconnect(input?: InputText): void;
  72723. private _removeConnectedInputObservables;
  72724. /**
  72725. * Release all resources
  72726. */
  72727. dispose(): void;
  72728. /**
  72729. * Creates a new keyboard using a default layout
  72730. *
  72731. * @param name defines control name
  72732. * @returns a new VirtualKeyboard
  72733. */
  72734. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  72735. }
  72736. }
  72737. declare module BABYLON.GUI {
  72738. /**
  72739. * Class used to create input text control
  72740. */
  72741. export class InputText extends Control implements IFocusableControl {
  72742. name?: string | undefined;
  72743. private _text;
  72744. private _placeholderText;
  72745. private _background;
  72746. private _focusedBackground;
  72747. private _focusedColor;
  72748. private _placeholderColor;
  72749. private _thickness;
  72750. private _margin;
  72751. private _autoStretchWidth;
  72752. private _maxWidth;
  72753. private _isFocused;
  72754. private _blinkTimeout;
  72755. private _blinkIsEven;
  72756. private _cursorOffset;
  72757. private _scrollLeft;
  72758. private _textWidth;
  72759. private _clickedCoordinate;
  72760. private _deadKey;
  72761. private _addKey;
  72762. private _currentKey;
  72763. private _isTextHighlightOn;
  72764. private _textHighlightColor;
  72765. private _highligherOpacity;
  72766. private _highlightedText;
  72767. private _startHighlightIndex;
  72768. private _endHighlightIndex;
  72769. private _cursorIndex;
  72770. private _onFocusSelectAll;
  72771. private _isPointerDown;
  72772. private _onClipboardObserver;
  72773. private _onPointerDblTapObserver;
  72774. /** @hidden */
  72775. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  72776. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  72777. promptMessage: string;
  72778. /** Force disable prompt on mobile device */
  72779. disableMobilePrompt: boolean;
  72780. /** BABYLON.Observable raised when the text changes */
  72781. onTextChangedObservable: BABYLON.Observable<InputText>;
  72782. /** BABYLON.Observable raised just before an entered character is to be added */
  72783. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  72784. /** BABYLON.Observable raised when the control gets the focus */
  72785. onFocusObservable: BABYLON.Observable<InputText>;
  72786. /** BABYLON.Observable raised when the control loses the focus */
  72787. onBlurObservable: BABYLON.Observable<InputText>;
  72788. /**Observable raised when the text is highlighted */
  72789. onTextHighlightObservable: BABYLON.Observable<InputText>;
  72790. /**Observable raised when copy event is triggered */
  72791. onTextCopyObservable: BABYLON.Observable<InputText>;
  72792. /** BABYLON.Observable raised when cut event is triggered */
  72793. onTextCutObservable: BABYLON.Observable<InputText>;
  72794. /** BABYLON.Observable raised when paste event is triggered */
  72795. onTextPasteObservable: BABYLON.Observable<InputText>;
  72796. /** BABYLON.Observable raised when a key event was processed */
  72797. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  72798. /** Gets or sets the maximum width allowed by the control */
  72799. get maxWidth(): string | number;
  72800. /** Gets the maximum width allowed by the control in pixels */
  72801. get maxWidthInPixels(): number;
  72802. set maxWidth(value: string | number);
  72803. /** Gets or sets the text highlighter transparency; default: 0.4 */
  72804. get highligherOpacity(): number;
  72805. set highligherOpacity(value: number);
  72806. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  72807. get onFocusSelectAll(): boolean;
  72808. set onFocusSelectAll(value: boolean);
  72809. /** Gets or sets the text hightlight color */
  72810. get textHighlightColor(): string;
  72811. set textHighlightColor(value: string);
  72812. /** Gets or sets control margin */
  72813. get margin(): string;
  72814. /** Gets control margin in pixels */
  72815. get marginInPixels(): number;
  72816. set margin(value: string);
  72817. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  72818. get autoStretchWidth(): boolean;
  72819. set autoStretchWidth(value: boolean);
  72820. /** Gets or sets border thickness */
  72821. get thickness(): number;
  72822. set thickness(value: number);
  72823. /** Gets or sets the background color when focused */
  72824. get focusedBackground(): string;
  72825. set focusedBackground(value: string);
  72826. /** Gets or sets the background color when focused */
  72827. get focusedColor(): string;
  72828. set focusedColor(value: string);
  72829. /** Gets or sets the background color */
  72830. get background(): string;
  72831. set background(value: string);
  72832. /** Gets or sets the placeholder color */
  72833. get placeholderColor(): string;
  72834. set placeholderColor(value: string);
  72835. /** Gets or sets the text displayed when the control is empty */
  72836. get placeholderText(): string;
  72837. set placeholderText(value: string);
  72838. /** Gets or sets the dead key flag */
  72839. get deadKey(): boolean;
  72840. set deadKey(flag: boolean);
  72841. /** Gets or sets the highlight text */
  72842. get highlightedText(): string;
  72843. set highlightedText(text: string);
  72844. /** Gets or sets if the current key should be added */
  72845. get addKey(): boolean;
  72846. set addKey(flag: boolean);
  72847. /** Gets or sets the value of the current key being entered */
  72848. get currentKey(): string;
  72849. set currentKey(key: string);
  72850. /** Gets or sets the text displayed in the control */
  72851. get text(): string;
  72852. set text(value: string);
  72853. /** Gets or sets control width */
  72854. get width(): string | number;
  72855. set width(value: string | number);
  72856. /**
  72857. * Creates a new InputText
  72858. * @param name defines the control name
  72859. * @param text defines the text of the control
  72860. */
  72861. constructor(name?: string | undefined, text?: string);
  72862. /** @hidden */
  72863. onBlur(): void;
  72864. /** @hidden */
  72865. onFocus(): void;
  72866. protected _getTypeName(): string;
  72867. /**
  72868. * Function called to get the list of controls that should not steal the focus from this control
  72869. * @returns an array of controls
  72870. */
  72871. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  72872. /** @hidden */
  72873. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  72874. /** @hidden */
  72875. private _updateValueFromCursorIndex;
  72876. /** @hidden */
  72877. private _processDblClick;
  72878. /** @hidden */
  72879. private _selectAllText;
  72880. /**
  72881. * Handles the keyboard event
  72882. * @param evt Defines the KeyboardEvent
  72883. */
  72884. processKeyboard(evt: KeyboardEvent): void;
  72885. /** @hidden */
  72886. private _onCopyText;
  72887. /** @hidden */
  72888. private _onCutText;
  72889. /** @hidden */
  72890. private _onPasteText;
  72891. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72892. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72893. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72894. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72895. protected _beforeRenderText(text: string): string;
  72896. dispose(): void;
  72897. }
  72898. }
  72899. declare module BABYLON.GUI {
  72900. /**
  72901. * Class used to create a 2D grid container
  72902. */
  72903. export class Grid extends Container {
  72904. name?: string | undefined;
  72905. private _rowDefinitions;
  72906. private _columnDefinitions;
  72907. private _cells;
  72908. private _childControls;
  72909. /**
  72910. * Gets the number of columns
  72911. */
  72912. get columnCount(): number;
  72913. /**
  72914. * Gets the number of rows
  72915. */
  72916. get rowCount(): number;
  72917. /** Gets the list of children */
  72918. get children(): Control[];
  72919. /** Gets the list of cells (e.g. the containers) */
  72920. get cells(): {
  72921. [key: string]: Container;
  72922. };
  72923. /**
  72924. * Gets the definition of a specific row
  72925. * @param index defines the index of the row
  72926. * @returns the row definition
  72927. */
  72928. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  72929. /**
  72930. * Gets the definition of a specific column
  72931. * @param index defines the index of the column
  72932. * @returns the column definition
  72933. */
  72934. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  72935. /**
  72936. * Adds a new row to the grid
  72937. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  72938. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  72939. * @returns the current grid
  72940. */
  72941. addRowDefinition(height: number, isPixel?: boolean): Grid;
  72942. /**
  72943. * Adds a new column to the grid
  72944. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  72945. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  72946. * @returns the current grid
  72947. */
  72948. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  72949. /**
  72950. * Update a row definition
  72951. * @param index defines the index of the row to update
  72952. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  72953. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  72954. * @returns the current grid
  72955. */
  72956. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  72957. /**
  72958. * Update a column definition
  72959. * @param index defines the index of the column to update
  72960. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  72961. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  72962. * @returns the current grid
  72963. */
  72964. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  72965. /**
  72966. * Gets the list of children stored in a specific cell
  72967. * @param row defines the row to check
  72968. * @param column defines the column to check
  72969. * @returns the list of controls
  72970. */
  72971. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  72972. /**
  72973. * Gets a string representing the child cell info (row x column)
  72974. * @param child defines the control to get info from
  72975. * @returns a string containing the child cell info (row x column)
  72976. */
  72977. getChildCellInfo(child: Control): string;
  72978. private _removeCell;
  72979. private _offsetCell;
  72980. /**
  72981. * Remove a column definition at specified index
  72982. * @param index defines the index of the column to remove
  72983. * @returns the current grid
  72984. */
  72985. removeColumnDefinition(index: number): Grid;
  72986. /**
  72987. * Remove a row definition at specified index
  72988. * @param index defines the index of the row to remove
  72989. * @returns the current grid
  72990. */
  72991. removeRowDefinition(index: number): Grid;
  72992. /**
  72993. * Adds a new control to the current grid
  72994. * @param control defines the control to add
  72995. * @param row defines the row where to add the control (0 by default)
  72996. * @param column defines the column where to add the control (0 by default)
  72997. * @returns the current grid
  72998. */
  72999. addControl(control: Control, row?: number, column?: number): Grid;
  73000. /**
  73001. * Removes a control from the current container
  73002. * @param control defines the control to remove
  73003. * @returns the current container
  73004. */
  73005. removeControl(control: Control): Container;
  73006. /**
  73007. * Creates a new Grid
  73008. * @param name defines control name
  73009. */
  73010. constructor(name?: string | undefined);
  73011. protected _getTypeName(): string;
  73012. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  73013. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73014. _flagDescendantsAsMatrixDirty(): void;
  73015. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  73016. /** Releases associated resources */
  73017. dispose(): void;
  73018. }
  73019. }
  73020. declare module BABYLON.GUI {
  73021. /** Class used to create color pickers */
  73022. export class ColorPicker extends Control {
  73023. name?: string | undefined;
  73024. private static _Epsilon;
  73025. private _colorWheelCanvas;
  73026. private _value;
  73027. private _tmpColor;
  73028. private _pointerStartedOnSquare;
  73029. private _pointerStartedOnWheel;
  73030. private _squareLeft;
  73031. private _squareTop;
  73032. private _squareSize;
  73033. private _h;
  73034. private _s;
  73035. private _v;
  73036. private _lastPointerDownID;
  73037. /**
  73038. * BABYLON.Observable raised when the value changes
  73039. */
  73040. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  73041. /** Gets or sets the color of the color picker */
  73042. get value(): BABYLON.Color3;
  73043. set value(value: BABYLON.Color3);
  73044. /**
  73045. * Gets or sets control width
  73046. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73047. */
  73048. get width(): string | number;
  73049. set width(value: string | number);
  73050. /**
  73051. * Gets or sets control height
  73052. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73053. */
  73054. get height(): string | number;
  73055. /** Gets or sets control height */
  73056. set height(value: string | number);
  73057. /** Gets or sets control size */
  73058. get size(): string | number;
  73059. set size(value: string | number);
  73060. /**
  73061. * Creates a new ColorPicker
  73062. * @param name defines the control name
  73063. */
  73064. constructor(name?: string | undefined);
  73065. protected _getTypeName(): string;
  73066. /** @hidden */
  73067. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73068. private _updateSquareProps;
  73069. private _drawGradientSquare;
  73070. private _drawCircle;
  73071. private _createColorWheelCanvas;
  73072. /** @hidden */
  73073. _draw(context: CanvasRenderingContext2D): void;
  73074. private _pointerIsDown;
  73075. private _updateValueFromPointer;
  73076. private _isPointOnSquare;
  73077. private _isPointOnWheel;
  73078. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73079. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73080. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73081. /**
  73082. * This function expands the color picker by creating a color picker dialog with manual
  73083. * color value input and the ability to save colors into an array to be used later in
  73084. * subsequent launches of the dialogue.
  73085. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  73086. * @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.
  73087. * @returns picked color as a hex string and the saved colors array as hex strings.
  73088. */
  73089. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  73090. pickerWidth?: string;
  73091. pickerHeight?: string;
  73092. headerHeight?: string;
  73093. lastColor?: string;
  73094. swatchLimit?: number;
  73095. numSwatchesPerLine?: number;
  73096. savedColors?: Array<string>;
  73097. }): Promise<{
  73098. savedColors?: string[];
  73099. pickedColor: string;
  73100. }>;
  73101. }
  73102. }
  73103. declare module BABYLON.GUI {
  73104. /** Class used to create 2D ellipse containers */
  73105. export class Ellipse extends Container {
  73106. name?: string | undefined;
  73107. private _thickness;
  73108. /** Gets or sets border thickness */
  73109. get thickness(): number;
  73110. set thickness(value: number);
  73111. /**
  73112. * Creates a new Ellipse
  73113. * @param name defines the control name
  73114. */
  73115. constructor(name?: string | undefined);
  73116. protected _getTypeName(): string;
  73117. protected _localDraw(context: CanvasRenderingContext2D): void;
  73118. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73119. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  73120. }
  73121. }
  73122. declare module BABYLON.GUI {
  73123. /**
  73124. * Class used to create a password control
  73125. */
  73126. export class InputPassword extends InputText {
  73127. protected _beforeRenderText(text: string): string;
  73128. }
  73129. }
  73130. declare module BABYLON.GUI {
  73131. /** Class used to render 2D lines */
  73132. export class Line extends Control {
  73133. name?: string | undefined;
  73134. private _lineWidth;
  73135. private _x1;
  73136. private _y1;
  73137. private _x2;
  73138. private _y2;
  73139. private _dash;
  73140. private _connectedControl;
  73141. private _connectedControlDirtyObserver;
  73142. /** Gets or sets the dash pattern */
  73143. get dash(): Array<number>;
  73144. set dash(value: Array<number>);
  73145. /** Gets or sets the control connected with the line end */
  73146. get connectedControl(): Control;
  73147. set connectedControl(value: Control);
  73148. /** Gets or sets start coordinates on X axis */
  73149. get x1(): string | number;
  73150. set x1(value: string | number);
  73151. /** Gets or sets start coordinates on Y axis */
  73152. get y1(): string | number;
  73153. set y1(value: string | number);
  73154. /** Gets or sets end coordinates on X axis */
  73155. get x2(): string | number;
  73156. set x2(value: string | number);
  73157. /** Gets or sets end coordinates on Y axis */
  73158. get y2(): string | number;
  73159. set y2(value: string | number);
  73160. /** Gets or sets line width */
  73161. get lineWidth(): number;
  73162. set lineWidth(value: number);
  73163. /** Gets or sets horizontal alignment */
  73164. set horizontalAlignment(value: number);
  73165. /** Gets or sets vertical alignment */
  73166. set verticalAlignment(value: number);
  73167. private get _effectiveX2();
  73168. private get _effectiveY2();
  73169. /**
  73170. * Creates a new Line
  73171. * @param name defines the control name
  73172. */
  73173. constructor(name?: string | undefined);
  73174. protected _getTypeName(): string;
  73175. _draw(context: CanvasRenderingContext2D): void;
  73176. _measure(): void;
  73177. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73178. /**
  73179. * Move one end of the line given 3D cartesian coordinates.
  73180. * @param position Targeted world position
  73181. * @param scene BABYLON.Scene
  73182. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  73183. */
  73184. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  73185. /**
  73186. * Move one end of the line to a position in screen absolute space.
  73187. * @param projectedPosition Position in screen absolute space (X, Y)
  73188. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  73189. */
  73190. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  73191. }
  73192. }
  73193. declare module BABYLON.GUI {
  73194. /**
  73195. * Class used to store a point for a MultiLine object.
  73196. * The point can be pure 2D coordinates, a mesh or a control
  73197. */
  73198. export class MultiLinePoint {
  73199. private _multiLine;
  73200. private _x;
  73201. private _y;
  73202. private _control;
  73203. private _mesh;
  73204. private _controlObserver;
  73205. private _meshObserver;
  73206. /** @hidden */
  73207. _point: BABYLON.Vector2;
  73208. /**
  73209. * Creates a new MultiLinePoint
  73210. * @param multiLine defines the source MultiLine object
  73211. */
  73212. constructor(multiLine: MultiLine);
  73213. /** Gets or sets x coordinate */
  73214. get x(): string | number;
  73215. set x(value: string | number);
  73216. /** Gets or sets y coordinate */
  73217. get y(): string | number;
  73218. set y(value: string | number);
  73219. /** Gets or sets the control associated with this point */
  73220. get control(): BABYLON.Nullable<Control>;
  73221. set control(value: BABYLON.Nullable<Control>);
  73222. /** Gets or sets the mesh associated with this point */
  73223. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  73224. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  73225. /** Resets links */
  73226. resetLinks(): void;
  73227. /**
  73228. * Gets a translation vector
  73229. * @returns the translation vector
  73230. */
  73231. translate(): BABYLON.Vector2;
  73232. private _translatePoint;
  73233. /** Release associated resources */
  73234. dispose(): void;
  73235. }
  73236. }
  73237. declare module BABYLON.GUI {
  73238. /**
  73239. * Class used to create multi line control
  73240. */
  73241. export class MultiLine extends Control {
  73242. name?: string | undefined;
  73243. private _lineWidth;
  73244. private _dash;
  73245. private _points;
  73246. private _minX;
  73247. private _minY;
  73248. private _maxX;
  73249. private _maxY;
  73250. /**
  73251. * Creates a new MultiLine
  73252. * @param name defines the control name
  73253. */
  73254. constructor(name?: string | undefined);
  73255. /** Gets or sets dash pattern */
  73256. get dash(): Array<number>;
  73257. set dash(value: Array<number>);
  73258. /**
  73259. * Gets point stored at specified index
  73260. * @param index defines the index to look for
  73261. * @returns the requested point if found
  73262. */
  73263. getAt(index: number): MultiLinePoint;
  73264. /** Function called when a point is updated */
  73265. onPointUpdate: () => void;
  73266. /**
  73267. * Adds new points to the point collection
  73268. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  73269. * @returns the list of created MultiLinePoint
  73270. */
  73271. add(...items: (AbstractMesh | Control | {
  73272. x: string | number;
  73273. y: string | number;
  73274. })[]): MultiLinePoint[];
  73275. /**
  73276. * Adds a new point to the point collection
  73277. * @param item defines the item (mesh, control or 2d coordiantes) to add
  73278. * @returns the created MultiLinePoint
  73279. */
  73280. push(item?: (AbstractMesh | Control | {
  73281. x: string | number;
  73282. y: string | number;
  73283. })): MultiLinePoint;
  73284. /**
  73285. * Remove a specific value or point from the active point collection
  73286. * @param value defines the value or point to remove
  73287. */
  73288. remove(value: number | MultiLinePoint): void;
  73289. /**
  73290. * Resets this object to initial state (no point)
  73291. */
  73292. reset(): void;
  73293. /**
  73294. * Resets all links
  73295. */
  73296. resetLinks(): void;
  73297. /** Gets or sets line width */
  73298. get lineWidth(): number;
  73299. set lineWidth(value: number);
  73300. set horizontalAlignment(value: number);
  73301. set verticalAlignment(value: number);
  73302. protected _getTypeName(): string;
  73303. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73304. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73305. _measure(): void;
  73306. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73307. dispose(): void;
  73308. }
  73309. }
  73310. declare module BABYLON.GUI {
  73311. /**
  73312. * Class used to create radio button controls
  73313. */
  73314. export class RadioButton extends Control {
  73315. name?: string | undefined;
  73316. private _isChecked;
  73317. private _background;
  73318. private _checkSizeRatio;
  73319. private _thickness;
  73320. /** Gets or sets border thickness */
  73321. get thickness(): number;
  73322. set thickness(value: number);
  73323. /** Gets or sets group name */
  73324. group: string;
  73325. /** BABYLON.Observable raised when isChecked is changed */
  73326. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  73327. /** Gets or sets a value indicating the ratio between overall size and check size */
  73328. get checkSizeRatio(): number;
  73329. set checkSizeRatio(value: number);
  73330. /** Gets or sets background color */
  73331. get background(): string;
  73332. set background(value: string);
  73333. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  73334. get isChecked(): boolean;
  73335. set isChecked(value: boolean);
  73336. /**
  73337. * Creates a new RadioButton
  73338. * @param name defines the control name
  73339. */
  73340. constructor(name?: string | undefined);
  73341. protected _getTypeName(): string;
  73342. _draw(context: CanvasRenderingContext2D): void;
  73343. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73344. /**
  73345. * Utility function to easily create a radio button with a header
  73346. * @param title defines the label to use for the header
  73347. * @param group defines the group to use for the radio button
  73348. * @param isChecked defines the initial state of the radio button
  73349. * @param onValueChanged defines the callback to call when value changes
  73350. * @returns a StackPanel containing the radio button and a textBlock
  73351. */
  73352. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  73353. }
  73354. }
  73355. declare module BABYLON.GUI {
  73356. /**
  73357. * Class used to create slider controls
  73358. */
  73359. export class BaseSlider extends Control {
  73360. name?: string | undefined;
  73361. protected _thumbWidth: ValueAndUnit;
  73362. private _minimum;
  73363. private _maximum;
  73364. private _value;
  73365. private _isVertical;
  73366. protected _barOffset: ValueAndUnit;
  73367. private _isThumbClamped;
  73368. protected _displayThumb: boolean;
  73369. private _step;
  73370. private _lastPointerDownID;
  73371. protected _effectiveBarOffset: number;
  73372. protected _renderLeft: number;
  73373. protected _renderTop: number;
  73374. protected _renderWidth: number;
  73375. protected _renderHeight: number;
  73376. protected _backgroundBoxLength: number;
  73377. protected _backgroundBoxThickness: number;
  73378. protected _effectiveThumbThickness: number;
  73379. /** BABYLON.Observable raised when the sldier value changes */
  73380. onValueChangedObservable: BABYLON.Observable<number>;
  73381. /** Gets or sets a boolean indicating if the thumb must be rendered */
  73382. get displayThumb(): boolean;
  73383. set displayThumb(value: boolean);
  73384. /** Gets or sets a step to apply to values (0 by default) */
  73385. get step(): number;
  73386. set step(value: number);
  73387. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  73388. get barOffset(): string | number;
  73389. /** Gets main bar offset in pixels*/
  73390. get barOffsetInPixels(): number;
  73391. set barOffset(value: string | number);
  73392. /** Gets or sets thumb width */
  73393. get thumbWidth(): string | number;
  73394. /** Gets thumb width in pixels */
  73395. get thumbWidthInPixels(): number;
  73396. set thumbWidth(value: string | number);
  73397. /** Gets or sets minimum value */
  73398. get minimum(): number;
  73399. set minimum(value: number);
  73400. /** Gets or sets maximum value */
  73401. get maximum(): number;
  73402. set maximum(value: number);
  73403. /** Gets or sets current value */
  73404. get value(): number;
  73405. set value(value: number);
  73406. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  73407. get isVertical(): boolean;
  73408. set isVertical(value: boolean);
  73409. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  73410. get isThumbClamped(): boolean;
  73411. set isThumbClamped(value: boolean);
  73412. /**
  73413. * Creates a new BaseSlider
  73414. * @param name defines the control name
  73415. */
  73416. constructor(name?: string | undefined);
  73417. protected _getTypeName(): string;
  73418. protected _getThumbPosition(): number;
  73419. protected _getThumbThickness(type: string): number;
  73420. protected _prepareRenderingData(type: string): void;
  73421. private _pointerIsDown;
  73422. /** @hidden */
  73423. protected _updateValueFromPointer(x: number, y: number): void;
  73424. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73425. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73426. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73427. }
  73428. }
  73429. declare module BABYLON.GUI {
  73430. /**
  73431. * Class used to create slider controls
  73432. */
  73433. export class Slider extends BaseSlider {
  73434. name?: string | undefined;
  73435. private _background;
  73436. private _borderColor;
  73437. private _isThumbCircle;
  73438. protected _displayValueBar: boolean;
  73439. /** Gets or sets a boolean indicating if the value bar must be rendered */
  73440. get displayValueBar(): boolean;
  73441. set displayValueBar(value: boolean);
  73442. /** Gets or sets border color */
  73443. get borderColor(): string;
  73444. set borderColor(value: string);
  73445. /** Gets or sets background color */
  73446. get background(): string;
  73447. set background(value: string);
  73448. /** Gets or sets a boolean indicating if the thumb should be round or square */
  73449. get isThumbCircle(): boolean;
  73450. set isThumbCircle(value: boolean);
  73451. /**
  73452. * Creates a new Slider
  73453. * @param name defines the control name
  73454. */
  73455. constructor(name?: string | undefined);
  73456. protected _getTypeName(): string;
  73457. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73458. }
  73459. }
  73460. declare module BABYLON.GUI {
  73461. /** Class used to create a RadioGroup
  73462. * which contains groups of radio buttons
  73463. */
  73464. export class SelectorGroup {
  73465. /** name of SelectorGroup */
  73466. name: string;
  73467. private _groupPanel;
  73468. private _selectors;
  73469. private _groupHeader;
  73470. /**
  73471. * Creates a new SelectorGroup
  73472. * @param name of group, used as a group heading
  73473. */
  73474. constructor(
  73475. /** name of SelectorGroup */
  73476. name: string);
  73477. /** Gets the groupPanel of the SelectorGroup */
  73478. get groupPanel(): StackPanel;
  73479. /** Gets the selectors array */
  73480. get selectors(): StackPanel[];
  73481. /** Gets and sets the group header */
  73482. get header(): string;
  73483. set header(label: string);
  73484. /** @hidden */
  73485. private _addGroupHeader;
  73486. /** @hidden*/
  73487. _getSelector(selectorNb: number): StackPanel | undefined;
  73488. /** Removes the selector at the given position
  73489. * @param selectorNb the position of the selector within the group
  73490. */
  73491. removeSelector(selectorNb: number): void;
  73492. }
  73493. /** Class used to create a CheckboxGroup
  73494. * which contains groups of checkbox buttons
  73495. */
  73496. export class CheckboxGroup extends SelectorGroup {
  73497. /** Adds a checkbox as a control
  73498. * @param text is the label for the selector
  73499. * @param func is the function called when the Selector is checked
  73500. * @param checked is true when Selector is checked
  73501. */
  73502. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  73503. /** @hidden */
  73504. _setSelectorLabel(selectorNb: number, label: string): void;
  73505. /** @hidden */
  73506. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73507. /** @hidden */
  73508. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73509. /** @hidden */
  73510. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73511. }
  73512. /** Class used to create a RadioGroup
  73513. * which contains groups of radio buttons
  73514. */
  73515. export class RadioGroup extends SelectorGroup {
  73516. private _selectNb;
  73517. /** Adds a radio button as a control
  73518. * @param label is the label for the selector
  73519. * @param func is the function called when the Selector is checked
  73520. * @param checked is true when Selector is checked
  73521. */
  73522. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  73523. /** @hidden */
  73524. _setSelectorLabel(selectorNb: number, label: string): void;
  73525. /** @hidden */
  73526. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73527. /** @hidden */
  73528. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73529. /** @hidden */
  73530. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73531. }
  73532. /** Class used to create a SliderGroup
  73533. * which contains groups of slider buttons
  73534. */
  73535. export class SliderGroup extends SelectorGroup {
  73536. /**
  73537. * Adds a slider to the SelectorGroup
  73538. * @param label is the label for the SliderBar
  73539. * @param func is the function called when the Slider moves
  73540. * @param unit is a string describing the units used, eg degrees or metres
  73541. * @param min is the minimum value for the Slider
  73542. * @param max is the maximum value for the Slider
  73543. * @param value is the start value for the Slider between min and max
  73544. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  73545. */
  73546. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  73547. /** @hidden */
  73548. _setSelectorLabel(selectorNb: number, label: string): void;
  73549. /** @hidden */
  73550. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73551. /** @hidden */
  73552. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73553. /** @hidden */
  73554. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73555. }
  73556. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  73557. * @see http://doc.babylonjs.com/how_to/selector
  73558. */
  73559. export class SelectionPanel extends Rectangle {
  73560. /** name of SelectionPanel */
  73561. name: string;
  73562. /** an array of SelectionGroups */
  73563. groups: SelectorGroup[];
  73564. private _panel;
  73565. private _buttonColor;
  73566. private _buttonBackground;
  73567. private _headerColor;
  73568. private _barColor;
  73569. private _barHeight;
  73570. private _spacerHeight;
  73571. private _labelColor;
  73572. private _groups;
  73573. private _bars;
  73574. /**
  73575. * Creates a new SelectionPanel
  73576. * @param name of SelectionPanel
  73577. * @param groups is an array of SelectionGroups
  73578. */
  73579. constructor(
  73580. /** name of SelectionPanel */
  73581. name: string,
  73582. /** an array of SelectionGroups */
  73583. groups?: SelectorGroup[]);
  73584. protected _getTypeName(): string;
  73585. /** Gets or sets the headerColor */
  73586. get headerColor(): string;
  73587. set headerColor(color: string);
  73588. private _setHeaderColor;
  73589. /** Gets or sets the button color */
  73590. get buttonColor(): string;
  73591. set buttonColor(color: string);
  73592. private _setbuttonColor;
  73593. /** Gets or sets the label color */
  73594. get labelColor(): string;
  73595. set labelColor(color: string);
  73596. private _setLabelColor;
  73597. /** Gets or sets the button background */
  73598. get buttonBackground(): string;
  73599. set buttonBackground(color: string);
  73600. private _setButtonBackground;
  73601. /** Gets or sets the color of separator bar */
  73602. get barColor(): string;
  73603. set barColor(color: string);
  73604. private _setBarColor;
  73605. /** Gets or sets the height of separator bar */
  73606. get barHeight(): string;
  73607. set barHeight(value: string);
  73608. private _setBarHeight;
  73609. /** Gets or sets the height of spacers*/
  73610. get spacerHeight(): string;
  73611. set spacerHeight(value: string);
  73612. private _setSpacerHeight;
  73613. /** Adds a bar between groups */
  73614. private _addSpacer;
  73615. /** Add a group to the selection panel
  73616. * @param group is the selector group to add
  73617. */
  73618. addGroup(group: SelectorGroup): void;
  73619. /** Remove the group from the given position
  73620. * @param groupNb is the position of the group in the list
  73621. */
  73622. removeGroup(groupNb: number): void;
  73623. /** Change a group header label
  73624. * @param label is the new group header label
  73625. * @param groupNb is the number of the group to relabel
  73626. * */
  73627. setHeaderName(label: string, groupNb: number): void;
  73628. /** Change selector label to the one given
  73629. * @param label is the new selector label
  73630. * @param groupNb is the number of the groupcontaining the selector
  73631. * @param selectorNb is the number of the selector within a group to relabel
  73632. * */
  73633. relabel(label: string, groupNb: number, selectorNb: number): void;
  73634. /** For a given group position remove the selector at the given position
  73635. * @param groupNb is the number of the group to remove the selector from
  73636. * @param selectorNb is the number of the selector within the group
  73637. */
  73638. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  73639. /** For a given group position of correct type add a checkbox button
  73640. * @param groupNb is the number of the group to remove the selector from
  73641. * @param label is the label for the selector
  73642. * @param func is the function called when the Selector is checked
  73643. * @param checked is true when Selector is checked
  73644. */
  73645. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  73646. /** For a given group position of correct type add a radio button
  73647. * @param groupNb is the number of the group to remove the selector from
  73648. * @param label is the label for the selector
  73649. * @param func is the function called when the Selector is checked
  73650. * @param checked is true when Selector is checked
  73651. */
  73652. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  73653. /**
  73654. * For a given slider group add a slider
  73655. * @param groupNb is the number of the group to add the slider to
  73656. * @param label is the label for the Slider
  73657. * @param func is the function called when the Slider moves
  73658. * @param unit is a string describing the units used, eg degrees or metres
  73659. * @param min is the minimum value for the Slider
  73660. * @param max is the maximum value for the Slider
  73661. * @param value is the start value for the Slider between min and max
  73662. * @param onVal is the function used to format the value displayed, eg radians to degrees
  73663. */
  73664. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  73665. }
  73666. }
  73667. declare module BABYLON.GUI {
  73668. /**
  73669. * Class used to hold a the container for ScrollViewer
  73670. * @hidden
  73671. */
  73672. export class _ScrollViewerWindow extends Container {
  73673. parentClientWidth: number;
  73674. parentClientHeight: number;
  73675. private _freezeControls;
  73676. private _parentMeasure;
  73677. private _oldLeft;
  73678. private _oldTop;
  73679. get freezeControls(): boolean;
  73680. set freezeControls(value: boolean);
  73681. private _bucketWidth;
  73682. private _bucketHeight;
  73683. private _buckets;
  73684. private _bucketLen;
  73685. get bucketWidth(): number;
  73686. get bucketHeight(): number;
  73687. setBucketSizes(width: number, height: number): void;
  73688. private _useBuckets;
  73689. private _makeBuckets;
  73690. private _dispatchInBuckets;
  73691. private _updateMeasures;
  73692. private _updateChildrenMeasures;
  73693. private _restoreMeasures;
  73694. /**
  73695. * Creates a new ScrollViewerWindow
  73696. * @param name of ScrollViewerWindow
  73697. */
  73698. constructor(name?: string);
  73699. protected _getTypeName(): string;
  73700. /** @hidden */
  73701. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73702. /** @hidden */
  73703. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  73704. private _scrollChildren;
  73705. private _scrollChildrenWithBuckets;
  73706. /** @hidden */
  73707. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  73708. protected _postMeasure(): void;
  73709. }
  73710. }
  73711. declare module BABYLON.GUI {
  73712. /**
  73713. * Class used to create slider controls
  73714. */
  73715. export class ScrollBar extends BaseSlider {
  73716. name?: string | undefined;
  73717. private _background;
  73718. private _borderColor;
  73719. private _tempMeasure;
  73720. /** Gets or sets border color */
  73721. get borderColor(): string;
  73722. set borderColor(value: string);
  73723. /** Gets or sets background color */
  73724. get background(): string;
  73725. set background(value: string);
  73726. /**
  73727. * Creates a new Slider
  73728. * @param name defines the control name
  73729. */
  73730. constructor(name?: string | undefined);
  73731. protected _getTypeName(): string;
  73732. protected _getThumbThickness(): number;
  73733. _draw(context: CanvasRenderingContext2D): void;
  73734. private _first;
  73735. private _originX;
  73736. private _originY;
  73737. /** @hidden */
  73738. protected _updateValueFromPointer(x: number, y: number): void;
  73739. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73740. }
  73741. }
  73742. declare module BABYLON.GUI {
  73743. /**
  73744. * Class used to create slider controls
  73745. */
  73746. export class ImageScrollBar extends BaseSlider {
  73747. name?: string | undefined;
  73748. private _backgroundBaseImage;
  73749. private _backgroundImage;
  73750. private _thumbImage;
  73751. private _thumbBaseImage;
  73752. private _thumbLength;
  73753. private _thumbHeight;
  73754. private _barImageHeight;
  73755. private _tempMeasure;
  73756. /** Number of 90° rotation to apply on the images when in vertical mode */
  73757. num90RotationInVerticalMode: number;
  73758. /**
  73759. * Gets or sets the image used to render the background for horizontal bar
  73760. */
  73761. get backgroundImage(): Image;
  73762. set backgroundImage(value: Image);
  73763. /**
  73764. * Gets or sets the image used to render the thumb
  73765. */
  73766. get thumbImage(): Image;
  73767. set thumbImage(value: Image);
  73768. /**
  73769. * Gets or sets the length of the thumb
  73770. */
  73771. get thumbLength(): number;
  73772. set thumbLength(value: number);
  73773. /**
  73774. * Gets or sets the height of the thumb
  73775. */
  73776. get thumbHeight(): number;
  73777. set thumbHeight(value: number);
  73778. /**
  73779. * Gets or sets the height of the bar image
  73780. */
  73781. get barImageHeight(): number;
  73782. set barImageHeight(value: number);
  73783. /**
  73784. * Creates a new ImageScrollBar
  73785. * @param name defines the control name
  73786. */
  73787. constructor(name?: string | undefined);
  73788. protected _getTypeName(): string;
  73789. protected _getThumbThickness(): number;
  73790. _draw(context: CanvasRenderingContext2D): void;
  73791. private _first;
  73792. private _originX;
  73793. private _originY;
  73794. /** @hidden */
  73795. protected _updateValueFromPointer(x: number, y: number): void;
  73796. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73797. }
  73798. }
  73799. declare module BABYLON.GUI {
  73800. /**
  73801. * Class used to hold a viewer window and sliders in a grid
  73802. */
  73803. export class ScrollViewer extends Rectangle {
  73804. private _grid;
  73805. private _horizontalBarSpace;
  73806. private _verticalBarSpace;
  73807. private _dragSpace;
  73808. private _horizontalBar;
  73809. private _verticalBar;
  73810. private _barColor;
  73811. private _barBackground;
  73812. private _barImage;
  73813. private _horizontalBarImage;
  73814. private _verticalBarImage;
  73815. private _barBackgroundImage;
  73816. private _horizontalBarBackgroundImage;
  73817. private _verticalBarBackgroundImage;
  73818. private _barSize;
  73819. private _window;
  73820. private _pointerIsOver;
  73821. private _wheelPrecision;
  73822. private _onWheelObserver;
  73823. private _clientWidth;
  73824. private _clientHeight;
  73825. private _useImageBar;
  73826. private _thumbLength;
  73827. private _thumbHeight;
  73828. private _barImageHeight;
  73829. private _horizontalBarImageHeight;
  73830. private _verticalBarImageHeight;
  73831. /**
  73832. * Gets the horizontal scrollbar
  73833. */
  73834. get horizontalBar(): ScrollBar | ImageScrollBar;
  73835. /**
  73836. * Gets the vertical scrollbar
  73837. */
  73838. get verticalBar(): ScrollBar | ImageScrollBar;
  73839. /**
  73840. * Adds a new control to the current container
  73841. * @param control defines the control to add
  73842. * @returns the current container
  73843. */
  73844. addControl(control: BABYLON.Nullable<Control>): Container;
  73845. /**
  73846. * Removes a control from the current container
  73847. * @param control defines the control to remove
  73848. * @returns the current container
  73849. */
  73850. removeControl(control: Control): Container;
  73851. /** Gets the list of children */
  73852. get children(): Control[];
  73853. _flagDescendantsAsMatrixDirty(): void;
  73854. /**
  73855. * Freezes or unfreezes the controls in the window.
  73856. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  73857. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  73858. */
  73859. get freezeControls(): boolean;
  73860. set freezeControls(value: boolean);
  73861. /** Gets the bucket width */
  73862. get bucketWidth(): number;
  73863. /** Gets the bucket height */
  73864. get bucketHeight(): number;
  73865. /**
  73866. * Sets the bucket sizes.
  73867. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  73868. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  73869. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  73870. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  73871. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  73872. * used), that's why it is not enabled by default.
  73873. * @param width width of the bucket
  73874. * @param height height of the bucket
  73875. */
  73876. setBucketSizes(width: number, height: number): void;
  73877. private _forceHorizontalBar;
  73878. private _forceVerticalBar;
  73879. /**
  73880. * Forces the horizontal scroll bar to be displayed
  73881. */
  73882. get forceHorizontalBar(): boolean;
  73883. set forceHorizontalBar(value: boolean);
  73884. /**
  73885. * Forces the vertical scroll bar to be displayed
  73886. */
  73887. get forceVerticalBar(): boolean;
  73888. set forceVerticalBar(value: boolean);
  73889. /**
  73890. * Creates a new ScrollViewer
  73891. * @param name of ScrollViewer
  73892. */
  73893. constructor(name?: string, isImageBased?: boolean);
  73894. /** Reset the scroll viewer window to initial size */
  73895. resetWindow(): void;
  73896. protected _getTypeName(): string;
  73897. private _buildClientSizes;
  73898. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73899. protected _postMeasure(): void;
  73900. /**
  73901. * Gets or sets the mouse wheel precision
  73902. * from 0 to 1 with a default value of 0.05
  73903. * */
  73904. get wheelPrecision(): number;
  73905. set wheelPrecision(value: number);
  73906. /** Gets or sets the scroll bar container background color */
  73907. get scrollBackground(): string;
  73908. set scrollBackground(color: string);
  73909. /** Gets or sets the bar color */
  73910. get barColor(): string;
  73911. set barColor(color: string);
  73912. /** Gets or sets the bar image */
  73913. get thumbImage(): Image;
  73914. set thumbImage(value: Image);
  73915. /** Gets or sets the horizontal bar image */
  73916. get horizontalThumbImage(): Image;
  73917. set horizontalThumbImage(value: Image);
  73918. /** Gets or sets the vertical bar image */
  73919. get verticalThumbImage(): Image;
  73920. set verticalThumbImage(value: Image);
  73921. /** Gets or sets the size of the bar */
  73922. get barSize(): number;
  73923. set barSize(value: number);
  73924. /** Gets or sets the length of the thumb */
  73925. get thumbLength(): number;
  73926. set thumbLength(value: number);
  73927. /** Gets or sets the height of the thumb */
  73928. get thumbHeight(): number;
  73929. set thumbHeight(value: number);
  73930. /** Gets or sets the height of the bar image */
  73931. get barImageHeight(): number;
  73932. set barImageHeight(value: number);
  73933. /** Gets or sets the height of the horizontal bar image */
  73934. get horizontalBarImageHeight(): number;
  73935. set horizontalBarImageHeight(value: number);
  73936. /** Gets or sets the height of the vertical bar image */
  73937. get verticalBarImageHeight(): number;
  73938. set verticalBarImageHeight(value: number);
  73939. /** Gets or sets the bar background */
  73940. get barBackground(): string;
  73941. set barBackground(color: string);
  73942. /** Gets or sets the bar background image */
  73943. get barImage(): Image;
  73944. set barImage(value: Image);
  73945. /** Gets or sets the horizontal bar background image */
  73946. get horizontalBarImage(): Image;
  73947. set horizontalBarImage(value: Image);
  73948. /** Gets or sets the vertical bar background image */
  73949. get verticalBarImage(): Image;
  73950. set verticalBarImage(value: Image);
  73951. private _setWindowPosition;
  73952. /** @hidden */
  73953. private _updateScroller;
  73954. _link(host: AdvancedDynamicTexture): void;
  73955. /** @hidden */
  73956. private _addBar;
  73957. /** @hidden */
  73958. private _attachWheel;
  73959. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  73960. /** Releases associated resources */
  73961. dispose(): void;
  73962. }
  73963. }
  73964. declare module BABYLON.GUI {
  73965. /** Class used to render a grid */
  73966. export class DisplayGrid extends Control {
  73967. name?: string | undefined;
  73968. private _cellWidth;
  73969. private _cellHeight;
  73970. private _minorLineTickness;
  73971. private _minorLineColor;
  73972. private _majorLineTickness;
  73973. private _majorLineColor;
  73974. private _majorLineFrequency;
  73975. private _background;
  73976. private _displayMajorLines;
  73977. private _displayMinorLines;
  73978. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  73979. get displayMinorLines(): boolean;
  73980. set displayMinorLines(value: boolean);
  73981. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  73982. get displayMajorLines(): boolean;
  73983. set displayMajorLines(value: boolean);
  73984. /** Gets or sets background color (Black by default) */
  73985. get background(): string;
  73986. set background(value: string);
  73987. /** Gets or sets the width of each cell (20 by default) */
  73988. get cellWidth(): number;
  73989. set cellWidth(value: number);
  73990. /** Gets or sets the height of each cell (20 by default) */
  73991. get cellHeight(): number;
  73992. set cellHeight(value: number);
  73993. /** Gets or sets the tickness of minor lines (1 by default) */
  73994. get minorLineTickness(): number;
  73995. set minorLineTickness(value: number);
  73996. /** Gets or sets the color of minor lines (DarkGray by default) */
  73997. get minorLineColor(): string;
  73998. set minorLineColor(value: string);
  73999. /** Gets or sets the tickness of major lines (2 by default) */
  74000. get majorLineTickness(): number;
  74001. set majorLineTickness(value: number);
  74002. /** Gets or sets the color of major lines (White by default) */
  74003. get majorLineColor(): string;
  74004. set majorLineColor(value: string);
  74005. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  74006. get majorLineFrequency(): number;
  74007. set majorLineFrequency(value: number);
  74008. /**
  74009. * Creates a new GridDisplayRectangle
  74010. * @param name defines the control name
  74011. */
  74012. constructor(name?: string | undefined);
  74013. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74014. protected _getTypeName(): string;
  74015. }
  74016. }
  74017. declare module BABYLON.GUI {
  74018. /**
  74019. * Class used to create slider controls based on images
  74020. */
  74021. export class ImageBasedSlider extends BaseSlider {
  74022. name?: string | undefined;
  74023. private _backgroundImage;
  74024. private _thumbImage;
  74025. private _valueBarImage;
  74026. private _tempMeasure;
  74027. get displayThumb(): boolean;
  74028. set displayThumb(value: boolean);
  74029. /**
  74030. * Gets or sets the image used to render the background
  74031. */
  74032. get backgroundImage(): Image;
  74033. set backgroundImage(value: Image);
  74034. /**
  74035. * Gets or sets the image used to render the value bar
  74036. */
  74037. get valueBarImage(): Image;
  74038. set valueBarImage(value: Image);
  74039. /**
  74040. * Gets or sets the image used to render the thumb
  74041. */
  74042. get thumbImage(): Image;
  74043. set thumbImage(value: Image);
  74044. /**
  74045. * Creates a new ImageBasedSlider
  74046. * @param name defines the control name
  74047. */
  74048. constructor(name?: string | undefined);
  74049. protected _getTypeName(): string;
  74050. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74051. }
  74052. }
  74053. declare module BABYLON.GUI {
  74054. /**
  74055. * Forcing an export so that this code will execute
  74056. * @hidden
  74057. */
  74058. const name = "Statics";
  74059. }
  74060. declare module BABYLON.GUI {
  74061. /**
  74062. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  74063. */
  74064. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  74065. /**
  74066. * Define the instrumented AdvancedDynamicTexture.
  74067. */
  74068. texture: AdvancedDynamicTexture;
  74069. private _captureRenderTime;
  74070. private _renderTime;
  74071. private _captureLayoutTime;
  74072. private _layoutTime;
  74073. private _onBeginRenderObserver;
  74074. private _onEndRenderObserver;
  74075. private _onBeginLayoutObserver;
  74076. private _onEndLayoutObserver;
  74077. /**
  74078. * Gets the perf counter used to capture render time
  74079. */
  74080. get renderTimeCounter(): BABYLON.PerfCounter;
  74081. /**
  74082. * Gets the perf counter used to capture layout time
  74083. */
  74084. get layoutTimeCounter(): BABYLON.PerfCounter;
  74085. /**
  74086. * Enable or disable the render time capture
  74087. */
  74088. get captureRenderTime(): boolean;
  74089. set captureRenderTime(value: boolean);
  74090. /**
  74091. * Enable or disable the layout time capture
  74092. */
  74093. get captureLayoutTime(): boolean;
  74094. set captureLayoutTime(value: boolean);
  74095. /**
  74096. * Instantiates a new advanced dynamic texture instrumentation.
  74097. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  74098. * @param texture Defines the AdvancedDynamicTexture to instrument
  74099. */
  74100. constructor(
  74101. /**
  74102. * Define the instrumented AdvancedDynamicTexture.
  74103. */
  74104. texture: AdvancedDynamicTexture);
  74105. /**
  74106. * Dispose and release associated resources.
  74107. */
  74108. dispose(): void;
  74109. }
  74110. }
  74111. declare module BABYLON.GUI {
  74112. /**
  74113. * Class used to load GUI via XML.
  74114. */
  74115. export class XmlLoader {
  74116. private _nodes;
  74117. private _nodeTypes;
  74118. private _isLoaded;
  74119. private _objectAttributes;
  74120. private _parentClass;
  74121. /**
  74122. * Create a new xml loader
  74123. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  74124. */
  74125. constructor(parentClass?: null);
  74126. private _getChainElement;
  74127. private _getClassAttribute;
  74128. private _createGuiElement;
  74129. private _parseGrid;
  74130. private _parseElement;
  74131. private _prepareSourceElement;
  74132. private _parseElementsFromSource;
  74133. private _parseXml;
  74134. /**
  74135. * Gets if the loading has finished.
  74136. * @returns whether the loading has finished or not
  74137. */
  74138. isLoaded(): boolean;
  74139. /**
  74140. * Gets a loaded node / control by id.
  74141. * @param id the Controls id set in the xml
  74142. * @returns element of type Control
  74143. */
  74144. getNodeById(id: string): any;
  74145. /**
  74146. * Gets all loaded nodes / controls
  74147. * @returns Array of controls
  74148. */
  74149. getNodes(): any;
  74150. /**
  74151. * Initiates the xml layout loading
  74152. * @param xmlFile defines the xml layout to load
  74153. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  74154. * @param callback defines the callback called on layout load.
  74155. */
  74156. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  74157. }
  74158. }
  74159. declare module BABYLON.GUI {
  74160. /**
  74161. * Class used to create containers for controls
  74162. */
  74163. export class Container3D extends Control3D {
  74164. private _blockLayout;
  74165. /**
  74166. * Gets the list of child controls
  74167. */
  74168. protected _children: Control3D[];
  74169. /**
  74170. * Gets the list of child controls
  74171. */
  74172. get children(): Array<Control3D>;
  74173. /**
  74174. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  74175. * This is helpful to optimize layout operation when adding multiple children in a row
  74176. */
  74177. get blockLayout(): boolean;
  74178. set blockLayout(value: boolean);
  74179. /**
  74180. * Creates a new container
  74181. * @param name defines the container name
  74182. */
  74183. constructor(name?: string);
  74184. /**
  74185. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  74186. * @returns the current container
  74187. */
  74188. updateLayout(): Container3D;
  74189. /**
  74190. * Gets a boolean indicating if the given control is in the children of this control
  74191. * @param control defines the control to check
  74192. * @returns true if the control is in the child list
  74193. */
  74194. containsControl(control: Control3D): boolean;
  74195. /**
  74196. * Adds a control to the children of this control
  74197. * @param control defines the control to add
  74198. * @returns the current container
  74199. */
  74200. addControl(control: Control3D): Container3D;
  74201. /**
  74202. * This function will be called everytime a new control is added
  74203. */
  74204. protected _arrangeChildren(): void;
  74205. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  74206. /**
  74207. * Removes a control from the children of this control
  74208. * @param control defines the control to remove
  74209. * @returns the current container
  74210. */
  74211. removeControl(control: Control3D): Container3D;
  74212. protected _getTypeName(): string;
  74213. /**
  74214. * Releases all associated resources
  74215. */
  74216. dispose(): void;
  74217. /** Control rotation will remain unchanged */
  74218. static readonly UNSET_ORIENTATION: number;
  74219. /** Control will rotate to make it look at sphere central axis */
  74220. static readonly FACEORIGIN_ORIENTATION: number;
  74221. /** Control will rotate to make it look back at sphere central axis */
  74222. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  74223. /** Control will rotate to look at z axis (0, 0, 1) */
  74224. static readonly FACEFORWARD_ORIENTATION: number;
  74225. /** Control will rotate to look at negative z axis (0, 0, -1) */
  74226. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  74227. }
  74228. }
  74229. declare module BABYLON.GUI {
  74230. /**
  74231. * Class used to manage 3D user interface
  74232. * @see http://doc.babylonjs.com/how_to/gui3d
  74233. */
  74234. export class GUI3DManager implements BABYLON.IDisposable {
  74235. private _scene;
  74236. private _sceneDisposeObserver;
  74237. private _utilityLayer;
  74238. private _rootContainer;
  74239. private _pointerObserver;
  74240. private _pointerOutObserver;
  74241. /** @hidden */
  74242. _lastPickedControl: Control3D;
  74243. /** @hidden */
  74244. _lastControlOver: {
  74245. [pointerId: number]: Control3D;
  74246. };
  74247. /** @hidden */
  74248. _lastControlDown: {
  74249. [pointerId: number]: Control3D;
  74250. };
  74251. /**
  74252. * BABYLON.Observable raised when the point picked by the pointer events changed
  74253. */
  74254. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  74255. /** @hidden */
  74256. _sharedMaterials: {
  74257. [key: string]: BABYLON.Material;
  74258. };
  74259. /** Gets the hosting scene */
  74260. get scene(): BABYLON.Scene;
  74261. /** Gets associated utility layer */
  74262. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  74263. /**
  74264. * Creates a new GUI3DManager
  74265. * @param scene
  74266. */
  74267. constructor(scene?: BABYLON.Scene);
  74268. private _handlePointerOut;
  74269. private _doPicking;
  74270. /**
  74271. * Gets the root container
  74272. */
  74273. get rootContainer(): Container3D;
  74274. /**
  74275. * Gets a boolean indicating if the given control is in the root child list
  74276. * @param control defines the control to check
  74277. * @returns true if the control is in the root child list
  74278. */
  74279. containsControl(control: Control3D): boolean;
  74280. /**
  74281. * Adds a control to the root child list
  74282. * @param control defines the control to add
  74283. * @returns the current manager
  74284. */
  74285. addControl(control: Control3D): GUI3DManager;
  74286. /**
  74287. * Removes a control from the root child list
  74288. * @param control defines the control to remove
  74289. * @returns the current container
  74290. */
  74291. removeControl(control: Control3D): GUI3DManager;
  74292. /**
  74293. * Releases all associated resources
  74294. */
  74295. dispose(): void;
  74296. }
  74297. }
  74298. declare module BABYLON.GUI {
  74299. /**
  74300. * Class used to transport BABYLON.Vector3 information for pointer events
  74301. */
  74302. export class Vector3WithInfo extends BABYLON.Vector3 {
  74303. /** defines the current mouse button index */
  74304. buttonIndex: number;
  74305. /**
  74306. * Creates a new Vector3WithInfo
  74307. * @param source defines the vector3 data to transport
  74308. * @param buttonIndex defines the current mouse button index
  74309. */
  74310. constructor(source: BABYLON.Vector3,
  74311. /** defines the current mouse button index */
  74312. buttonIndex?: number);
  74313. }
  74314. }
  74315. declare module BABYLON.GUI {
  74316. /**
  74317. * Class used as base class for controls
  74318. */
  74319. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  74320. /** Defines the control name */
  74321. name?: string | undefined;
  74322. /** @hidden */
  74323. _host: GUI3DManager;
  74324. private _node;
  74325. private _downCount;
  74326. private _enterCount;
  74327. private _downPointerIds;
  74328. private _isVisible;
  74329. /** Gets or sets the control position in world space */
  74330. get position(): BABYLON.Vector3;
  74331. set position(value: BABYLON.Vector3);
  74332. /** Gets or sets the control scaling in world space */
  74333. get scaling(): BABYLON.Vector3;
  74334. set scaling(value: BABYLON.Vector3);
  74335. /** Callback used to start pointer enter animation */
  74336. pointerEnterAnimation: () => void;
  74337. /** Callback used to start pointer out animation */
  74338. pointerOutAnimation: () => void;
  74339. /** Callback used to start pointer down animation */
  74340. pointerDownAnimation: () => void;
  74341. /** Callback used to start pointer up animation */
  74342. pointerUpAnimation: () => void;
  74343. /**
  74344. * An event triggered when the pointer move over the control
  74345. */
  74346. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  74347. /**
  74348. * An event triggered when the pointer move out of the control
  74349. */
  74350. onPointerOutObservable: BABYLON.Observable<Control3D>;
  74351. /**
  74352. * An event triggered when the pointer taps the control
  74353. */
  74354. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  74355. /**
  74356. * An event triggered when pointer is up
  74357. */
  74358. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  74359. /**
  74360. * An event triggered when a control is clicked on (with a mouse)
  74361. */
  74362. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  74363. /**
  74364. * An event triggered when pointer enters the control
  74365. */
  74366. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  74367. /**
  74368. * Gets or sets the parent container
  74369. */
  74370. parent: BABYLON.Nullable<Container3D>;
  74371. private _behaviors;
  74372. /**
  74373. * Gets the list of attached behaviors
  74374. * @see http://doc.babylonjs.com/features/behaviour
  74375. */
  74376. get behaviors(): BABYLON.Behavior<Control3D>[];
  74377. /**
  74378. * Attach a behavior to the control
  74379. * @see http://doc.babylonjs.com/features/behaviour
  74380. * @param behavior defines the behavior to attach
  74381. * @returns the current control
  74382. */
  74383. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  74384. /**
  74385. * Remove an attached behavior
  74386. * @see http://doc.babylonjs.com/features/behaviour
  74387. * @param behavior defines the behavior to attach
  74388. * @returns the current control
  74389. */
  74390. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  74391. /**
  74392. * Gets an attached behavior by name
  74393. * @param name defines the name of the behavior to look for
  74394. * @see http://doc.babylonjs.com/features/behaviour
  74395. * @returns null if behavior was not found else the requested behavior
  74396. */
  74397. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  74398. /** Gets or sets a boolean indicating if the control is visible */
  74399. get isVisible(): boolean;
  74400. set isVisible(value: boolean);
  74401. /**
  74402. * Creates a new control
  74403. * @param name defines the control name
  74404. */
  74405. constructor(
  74406. /** Defines the control name */
  74407. name?: string | undefined);
  74408. /**
  74409. * Gets a string representing the class name
  74410. */
  74411. get typeName(): string;
  74412. /**
  74413. * Get the current class name of the control.
  74414. * @returns current class name
  74415. */
  74416. getClassName(): string;
  74417. protected _getTypeName(): string;
  74418. /**
  74419. * Gets the transform node used by this control
  74420. */
  74421. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  74422. /**
  74423. * Gets the mesh used to render this control
  74424. */
  74425. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  74426. /**
  74427. * Link the control as child of the given node
  74428. * @param node defines the node to link to. Use null to unlink the control
  74429. * @returns the current control
  74430. */
  74431. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  74432. /** @hidden **/
  74433. _prepareNode(scene: BABYLON.Scene): void;
  74434. /**
  74435. * Node creation.
  74436. * Can be overriden by children
  74437. * @param scene defines the scene where the node must be attached
  74438. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  74439. */
  74440. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  74441. /**
  74442. * Affect a material to the given mesh
  74443. * @param mesh defines the mesh which will represent the control
  74444. */
  74445. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74446. /** @hidden */
  74447. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  74448. /** @hidden */
  74449. _onPointerEnter(target: Control3D): boolean;
  74450. /** @hidden */
  74451. _onPointerOut(target: Control3D): void;
  74452. /** @hidden */
  74453. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  74454. /** @hidden */
  74455. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74456. /** @hidden */
  74457. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  74458. /** @hidden */
  74459. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  74460. /** @hidden */
  74461. _disposeNode(): void;
  74462. /**
  74463. * Releases all associated resources
  74464. */
  74465. dispose(): void;
  74466. }
  74467. }
  74468. declare module BABYLON.GUI {
  74469. /**
  74470. * Class used as a root to all buttons
  74471. */
  74472. export class AbstractButton3D extends Control3D {
  74473. /**
  74474. * Creates a new button
  74475. * @param name defines the control name
  74476. */
  74477. constructor(name?: string);
  74478. protected _getTypeName(): string;
  74479. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74480. }
  74481. }
  74482. declare module BABYLON.GUI {
  74483. /**
  74484. * Class used to create a button in 3D
  74485. */
  74486. export class Button3D extends AbstractButton3D {
  74487. /** @hidden */
  74488. protected _currentMaterial: BABYLON.Material;
  74489. private _facadeTexture;
  74490. private _content;
  74491. private _contentResolution;
  74492. private _contentScaleRatio;
  74493. /**
  74494. * Gets or sets the texture resolution used to render content (512 by default)
  74495. */
  74496. get contentResolution(): BABYLON.int;
  74497. set contentResolution(value: BABYLON.int);
  74498. /**
  74499. * Gets or sets the texture scale ratio used to render content (2 by default)
  74500. */
  74501. get contentScaleRatio(): number;
  74502. set contentScaleRatio(value: number);
  74503. protected _disposeFacadeTexture(): void;
  74504. protected _resetContent(): void;
  74505. /**
  74506. * Creates a new button
  74507. * @param name defines the control name
  74508. */
  74509. constructor(name?: string);
  74510. /**
  74511. * Gets or sets the GUI 2D content used to display the button's facade
  74512. */
  74513. get content(): Control;
  74514. set content(value: Control);
  74515. /**
  74516. * Apply the facade texture (created from the content property).
  74517. * This function can be overloaded by child classes
  74518. * @param facadeTexture defines the AdvancedDynamicTexture to use
  74519. */
  74520. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  74521. protected _getTypeName(): string;
  74522. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74523. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74524. /**
  74525. * Releases all associated resources
  74526. */
  74527. dispose(): void;
  74528. }
  74529. }
  74530. declare module BABYLON.GUI {
  74531. /**
  74532. * Abstract class used to create a container panel deployed on the surface of a volume
  74533. */
  74534. export abstract class VolumeBasedPanel extends Container3D {
  74535. private _columns;
  74536. private _rows;
  74537. private _rowThenColum;
  74538. private _orientation;
  74539. protected _cellWidth: number;
  74540. protected _cellHeight: number;
  74541. /**
  74542. * Gets or sets the distance between elements
  74543. */
  74544. margin: number;
  74545. /**
  74546. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  74547. * | Value | Type | Description |
  74548. * | ----- | ----------------------------------- | ----------- |
  74549. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  74550. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  74551. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  74552. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  74553. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  74554. */
  74555. get orientation(): number;
  74556. set orientation(value: number);
  74557. /**
  74558. * Gets or sets the number of columns requested (10 by default).
  74559. * The panel will automatically compute the number of rows based on number of child controls.
  74560. */
  74561. get columns(): BABYLON.int;
  74562. set columns(value: BABYLON.int);
  74563. /**
  74564. * Gets or sets a the number of rows requested.
  74565. * The panel will automatically compute the number of columns based on number of child controls.
  74566. */
  74567. get rows(): BABYLON.int;
  74568. set rows(value: BABYLON.int);
  74569. /**
  74570. * Creates new VolumeBasedPanel
  74571. */
  74572. constructor();
  74573. protected _arrangeChildren(): void;
  74574. /** Child classes must implement this function to provide correct control positioning */
  74575. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74576. /** Child classes can implement this function to provide additional processing */
  74577. protected _finalProcessing(): void;
  74578. }
  74579. }
  74580. declare module BABYLON.GUI {
  74581. /**
  74582. * Class used to create a container panel deployed on the surface of a cylinder
  74583. */
  74584. export class CylinderPanel extends VolumeBasedPanel {
  74585. private _radius;
  74586. /**
  74587. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  74588. */
  74589. get radius(): BABYLON.float;
  74590. set radius(value: BABYLON.float);
  74591. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74592. private _cylindricalMapping;
  74593. }
  74594. }
  74595. declare module BABYLON.GUI {
  74596. /** @hidden */
  74597. export var fluentVertexShader: {
  74598. name: string;
  74599. shader: string;
  74600. };
  74601. }
  74602. declare module BABYLON.GUI {
  74603. /** @hidden */
  74604. export var fluentPixelShader: {
  74605. name: string;
  74606. shader: string;
  74607. };
  74608. }
  74609. declare module BABYLON.GUI {
  74610. /** @hidden */
  74611. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  74612. INNERGLOW: boolean;
  74613. BORDER: boolean;
  74614. HOVERLIGHT: boolean;
  74615. TEXTURE: boolean;
  74616. constructor();
  74617. }
  74618. /**
  74619. * Class used to render controls with fluent desgin
  74620. */
  74621. export class FluentMaterial extends BABYLON.PushMaterial {
  74622. /**
  74623. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  74624. */
  74625. innerGlowColorIntensity: number;
  74626. /**
  74627. * Gets or sets the inner glow color (white by default)
  74628. */
  74629. innerGlowColor: BABYLON.Color3;
  74630. /**
  74631. * Gets or sets alpha value (default is 1.0)
  74632. */
  74633. alpha: number;
  74634. /**
  74635. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  74636. */
  74637. albedoColor: BABYLON.Color3;
  74638. /**
  74639. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  74640. */
  74641. renderBorders: boolean;
  74642. /**
  74643. * Gets or sets border width (default is 0.5)
  74644. */
  74645. borderWidth: number;
  74646. /**
  74647. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  74648. */
  74649. edgeSmoothingValue: number;
  74650. /**
  74651. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  74652. */
  74653. borderMinValue: number;
  74654. /**
  74655. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  74656. */
  74657. renderHoverLight: boolean;
  74658. /**
  74659. * Gets or sets the radius used to render the hover light (default is 1.0)
  74660. */
  74661. hoverRadius: number;
  74662. /**
  74663. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  74664. */
  74665. hoverColor: BABYLON.Color4;
  74666. /**
  74667. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  74668. */
  74669. hoverPosition: BABYLON.Vector3;
  74670. private _albedoTexture;
  74671. /** Gets or sets the texture to use for albedo color */
  74672. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  74673. /**
  74674. * Creates a new Fluent material
  74675. * @param name defines the name of the material
  74676. * @param scene defines the hosting scene
  74677. */
  74678. constructor(name: string, scene: BABYLON.Scene);
  74679. needAlphaBlending(): boolean;
  74680. needAlphaTesting(): boolean;
  74681. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74682. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74683. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74684. getActiveTextures(): BABYLON.BaseTexture[];
  74685. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74686. dispose(forceDisposeEffect?: boolean): void;
  74687. clone(name: string): FluentMaterial;
  74688. serialize(): any;
  74689. getClassName(): string;
  74690. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  74691. }
  74692. }
  74693. declare module BABYLON.GUI {
  74694. /**
  74695. * Class used to create a holographic button in 3D
  74696. */
  74697. export class HolographicButton extends Button3D {
  74698. private _backPlate;
  74699. private _textPlate;
  74700. private _frontPlate;
  74701. private _text;
  74702. private _imageUrl;
  74703. private _shareMaterials;
  74704. private _frontMaterial;
  74705. private _backMaterial;
  74706. private _plateMaterial;
  74707. private _pickedPointObserver;
  74708. private _tooltipFade;
  74709. private _tooltipTextBlock;
  74710. private _tooltipTexture;
  74711. private _tooltipMesh;
  74712. private _tooltipHoverObserver;
  74713. private _tooltipOutObserver;
  74714. private _disposeTooltip;
  74715. /**
  74716. * Rendering ground id of all the mesh in the button
  74717. */
  74718. set renderingGroupId(id: number);
  74719. get renderingGroupId(): number;
  74720. /**
  74721. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  74722. */
  74723. set tooltipText(text: BABYLON.Nullable<string>);
  74724. get tooltipText(): BABYLON.Nullable<string>;
  74725. /**
  74726. * Gets or sets text for the button
  74727. */
  74728. get text(): string;
  74729. set text(value: string);
  74730. /**
  74731. * Gets or sets the image url for the button
  74732. */
  74733. get imageUrl(): string;
  74734. set imageUrl(value: string);
  74735. /**
  74736. * Gets the back material used by this button
  74737. */
  74738. get backMaterial(): FluentMaterial;
  74739. /**
  74740. * Gets the front material used by this button
  74741. */
  74742. get frontMaterial(): FluentMaterial;
  74743. /**
  74744. * Gets the plate material used by this button
  74745. */
  74746. get plateMaterial(): BABYLON.StandardMaterial;
  74747. /**
  74748. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  74749. */
  74750. get shareMaterials(): boolean;
  74751. /**
  74752. * Creates a new button
  74753. * @param name defines the control name
  74754. */
  74755. constructor(name?: string, shareMaterials?: boolean);
  74756. protected _getTypeName(): string;
  74757. private _rebuildContent;
  74758. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74759. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  74760. private _createBackMaterial;
  74761. private _createFrontMaterial;
  74762. private _createPlateMaterial;
  74763. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  74764. /**
  74765. * Releases all associated resources
  74766. */
  74767. dispose(): void;
  74768. }
  74769. }
  74770. declare module BABYLON.GUI {
  74771. /**
  74772. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  74773. */
  74774. export class MeshButton3D extends Button3D {
  74775. /** @hidden */
  74776. protected _currentMesh: BABYLON.Mesh;
  74777. /**
  74778. * Creates a new 3D button based on a mesh
  74779. * @param mesh mesh to become a 3D button
  74780. * @param name defines the control name
  74781. */
  74782. constructor(mesh: BABYLON.Mesh, name?: string);
  74783. protected _getTypeName(): string;
  74784. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74785. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74786. }
  74787. }
  74788. declare module BABYLON.GUI {
  74789. /**
  74790. * Class used to create a container panel deployed on the surface of a plane
  74791. */
  74792. export class PlanePanel extends VolumeBasedPanel {
  74793. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74794. }
  74795. }
  74796. declare module BABYLON.GUI {
  74797. /**
  74798. * Class used to create a container panel where items get randomized planar mapping
  74799. */
  74800. export class ScatterPanel extends VolumeBasedPanel {
  74801. private _iteration;
  74802. /**
  74803. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  74804. */
  74805. get iteration(): BABYLON.float;
  74806. set iteration(value: BABYLON.float);
  74807. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74808. private _scatterMapping;
  74809. protected _finalProcessing(): void;
  74810. }
  74811. }
  74812. declare module BABYLON.GUI {
  74813. /**
  74814. * Class used to create a container panel deployed on the surface of a sphere
  74815. */
  74816. export class SpherePanel extends VolumeBasedPanel {
  74817. private _radius;
  74818. /**
  74819. * Gets or sets the radius of the sphere where to project controls (5 by default)
  74820. */
  74821. get radius(): BABYLON.float;
  74822. set radius(value: BABYLON.float);
  74823. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74824. private _sphericalMapping;
  74825. }
  74826. }
  74827. declare module BABYLON.GUI {
  74828. /**
  74829. * Class used to create a stack panel in 3D on XY plane
  74830. */
  74831. export class StackPanel3D extends Container3D {
  74832. private _isVertical;
  74833. /**
  74834. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  74835. */
  74836. get isVertical(): boolean;
  74837. set isVertical(value: boolean);
  74838. /**
  74839. * Gets or sets the distance between elements
  74840. */
  74841. margin: number;
  74842. /**
  74843. * Creates new StackPanel
  74844. * @param isVertical
  74845. */
  74846. constructor(isVertical?: boolean);
  74847. protected _arrangeChildren(): void;
  74848. }
  74849. }
  74850. declare module BABYLON {
  74851. /**
  74852. * Configuration for glTF validation
  74853. */
  74854. export interface IGLTFValidationConfiguration {
  74855. /**
  74856. * The url of the glTF validator.
  74857. */
  74858. url: string;
  74859. }
  74860. /**
  74861. * glTF validation
  74862. */
  74863. export class GLTFValidation {
  74864. /**
  74865. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  74866. */
  74867. static Configuration: IGLTFValidationConfiguration;
  74868. private static _LoadScriptPromise;
  74869. /**
  74870. * Validate a glTF asset using the glTF-Validator.
  74871. * @param data The JSON of a glTF or the array buffer of a binary glTF
  74872. * @param rootUrl The root url for the glTF
  74873. * @param fileName The file name for the glTF
  74874. * @param getExternalResource The callback to get external resources for the glTF validator
  74875. * @returns A promise that resolves with the glTF validation results once complete
  74876. */
  74877. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  74878. }
  74879. }
  74880. declare module BABYLON {
  74881. /**
  74882. * Mode that determines the coordinate system to use.
  74883. */
  74884. export enum GLTFLoaderCoordinateSystemMode {
  74885. /**
  74886. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  74887. */
  74888. AUTO = 0,
  74889. /**
  74890. * Sets the useRightHandedSystem flag on the scene.
  74891. */
  74892. FORCE_RIGHT_HANDED = 1
  74893. }
  74894. /**
  74895. * Mode that determines what animations will start.
  74896. */
  74897. export enum GLTFLoaderAnimationStartMode {
  74898. /**
  74899. * No animation will start.
  74900. */
  74901. NONE = 0,
  74902. /**
  74903. * The first animation will start.
  74904. */
  74905. FIRST = 1,
  74906. /**
  74907. * All animations will start.
  74908. */
  74909. ALL = 2
  74910. }
  74911. /**
  74912. * Interface that contains the data for the glTF asset.
  74913. */
  74914. export interface IGLTFLoaderData {
  74915. /**
  74916. * The object that represents the glTF JSON.
  74917. */
  74918. json: Object;
  74919. /**
  74920. * The BIN chunk of a binary glTF.
  74921. */
  74922. bin: Nullable<IDataBuffer>;
  74923. }
  74924. /**
  74925. * Interface for extending the loader.
  74926. */
  74927. export interface IGLTFLoaderExtension {
  74928. /**
  74929. * The name of this extension.
  74930. */
  74931. readonly name: string;
  74932. /**
  74933. * Defines whether this extension is enabled.
  74934. */
  74935. enabled: boolean;
  74936. /**
  74937. * Defines the order of this extension.
  74938. * The loader sorts the extensions using these values when loading.
  74939. */
  74940. order?: number;
  74941. }
  74942. /**
  74943. * Loader state.
  74944. */
  74945. export enum GLTFLoaderState {
  74946. /**
  74947. * The asset is loading.
  74948. */
  74949. LOADING = 0,
  74950. /**
  74951. * The asset is ready for rendering.
  74952. */
  74953. READY = 1,
  74954. /**
  74955. * The asset is completely loaded.
  74956. */
  74957. COMPLETE = 2
  74958. }
  74959. /** @hidden */
  74960. export interface IImportMeshAsyncOutput {
  74961. meshes: AbstractMesh[];
  74962. particleSystems: IParticleSystem[];
  74963. skeletons: Skeleton[];
  74964. animationGroups: AnimationGroup[];
  74965. lights: Light[];
  74966. transformNodes: TransformNode[];
  74967. }
  74968. /** @hidden */
  74969. export interface IGLTFLoader extends IDisposable {
  74970. readonly state: Nullable<GLTFLoaderState>;
  74971. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  74972. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  74973. }
  74974. /**
  74975. * File loader for loading glTF files into a scene.
  74976. */
  74977. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  74978. /** @hidden */
  74979. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  74980. /** @hidden */
  74981. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  74982. /**
  74983. * Raised when the asset has been parsed
  74984. */
  74985. onParsedObservable: Observable<IGLTFLoaderData>;
  74986. private _onParsedObserver;
  74987. /**
  74988. * Raised when the asset has been parsed
  74989. */
  74990. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  74991. /**
  74992. * 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.
  74993. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  74994. * Defaults to true.
  74995. * @hidden
  74996. */
  74997. static IncrementalLoading: boolean;
  74998. /**
  74999. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  75000. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  75001. * @hidden
  75002. */
  75003. static HomogeneousCoordinates: boolean;
  75004. /**
  75005. * The coordinate system mode. Defaults to AUTO.
  75006. */
  75007. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  75008. /**
  75009. * The animation start mode. Defaults to FIRST.
  75010. */
  75011. animationStartMode: GLTFLoaderAnimationStartMode;
  75012. /**
  75013. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  75014. */
  75015. compileMaterials: boolean;
  75016. /**
  75017. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  75018. */
  75019. useClipPlane: boolean;
  75020. /**
  75021. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  75022. */
  75023. compileShadowGenerators: boolean;
  75024. /**
  75025. * Defines if the Alpha blended materials are only applied as coverage.
  75026. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  75027. * If true, no extra effects are applied to transparent pixels.
  75028. */
  75029. transparencyAsCoverage: boolean;
  75030. /**
  75031. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  75032. * Enabling will disable offline support and glTF validator.
  75033. * Defaults to false.
  75034. */
  75035. useRangeRequests: boolean;
  75036. /**
  75037. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  75038. */
  75039. createInstances: boolean;
  75040. /**
  75041. * Function called before loading a url referenced by the asset.
  75042. */
  75043. preprocessUrlAsync: (url: string) => Promise<string>;
  75044. /**
  75045. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  75046. */
  75047. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  75048. private _onMeshLoadedObserver;
  75049. /**
  75050. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  75051. */
  75052. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  75053. /**
  75054. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  75055. */
  75056. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  75057. private _onTextureLoadedObserver;
  75058. /**
  75059. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  75060. */
  75061. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  75062. /**
  75063. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  75064. */
  75065. readonly onMaterialLoadedObservable: Observable<Material>;
  75066. private _onMaterialLoadedObserver;
  75067. /**
  75068. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  75069. */
  75070. set onMaterialLoaded(callback: (material: Material) => void);
  75071. /**
  75072. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  75073. */
  75074. readonly onCameraLoadedObservable: Observable<Camera>;
  75075. private _onCameraLoadedObserver;
  75076. /**
  75077. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  75078. */
  75079. set onCameraLoaded(callback: (camera: Camera) => void);
  75080. /**
  75081. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  75082. * For assets with LODs, raised when all of the LODs are complete.
  75083. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  75084. */
  75085. readonly onCompleteObservable: Observable<void>;
  75086. private _onCompleteObserver;
  75087. /**
  75088. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  75089. * For assets with LODs, raised when all of the LODs are complete.
  75090. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  75091. */
  75092. set onComplete(callback: () => void);
  75093. /**
  75094. * Observable raised when an error occurs.
  75095. */
  75096. readonly onErrorObservable: Observable<any>;
  75097. private _onErrorObserver;
  75098. /**
  75099. * Callback raised when an error occurs.
  75100. */
  75101. set onError(callback: (reason: any) => void);
  75102. /**
  75103. * Observable raised after the loader is disposed.
  75104. */
  75105. readonly onDisposeObservable: Observable<void>;
  75106. private _onDisposeObserver;
  75107. /**
  75108. * Callback raised after the loader is disposed.
  75109. */
  75110. set onDispose(callback: () => void);
  75111. /**
  75112. * Observable raised after a loader extension is created.
  75113. * Set additional options for a loader extension in this event.
  75114. */
  75115. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  75116. private _onExtensionLoadedObserver;
  75117. /**
  75118. * Callback raised after a loader extension is created.
  75119. */
  75120. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  75121. /**
  75122. * Defines if the loader logging is enabled.
  75123. */
  75124. get loggingEnabled(): boolean;
  75125. set loggingEnabled(value: boolean);
  75126. /**
  75127. * Defines if the loader should capture performance counters.
  75128. */
  75129. get capturePerformanceCounters(): boolean;
  75130. set capturePerformanceCounters(value: boolean);
  75131. /**
  75132. * Defines if the loader should validate the asset.
  75133. */
  75134. validate: boolean;
  75135. /**
  75136. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  75137. */
  75138. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  75139. private _onValidatedObserver;
  75140. /**
  75141. * Callback raised after a loader extension is created.
  75142. */
  75143. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  75144. private _loader;
  75145. /**
  75146. * Name of the loader ("gltf")
  75147. */
  75148. name: string;
  75149. /** @hidden */
  75150. extensions: ISceneLoaderPluginExtensions;
  75151. /**
  75152. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  75153. */
  75154. dispose(): void;
  75155. /** @hidden */
  75156. _clear(): void;
  75157. /** @hidden */
  75158. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  75159. /** @hidden */
  75160. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  75161. /** @hidden */
  75162. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  75163. meshes: AbstractMesh[];
  75164. particleSystems: IParticleSystem[];
  75165. skeletons: Skeleton[];
  75166. animationGroups: AnimationGroup[];
  75167. }>;
  75168. /** @hidden */
  75169. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  75170. /** @hidden */
  75171. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  75172. /** @hidden */
  75173. canDirectLoad(data: string): boolean;
  75174. /** @hidden */
  75175. directLoad(scene: Scene, data: string): any;
  75176. /**
  75177. * The callback that allows custom handling of the root url based on the response url.
  75178. * @param rootUrl the original root url
  75179. * @param responseURL the response url if available
  75180. * @returns the new root url
  75181. */
  75182. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  75183. /** @hidden */
  75184. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  75185. /**
  75186. * The loader state or null if the loader is not active.
  75187. */
  75188. get loaderState(): Nullable<GLTFLoaderState>;
  75189. /**
  75190. * Returns a promise that resolves when the asset is completely loaded.
  75191. * @returns a promise that resolves when the asset is completely loaded.
  75192. */
  75193. whenCompleteAsync(): Promise<void>;
  75194. private _validate;
  75195. private _getLoader;
  75196. private _parseJson;
  75197. private _unpackBinaryAsync;
  75198. private _unpackBinaryV1Async;
  75199. private _unpackBinaryV2Async;
  75200. private static _parseVersion;
  75201. private static _compareVersion;
  75202. private static readonly _logSpaces;
  75203. private _logIndentLevel;
  75204. private _loggingEnabled;
  75205. /** @hidden */
  75206. _log: (message: string) => void;
  75207. /** @hidden */
  75208. _logOpen(message: string): void;
  75209. /** @hidden */
  75210. _logClose(): void;
  75211. private _logEnabled;
  75212. private _logDisabled;
  75213. private _capturePerformanceCounters;
  75214. /** @hidden */
  75215. _startPerformanceCounter: (counterName: string) => void;
  75216. /** @hidden */
  75217. _endPerformanceCounter: (counterName: string) => void;
  75218. private _startPerformanceCounterEnabled;
  75219. private _startPerformanceCounterDisabled;
  75220. private _endPerformanceCounterEnabled;
  75221. private _endPerformanceCounterDisabled;
  75222. }
  75223. }
  75224. declare module BABYLON.GLTF1 {
  75225. /**
  75226. * Enums
  75227. * @hidden
  75228. */
  75229. export enum EComponentType {
  75230. BYTE = 5120,
  75231. UNSIGNED_BYTE = 5121,
  75232. SHORT = 5122,
  75233. UNSIGNED_SHORT = 5123,
  75234. FLOAT = 5126
  75235. }
  75236. /** @hidden */
  75237. export enum EShaderType {
  75238. FRAGMENT = 35632,
  75239. VERTEX = 35633
  75240. }
  75241. /** @hidden */
  75242. export enum EParameterType {
  75243. BYTE = 5120,
  75244. UNSIGNED_BYTE = 5121,
  75245. SHORT = 5122,
  75246. UNSIGNED_SHORT = 5123,
  75247. INT = 5124,
  75248. UNSIGNED_INT = 5125,
  75249. FLOAT = 5126,
  75250. FLOAT_VEC2 = 35664,
  75251. FLOAT_VEC3 = 35665,
  75252. FLOAT_VEC4 = 35666,
  75253. INT_VEC2 = 35667,
  75254. INT_VEC3 = 35668,
  75255. INT_VEC4 = 35669,
  75256. BOOL = 35670,
  75257. BOOL_VEC2 = 35671,
  75258. BOOL_VEC3 = 35672,
  75259. BOOL_VEC4 = 35673,
  75260. FLOAT_MAT2 = 35674,
  75261. FLOAT_MAT3 = 35675,
  75262. FLOAT_MAT4 = 35676,
  75263. SAMPLER_2D = 35678
  75264. }
  75265. /** @hidden */
  75266. export enum ETextureWrapMode {
  75267. CLAMP_TO_EDGE = 33071,
  75268. MIRRORED_REPEAT = 33648,
  75269. REPEAT = 10497
  75270. }
  75271. /** @hidden */
  75272. export enum ETextureFilterType {
  75273. NEAREST = 9728,
  75274. LINEAR = 9728,
  75275. NEAREST_MIPMAP_NEAREST = 9984,
  75276. LINEAR_MIPMAP_NEAREST = 9985,
  75277. NEAREST_MIPMAP_LINEAR = 9986,
  75278. LINEAR_MIPMAP_LINEAR = 9987
  75279. }
  75280. /** @hidden */
  75281. export enum ETextureFormat {
  75282. ALPHA = 6406,
  75283. RGB = 6407,
  75284. RGBA = 6408,
  75285. LUMINANCE = 6409,
  75286. LUMINANCE_ALPHA = 6410
  75287. }
  75288. /** @hidden */
  75289. export enum ECullingType {
  75290. FRONT = 1028,
  75291. BACK = 1029,
  75292. FRONT_AND_BACK = 1032
  75293. }
  75294. /** @hidden */
  75295. export enum EBlendingFunction {
  75296. ZERO = 0,
  75297. ONE = 1,
  75298. SRC_COLOR = 768,
  75299. ONE_MINUS_SRC_COLOR = 769,
  75300. DST_COLOR = 774,
  75301. ONE_MINUS_DST_COLOR = 775,
  75302. SRC_ALPHA = 770,
  75303. ONE_MINUS_SRC_ALPHA = 771,
  75304. DST_ALPHA = 772,
  75305. ONE_MINUS_DST_ALPHA = 773,
  75306. CONSTANT_COLOR = 32769,
  75307. ONE_MINUS_CONSTANT_COLOR = 32770,
  75308. CONSTANT_ALPHA = 32771,
  75309. ONE_MINUS_CONSTANT_ALPHA = 32772,
  75310. SRC_ALPHA_SATURATE = 776
  75311. }
  75312. /** @hidden */
  75313. export interface IGLTFProperty {
  75314. extensions?: {
  75315. [key: string]: any;
  75316. };
  75317. extras?: Object;
  75318. }
  75319. /** @hidden */
  75320. export interface IGLTFChildRootProperty extends IGLTFProperty {
  75321. name?: string;
  75322. }
  75323. /** @hidden */
  75324. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  75325. bufferView: string;
  75326. byteOffset: number;
  75327. byteStride: number;
  75328. count: number;
  75329. type: string;
  75330. componentType: EComponentType;
  75331. max?: number[];
  75332. min?: number[];
  75333. name?: string;
  75334. }
  75335. /** @hidden */
  75336. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  75337. buffer: string;
  75338. byteOffset: number;
  75339. byteLength: number;
  75340. byteStride: number;
  75341. target?: number;
  75342. }
  75343. /** @hidden */
  75344. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  75345. uri: string;
  75346. byteLength?: number;
  75347. type?: string;
  75348. }
  75349. /** @hidden */
  75350. export interface IGLTFShader extends IGLTFChildRootProperty {
  75351. uri: string;
  75352. type: EShaderType;
  75353. }
  75354. /** @hidden */
  75355. export interface IGLTFProgram extends IGLTFChildRootProperty {
  75356. attributes: string[];
  75357. fragmentShader: string;
  75358. vertexShader: string;
  75359. }
  75360. /** @hidden */
  75361. export interface IGLTFTechniqueParameter {
  75362. type: number;
  75363. count?: number;
  75364. semantic?: string;
  75365. node?: string;
  75366. value?: number | boolean | string | Array<any>;
  75367. source?: string;
  75368. babylonValue?: any;
  75369. }
  75370. /** @hidden */
  75371. export interface IGLTFTechniqueCommonProfile {
  75372. lightingModel: string;
  75373. texcoordBindings: Object;
  75374. parameters?: Array<any>;
  75375. }
  75376. /** @hidden */
  75377. export interface IGLTFTechniqueStatesFunctions {
  75378. blendColor?: number[];
  75379. blendEquationSeparate?: number[];
  75380. blendFuncSeparate?: number[];
  75381. colorMask: boolean[];
  75382. cullFace: number[];
  75383. }
  75384. /** @hidden */
  75385. export interface IGLTFTechniqueStates {
  75386. enable: number[];
  75387. functions: IGLTFTechniqueStatesFunctions;
  75388. }
  75389. /** @hidden */
  75390. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  75391. parameters: {
  75392. [key: string]: IGLTFTechniqueParameter;
  75393. };
  75394. program: string;
  75395. attributes: {
  75396. [key: string]: string;
  75397. };
  75398. uniforms: {
  75399. [key: string]: string;
  75400. };
  75401. states: IGLTFTechniqueStates;
  75402. }
  75403. /** @hidden */
  75404. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  75405. technique?: string;
  75406. values: string[];
  75407. }
  75408. /** @hidden */
  75409. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  75410. attributes: {
  75411. [key: string]: string;
  75412. };
  75413. indices: string;
  75414. material: string;
  75415. mode?: number;
  75416. }
  75417. /** @hidden */
  75418. export interface IGLTFMesh extends IGLTFChildRootProperty {
  75419. primitives: IGLTFMeshPrimitive[];
  75420. }
  75421. /** @hidden */
  75422. export interface IGLTFImage extends IGLTFChildRootProperty {
  75423. uri: string;
  75424. }
  75425. /** @hidden */
  75426. export interface IGLTFSampler extends IGLTFChildRootProperty {
  75427. magFilter?: number;
  75428. minFilter?: number;
  75429. wrapS?: number;
  75430. wrapT?: number;
  75431. }
  75432. /** @hidden */
  75433. export interface IGLTFTexture extends IGLTFChildRootProperty {
  75434. sampler: string;
  75435. source: string;
  75436. format?: ETextureFormat;
  75437. internalFormat?: ETextureFormat;
  75438. target?: number;
  75439. type?: number;
  75440. babylonTexture?: Texture;
  75441. }
  75442. /** @hidden */
  75443. export interface IGLTFAmbienLight {
  75444. color?: number[];
  75445. }
  75446. /** @hidden */
  75447. export interface IGLTFDirectionalLight {
  75448. color?: number[];
  75449. }
  75450. /** @hidden */
  75451. export interface IGLTFPointLight {
  75452. color?: number[];
  75453. constantAttenuation?: number;
  75454. linearAttenuation?: number;
  75455. quadraticAttenuation?: number;
  75456. }
  75457. /** @hidden */
  75458. export interface IGLTFSpotLight {
  75459. color?: number[];
  75460. constantAttenuation?: number;
  75461. fallOfAngle?: number;
  75462. fallOffExponent?: number;
  75463. linearAttenuation?: number;
  75464. quadraticAttenuation?: number;
  75465. }
  75466. /** @hidden */
  75467. export interface IGLTFLight extends IGLTFChildRootProperty {
  75468. type: string;
  75469. }
  75470. /** @hidden */
  75471. export interface IGLTFCameraOrthographic {
  75472. xmag: number;
  75473. ymag: number;
  75474. zfar: number;
  75475. znear: number;
  75476. }
  75477. /** @hidden */
  75478. export interface IGLTFCameraPerspective {
  75479. aspectRatio: number;
  75480. yfov: number;
  75481. zfar: number;
  75482. znear: number;
  75483. }
  75484. /** @hidden */
  75485. export interface IGLTFCamera extends IGLTFChildRootProperty {
  75486. type: string;
  75487. }
  75488. /** @hidden */
  75489. export interface IGLTFAnimationChannelTarget {
  75490. id: string;
  75491. path: string;
  75492. }
  75493. /** @hidden */
  75494. export interface IGLTFAnimationChannel {
  75495. sampler: string;
  75496. target: IGLTFAnimationChannelTarget;
  75497. }
  75498. /** @hidden */
  75499. export interface IGLTFAnimationSampler {
  75500. input: string;
  75501. output: string;
  75502. interpolation?: string;
  75503. }
  75504. /** @hidden */
  75505. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  75506. channels?: IGLTFAnimationChannel[];
  75507. parameters?: {
  75508. [key: string]: string;
  75509. };
  75510. samplers?: {
  75511. [key: string]: IGLTFAnimationSampler;
  75512. };
  75513. }
  75514. /** @hidden */
  75515. export interface IGLTFNodeInstanceSkin {
  75516. skeletons: string[];
  75517. skin: string;
  75518. meshes: string[];
  75519. }
  75520. /** @hidden */
  75521. export interface IGLTFSkins extends IGLTFChildRootProperty {
  75522. bindShapeMatrix: number[];
  75523. inverseBindMatrices: string;
  75524. jointNames: string[];
  75525. babylonSkeleton?: Skeleton;
  75526. }
  75527. /** @hidden */
  75528. export interface IGLTFNode extends IGLTFChildRootProperty {
  75529. camera?: string;
  75530. children: string[];
  75531. skin?: string;
  75532. jointName?: string;
  75533. light?: string;
  75534. matrix: number[];
  75535. mesh?: string;
  75536. meshes?: string[];
  75537. rotation?: number[];
  75538. scale?: number[];
  75539. translation?: number[];
  75540. babylonNode?: Node;
  75541. }
  75542. /** @hidden */
  75543. export interface IGLTFScene extends IGLTFChildRootProperty {
  75544. nodes: string[];
  75545. }
  75546. /** @hidden */
  75547. export interface IGLTFRuntime {
  75548. extensions: {
  75549. [key: string]: any;
  75550. };
  75551. accessors: {
  75552. [key: string]: IGLTFAccessor;
  75553. };
  75554. buffers: {
  75555. [key: string]: IGLTFBuffer;
  75556. };
  75557. bufferViews: {
  75558. [key: string]: IGLTFBufferView;
  75559. };
  75560. meshes: {
  75561. [key: string]: IGLTFMesh;
  75562. };
  75563. lights: {
  75564. [key: string]: IGLTFLight;
  75565. };
  75566. cameras: {
  75567. [key: string]: IGLTFCamera;
  75568. };
  75569. nodes: {
  75570. [key: string]: IGLTFNode;
  75571. };
  75572. images: {
  75573. [key: string]: IGLTFImage;
  75574. };
  75575. textures: {
  75576. [key: string]: IGLTFTexture;
  75577. };
  75578. shaders: {
  75579. [key: string]: IGLTFShader;
  75580. };
  75581. programs: {
  75582. [key: string]: IGLTFProgram;
  75583. };
  75584. samplers: {
  75585. [key: string]: IGLTFSampler;
  75586. };
  75587. techniques: {
  75588. [key: string]: IGLTFTechnique;
  75589. };
  75590. materials: {
  75591. [key: string]: IGLTFMaterial;
  75592. };
  75593. animations: {
  75594. [key: string]: IGLTFAnimation;
  75595. };
  75596. skins: {
  75597. [key: string]: IGLTFSkins;
  75598. };
  75599. currentScene?: Object;
  75600. scenes: {
  75601. [key: string]: IGLTFScene;
  75602. };
  75603. extensionsUsed: string[];
  75604. extensionsRequired?: string[];
  75605. buffersCount: number;
  75606. shaderscount: number;
  75607. scene: Scene;
  75608. rootUrl: string;
  75609. loadedBufferCount: number;
  75610. loadedBufferViews: {
  75611. [name: string]: ArrayBufferView;
  75612. };
  75613. loadedShaderCount: number;
  75614. importOnlyMeshes: boolean;
  75615. importMeshesNames?: string[];
  75616. dummyNodes: Node[];
  75617. forAssetContainer: boolean;
  75618. }
  75619. /** @hidden */
  75620. export interface INodeToRoot {
  75621. bone: Bone;
  75622. node: IGLTFNode;
  75623. id: string;
  75624. }
  75625. /** @hidden */
  75626. export interface IJointNode {
  75627. node: IGLTFNode;
  75628. id: string;
  75629. }
  75630. }
  75631. declare module BABYLON.GLTF1 {
  75632. /**
  75633. * Utils functions for GLTF
  75634. * @hidden
  75635. */
  75636. export class GLTFUtils {
  75637. /**
  75638. * Sets the given "parameter" matrix
  75639. * @param scene: the Scene object
  75640. * @param source: the source node where to pick the matrix
  75641. * @param parameter: the GLTF technique parameter
  75642. * @param uniformName: the name of the shader's uniform
  75643. * @param shaderMaterial: the shader material
  75644. */
  75645. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  75646. /**
  75647. * Sets the given "parameter" matrix
  75648. * @param shaderMaterial: the shader material
  75649. * @param uniform: the name of the shader's uniform
  75650. * @param value: the value of the uniform
  75651. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  75652. */
  75653. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  75654. /**
  75655. * Returns the wrap mode of the texture
  75656. * @param mode: the mode value
  75657. */
  75658. static GetWrapMode(mode: number): number;
  75659. /**
  75660. * Returns the byte stride giving an accessor
  75661. * @param accessor: the GLTF accessor objet
  75662. */
  75663. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  75664. /**
  75665. * Returns the texture filter mode giving a mode value
  75666. * @param mode: the filter mode value
  75667. */
  75668. static GetTextureFilterMode(mode: number): ETextureFilterType;
  75669. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  75670. /**
  75671. * Returns a buffer from its accessor
  75672. * @param gltfRuntime: the GLTF runtime
  75673. * @param accessor: the GLTF accessor
  75674. */
  75675. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  75676. /**
  75677. * Decodes a buffer view into a string
  75678. * @param view: the buffer view
  75679. */
  75680. static DecodeBufferToText(view: ArrayBufferView): string;
  75681. /**
  75682. * Returns the default material of gltf. Related to
  75683. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  75684. * @param scene: the Babylon.js scene
  75685. */
  75686. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  75687. private static _DefaultMaterial;
  75688. }
  75689. }
  75690. declare module BABYLON.GLTF1 {
  75691. /**
  75692. * Implementation of the base glTF spec
  75693. * @hidden
  75694. */
  75695. export class GLTFLoaderBase {
  75696. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  75697. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  75698. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  75699. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  75700. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  75701. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  75702. }
  75703. /**
  75704. * glTF V1 Loader
  75705. * @hidden
  75706. */
  75707. export class GLTFLoader implements IGLTFLoader {
  75708. static Extensions: {
  75709. [name: string]: GLTFLoaderExtension;
  75710. };
  75711. static RegisterExtension(extension: GLTFLoaderExtension): void;
  75712. state: Nullable<GLTFLoaderState>;
  75713. dispose(): void;
  75714. private _importMeshAsync;
  75715. /**
  75716. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  75717. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  75718. * @param scene the scene the meshes should be added to
  75719. * @param forAssetContainer defines if the entities must be stored in the scene
  75720. * @param data gltf data containing information of the meshes in a loaded file
  75721. * @param rootUrl root url to load from
  75722. * @param onProgress event that fires when loading progress has occured
  75723. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  75724. */
  75725. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  75726. private _loadAsync;
  75727. /**
  75728. * Imports all objects from a loaded gltf file and adds them to the scene
  75729. * @param scene the scene the objects should be added to
  75730. * @param data gltf data containing information of the meshes in a loaded file
  75731. * @param rootUrl root url to load from
  75732. * @param onProgress event that fires when loading progress has occured
  75733. * @returns a promise which completes when objects have been loaded to the scene
  75734. */
  75735. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  75736. private _loadShadersAsync;
  75737. private _loadBuffersAsync;
  75738. private _createNodes;
  75739. }
  75740. /** @hidden */
  75741. export abstract class GLTFLoaderExtension {
  75742. private _name;
  75743. constructor(name: string);
  75744. get name(): string;
  75745. /**
  75746. * Defines an override for loading the runtime
  75747. * Return true to stop further extensions from loading the runtime
  75748. */
  75749. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  75750. /**
  75751. * Defines an onverride for creating gltf runtime
  75752. * Return true to stop further extensions from creating the runtime
  75753. */
  75754. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  75755. /**
  75756. * Defines an override for loading buffers
  75757. * Return true to stop further extensions from loading this buffer
  75758. */
  75759. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  75760. /**
  75761. * Defines an override for loading texture buffers
  75762. * Return true to stop further extensions from loading this texture data
  75763. */
  75764. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  75765. /**
  75766. * Defines an override for creating textures
  75767. * Return true to stop further extensions from loading this texture
  75768. */
  75769. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  75770. /**
  75771. * Defines an override for loading shader strings
  75772. * Return true to stop further extensions from loading this shader data
  75773. */
  75774. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  75775. /**
  75776. * Defines an override for loading materials
  75777. * Return true to stop further extensions from loading this material
  75778. */
  75779. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  75780. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  75781. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  75782. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  75783. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  75784. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  75785. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  75786. private static LoadTextureBufferAsync;
  75787. private static CreateTextureAsync;
  75788. private static ApplyExtensions;
  75789. }
  75790. }
  75791. declare module BABYLON.GLTF1 {
  75792. /** @hidden */
  75793. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  75794. private _bin;
  75795. constructor();
  75796. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  75797. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  75798. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  75799. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  75800. }
  75801. }
  75802. declare module BABYLON.GLTF1 {
  75803. /** @hidden */
  75804. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  75805. constructor();
  75806. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  75807. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  75808. private _loadTexture;
  75809. }
  75810. }
  75811. declare module BABYLON.GLTF2.Loader {
  75812. /**
  75813. * Loader interface with an index field.
  75814. */
  75815. export interface IArrayItem {
  75816. /**
  75817. * The index of this item in the array.
  75818. */
  75819. index: number;
  75820. }
  75821. /**
  75822. * Loader interface with additional members.
  75823. */
  75824. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  75825. /** @hidden */
  75826. _data?: Promise<ArrayBufferView>;
  75827. /** @hidden */
  75828. _babylonVertexBuffer?: Promise<VertexBuffer>;
  75829. }
  75830. /**
  75831. * Loader interface with additional members.
  75832. */
  75833. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  75834. }
  75835. /** @hidden */
  75836. export interface _IAnimationSamplerData {
  75837. input: Float32Array;
  75838. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  75839. output: Float32Array;
  75840. }
  75841. /**
  75842. * Loader interface with additional members.
  75843. */
  75844. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  75845. /** @hidden */
  75846. _data?: Promise<_IAnimationSamplerData>;
  75847. }
  75848. /**
  75849. * Loader interface with additional members.
  75850. */
  75851. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  75852. channels: IAnimationChannel[];
  75853. samplers: IAnimationSampler[];
  75854. /** @hidden */
  75855. _babylonAnimationGroup?: AnimationGroup;
  75856. }
  75857. /**
  75858. * Loader interface with additional members.
  75859. */
  75860. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  75861. /** @hidden */
  75862. _data?: Promise<ArrayBufferView>;
  75863. }
  75864. /**
  75865. * Loader interface with additional members.
  75866. */
  75867. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  75868. /** @hidden */
  75869. _data?: Promise<ArrayBufferView>;
  75870. /** @hidden */
  75871. _babylonBuffer?: Promise<Buffer>;
  75872. }
  75873. /**
  75874. * Loader interface with additional members.
  75875. */
  75876. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  75877. }
  75878. /**
  75879. * Loader interface with additional members.
  75880. */
  75881. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  75882. /** @hidden */
  75883. _data?: Promise<ArrayBufferView>;
  75884. }
  75885. /**
  75886. * Loader interface with additional members.
  75887. */
  75888. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  75889. }
  75890. /**
  75891. * Loader interface with additional members.
  75892. */
  75893. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  75894. }
  75895. /**
  75896. * Loader interface with additional members.
  75897. */
  75898. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  75899. baseColorTexture?: ITextureInfo;
  75900. metallicRoughnessTexture?: ITextureInfo;
  75901. }
  75902. /**
  75903. * Loader interface with additional members.
  75904. */
  75905. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  75906. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  75907. normalTexture?: IMaterialNormalTextureInfo;
  75908. occlusionTexture?: IMaterialOcclusionTextureInfo;
  75909. emissiveTexture?: ITextureInfo;
  75910. /** @hidden */
  75911. _data?: {
  75912. [babylonDrawMode: number]: {
  75913. babylonMaterial: Material;
  75914. babylonMeshes: AbstractMesh[];
  75915. promise: Promise<void>;
  75916. };
  75917. };
  75918. }
  75919. /**
  75920. * Loader interface with additional members.
  75921. */
  75922. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  75923. primitives: IMeshPrimitive[];
  75924. }
  75925. /**
  75926. * Loader interface with additional members.
  75927. */
  75928. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  75929. /** @hidden */
  75930. _instanceData?: {
  75931. babylonSourceMesh: Mesh;
  75932. promise: Promise<any>;
  75933. };
  75934. }
  75935. /**
  75936. * Loader interface with additional members.
  75937. */
  75938. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  75939. /**
  75940. * The parent glTF node.
  75941. */
  75942. parent?: INode;
  75943. /** @hidden */
  75944. _babylonTransformNode?: TransformNode;
  75945. /** @hidden */
  75946. _primitiveBabylonMeshes?: AbstractMesh[];
  75947. /** @hidden */
  75948. _babylonBones?: Bone[];
  75949. /** @hidden */
  75950. _numMorphTargets?: number;
  75951. }
  75952. /** @hidden */
  75953. export interface _ISamplerData {
  75954. noMipMaps: boolean;
  75955. samplingMode: number;
  75956. wrapU: number;
  75957. wrapV: number;
  75958. }
  75959. /**
  75960. * Loader interface with additional members.
  75961. */
  75962. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  75963. /** @hidden */
  75964. _data?: _ISamplerData;
  75965. }
  75966. /**
  75967. * Loader interface with additional members.
  75968. */
  75969. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  75970. }
  75971. /**
  75972. * Loader interface with additional members.
  75973. */
  75974. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  75975. /** @hidden */
  75976. _data?: {
  75977. babylonSkeleton: Skeleton;
  75978. promise: Promise<void>;
  75979. };
  75980. }
  75981. /**
  75982. * Loader interface with additional members.
  75983. */
  75984. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  75985. }
  75986. /**
  75987. * Loader interface with additional members.
  75988. */
  75989. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  75990. }
  75991. /**
  75992. * Loader interface with additional members.
  75993. */
  75994. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  75995. accessors?: IAccessor[];
  75996. animations?: IAnimation[];
  75997. buffers?: IBuffer[];
  75998. bufferViews?: IBufferView[];
  75999. cameras?: ICamera[];
  76000. images?: IImage[];
  76001. materials?: IMaterial[];
  76002. meshes?: IMesh[];
  76003. nodes?: INode[];
  76004. samplers?: ISampler[];
  76005. scenes?: IScene[];
  76006. skins?: ISkin[];
  76007. textures?: ITexture[];
  76008. }
  76009. }
  76010. declare module BABYLON.GLTF2 {
  76011. /**
  76012. * Interface for a glTF loader extension.
  76013. */
  76014. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  76015. /**
  76016. * Called after the loader state changes to LOADING.
  76017. */
  76018. onLoading?(): void;
  76019. /**
  76020. * Called after the loader state changes to READY.
  76021. */
  76022. onReady?(): void;
  76023. /**
  76024. * Define this method to modify the default behavior when loading scenes.
  76025. * @param context The context when loading the asset
  76026. * @param scene The glTF scene property
  76027. * @returns A promise that resolves when the load is complete or null if not handled
  76028. */
  76029. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  76030. /**
  76031. * Define this method to modify the default behavior when loading nodes.
  76032. * @param context The context when loading the asset
  76033. * @param node The glTF node property
  76034. * @param assign A function called synchronously after parsing the glTF properties
  76035. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  76036. */
  76037. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76038. /**
  76039. * Define this method to modify the default behavior when loading cameras.
  76040. * @param context The context when loading the asset
  76041. * @param camera The glTF camera property
  76042. * @param assign A function called synchronously after parsing the glTF properties
  76043. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  76044. */
  76045. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  76046. /**
  76047. * @hidden
  76048. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  76049. * @param context The context when loading the asset
  76050. * @param primitive The glTF mesh primitive property
  76051. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  76052. */
  76053. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  76054. /**
  76055. * @hidden
  76056. * Define this method to modify the default behavior when loading data for mesh primitives.
  76057. * @param context The context when loading the asset
  76058. * @param name The mesh name when loading the asset
  76059. * @param node The glTF node when loading the asset
  76060. * @param mesh The glTF mesh when loading the asset
  76061. * @param primitive The glTF mesh primitive property
  76062. * @param assign A function called synchronously after parsing the glTF properties
  76063. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  76064. */
  76065. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  76066. /**
  76067. * @hidden
  76068. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  76069. * @param context The context when loading the asset
  76070. * @param material The glTF material property
  76071. * @param assign A function called synchronously after parsing the glTF properties
  76072. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  76073. */
  76074. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  76075. /**
  76076. * Define this method to modify the default behavior when creating materials.
  76077. * @param context The context when loading the asset
  76078. * @param material The glTF material property
  76079. * @param babylonDrawMode The draw mode for the Babylon material
  76080. * @returns The Babylon material or null if not handled
  76081. */
  76082. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  76083. /**
  76084. * Define this method to modify the default behavior when loading material properties.
  76085. * @param context The context when loading the asset
  76086. * @param material The glTF material property
  76087. * @param babylonMaterial The Babylon material
  76088. * @returns A promise that resolves when the load is complete or null if not handled
  76089. */
  76090. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76091. /**
  76092. * Define this method to modify the default behavior when loading texture infos.
  76093. * @param context The context when loading the asset
  76094. * @param textureInfo The glTF texture info property
  76095. * @param assign A function called synchronously after parsing the glTF properties
  76096. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  76097. */
  76098. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76099. /**
  76100. * @hidden
  76101. * Define this method to modify the default behavior when loading textures.
  76102. * @param context The context when loading the asset
  76103. * @param texture The glTF texture property
  76104. * @param assign A function called synchronously after parsing the glTF properties
  76105. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  76106. */
  76107. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76108. /**
  76109. * Define this method to modify the default behavior when loading animations.
  76110. * @param context The context when loading the asset
  76111. * @param animation The glTF animation property
  76112. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  76113. */
  76114. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  76115. /**
  76116. * @hidden
  76117. * Define this method to modify the default behavior when loading skins.
  76118. * @param context The context when loading the asset
  76119. * @param node The glTF node property
  76120. * @param skin The glTF skin property
  76121. * @returns A promise that resolves when the load is complete or null if not handled
  76122. */
  76123. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  76124. /**
  76125. * @hidden
  76126. * Define this method to modify the default behavior when loading uris.
  76127. * @param context The context when loading the asset
  76128. * @param property The glTF property associated with the uri
  76129. * @param uri The uri to load
  76130. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76131. */
  76132. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  76133. /**
  76134. * Define this method to modify the default behavior when loading buffer views.
  76135. * @param context The context when loading the asset
  76136. * @param bufferView The glTF buffer view property
  76137. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76138. */
  76139. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  76140. /**
  76141. * Define this method to modify the default behavior when loading buffers.
  76142. * @param context The context when loading the asset
  76143. * @param buffer The glTF buffer property
  76144. * @param byteOffset The byte offset to load
  76145. * @param byteLength The byte length to load
  76146. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76147. */
  76148. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  76149. }
  76150. }
  76151. declare module BABYLON.GLTF2 {
  76152. /**
  76153. * Helper class for working with arrays when loading the glTF asset
  76154. */
  76155. export class ArrayItem {
  76156. /**
  76157. * Gets an item from the given array.
  76158. * @param context The context when loading the asset
  76159. * @param array The array to get the item from
  76160. * @param index The index to the array
  76161. * @returns The array item
  76162. */
  76163. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  76164. /**
  76165. * Assign an `index` field to each item of the given array.
  76166. * @param array The array of items
  76167. */
  76168. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  76169. }
  76170. /**
  76171. * The glTF 2.0 loader
  76172. */
  76173. export class GLTFLoader implements IGLTFLoader {
  76174. /** @hidden */
  76175. _completePromises: Promise<any>[];
  76176. /** @hidden */
  76177. _forAssetContainer: boolean;
  76178. /** Storage */
  76179. _babylonLights: Light[];
  76180. private _disposed;
  76181. private _parent;
  76182. private _state;
  76183. private _extensions;
  76184. private _rootUrl;
  76185. private _fileName;
  76186. private _uniqueRootUrl;
  76187. private _gltf;
  76188. private _bin;
  76189. private _babylonScene;
  76190. private _rootBabylonMesh;
  76191. private _defaultBabylonMaterialData;
  76192. private _progressCallback?;
  76193. private _requests;
  76194. private static _RegisteredExtensions;
  76195. /**
  76196. * The default glTF sampler.
  76197. */
  76198. static readonly DefaultSampler: ISampler;
  76199. /**
  76200. * Registers a loader extension.
  76201. * @param name The name of the loader extension.
  76202. * @param factory The factory function that creates the loader extension.
  76203. */
  76204. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  76205. /**
  76206. * Unregisters a loader extension.
  76207. * @param name The name of the loader extension.
  76208. * @returns A boolean indicating whether the extension has been unregistered
  76209. */
  76210. static UnregisterExtension(name: string): boolean;
  76211. /**
  76212. * The loader state.
  76213. */
  76214. get state(): Nullable<GLTFLoaderState>;
  76215. /**
  76216. * The object that represents the glTF JSON.
  76217. */
  76218. get gltf(): IGLTF;
  76219. /**
  76220. * The BIN chunk of a binary glTF.
  76221. */
  76222. get bin(): Nullable<IDataBuffer>;
  76223. /**
  76224. * The parent file loader.
  76225. */
  76226. get parent(): GLTFFileLoader;
  76227. /**
  76228. * The Babylon scene when loading the asset.
  76229. */
  76230. get babylonScene(): Scene;
  76231. /**
  76232. * The root Babylon mesh when loading the asset.
  76233. */
  76234. get rootBabylonMesh(): Mesh;
  76235. /** @hidden */
  76236. constructor(parent: GLTFFileLoader);
  76237. /** @hidden */
  76238. dispose(): void;
  76239. /** @hidden */
  76240. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  76241. /** @hidden */
  76242. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  76243. private _loadAsync;
  76244. private _loadData;
  76245. private _setupData;
  76246. private _loadExtensions;
  76247. private _checkExtensions;
  76248. private _setState;
  76249. private _createRootNode;
  76250. /**
  76251. * Loads a glTF scene.
  76252. * @param context The context when loading the asset
  76253. * @param scene The glTF scene property
  76254. * @returns A promise that resolves when the load is complete
  76255. */
  76256. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  76257. private _forEachPrimitive;
  76258. private _getMeshes;
  76259. private _getTransformNodes;
  76260. private _getSkeletons;
  76261. private _getAnimationGroups;
  76262. private _startAnimations;
  76263. /**
  76264. * Loads a glTF node.
  76265. * @param context The context when loading the asset
  76266. * @param node The glTF node property
  76267. * @param assign A function called synchronously after parsing the glTF properties
  76268. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  76269. */
  76270. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  76271. private _loadMeshAsync;
  76272. /**
  76273. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  76274. * @param context The context when loading the asset
  76275. * @param name The mesh name when loading the asset
  76276. * @param node The glTF node when loading the asset
  76277. * @param mesh The glTF mesh when loading the asset
  76278. * @param primitive The glTF mesh primitive property
  76279. * @param assign A function called synchronously after parsing the glTF properties
  76280. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  76281. */
  76282. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  76283. private _loadVertexDataAsync;
  76284. private _createMorphTargets;
  76285. private _loadMorphTargetsAsync;
  76286. private _loadMorphTargetVertexDataAsync;
  76287. private static _LoadTransform;
  76288. private _loadSkinAsync;
  76289. private _loadBones;
  76290. private _loadBone;
  76291. private _loadSkinInverseBindMatricesDataAsync;
  76292. private _updateBoneMatrices;
  76293. private _getNodeMatrix;
  76294. /**
  76295. * Loads a glTF camera.
  76296. * @param context The context when loading the asset
  76297. * @param camera The glTF camera property
  76298. * @param assign A function called synchronously after parsing the glTF properties
  76299. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  76300. */
  76301. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  76302. private _loadAnimationsAsync;
  76303. /**
  76304. * Loads a glTF animation.
  76305. * @param context The context when loading the asset
  76306. * @param animation The glTF animation property
  76307. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  76308. */
  76309. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  76310. /**
  76311. * @hidden Loads a glTF animation channel.
  76312. * @param context The context when loading the asset
  76313. * @param animationContext The context of the animation when loading the asset
  76314. * @param animation The glTF animation property
  76315. * @param channel The glTF animation channel property
  76316. * @param babylonAnimationGroup The babylon animation group property
  76317. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  76318. * @returns A void promise when the channel load is complete
  76319. */
  76320. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  76321. private _loadAnimationSamplerAsync;
  76322. private _loadBufferAsync;
  76323. /**
  76324. * Loads a glTF buffer view.
  76325. * @param context The context when loading the asset
  76326. * @param bufferView The glTF buffer view property
  76327. * @returns A promise that resolves with the loaded data when the load is complete
  76328. */
  76329. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  76330. private _loadAccessorAsync;
  76331. /** @hidden */
  76332. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  76333. private _loadIndicesAccessorAsync;
  76334. private _loadVertexBufferViewAsync;
  76335. private _loadVertexAccessorAsync;
  76336. private _loadMaterialMetallicRoughnessPropertiesAsync;
  76337. /** @hidden */
  76338. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  76339. private _createDefaultMaterial;
  76340. /**
  76341. * Creates a Babylon material from a glTF material.
  76342. * @param context The context when loading the asset
  76343. * @param material The glTF material property
  76344. * @param babylonDrawMode The draw mode for the Babylon material
  76345. * @returns The Babylon material
  76346. */
  76347. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  76348. /**
  76349. * Loads properties from a glTF material into a Babylon material.
  76350. * @param context The context when loading the asset
  76351. * @param material The glTF material property
  76352. * @param babylonMaterial The Babylon material
  76353. * @returns A promise that resolves when the load is complete
  76354. */
  76355. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  76356. /**
  76357. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  76358. * @param context The context when loading the asset
  76359. * @param material The glTF material property
  76360. * @param babylonMaterial The Babylon material
  76361. * @returns A promise that resolves when the load is complete
  76362. */
  76363. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  76364. /**
  76365. * Loads the alpha properties from a glTF material into a Babylon material.
  76366. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  76367. * @param context The context when loading the asset
  76368. * @param material The glTF material property
  76369. * @param babylonMaterial The Babylon material
  76370. */
  76371. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  76372. /**
  76373. * Loads a glTF texture info.
  76374. * @param context The context when loading the asset
  76375. * @param textureInfo The glTF texture info property
  76376. * @param assign A function called synchronously after parsing the glTF properties
  76377. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  76378. */
  76379. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76380. /** @hidden */
  76381. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76382. /** @hidden */
  76383. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76384. private _loadSampler;
  76385. /**
  76386. * Loads a glTF image.
  76387. * @param context The context when loading the asset
  76388. * @param image The glTF image property
  76389. * @returns A promise that resolves with the loaded data when the load is complete
  76390. */
  76391. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  76392. /**
  76393. * Loads a glTF uri.
  76394. * @param context The context when loading the asset
  76395. * @param property The glTF property associated with the uri
  76396. * @param uri The base64 or relative uri
  76397. * @returns A promise that resolves with the loaded data when the load is complete
  76398. */
  76399. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  76400. private _onProgress;
  76401. /**
  76402. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  76403. * @param babylonObject the Babylon object with metadata
  76404. * @param pointer the JSON pointer
  76405. */
  76406. static AddPointerMetadata(babylonObject: {
  76407. metadata: any;
  76408. }, pointer: string): void;
  76409. private static _GetTextureWrapMode;
  76410. private static _GetTextureSamplingMode;
  76411. private static _GetTypedArrayConstructor;
  76412. private static _GetTypedArray;
  76413. private static _GetNumComponents;
  76414. private static _ValidateUri;
  76415. private static _GetDrawMode;
  76416. private _compileMaterialsAsync;
  76417. private _compileShadowGeneratorsAsync;
  76418. private _forEachExtensions;
  76419. private _applyExtensions;
  76420. private _extensionsOnLoading;
  76421. private _extensionsOnReady;
  76422. private _extensionsLoadSceneAsync;
  76423. private _extensionsLoadNodeAsync;
  76424. private _extensionsLoadCameraAsync;
  76425. private _extensionsLoadVertexDataAsync;
  76426. private _extensionsLoadMeshPrimitiveAsync;
  76427. private _extensionsLoadMaterialAsync;
  76428. private _extensionsCreateMaterial;
  76429. private _extensionsLoadMaterialPropertiesAsync;
  76430. private _extensionsLoadTextureInfoAsync;
  76431. private _extensionsLoadTextureAsync;
  76432. private _extensionsLoadAnimationAsync;
  76433. private _extensionsLoadSkinAsync;
  76434. private _extensionsLoadUriAsync;
  76435. private _extensionsLoadBufferViewAsync;
  76436. private _extensionsLoadBufferAsync;
  76437. /**
  76438. * Helper method called by a loader extension to load an glTF extension.
  76439. * @param context The context when loading the asset
  76440. * @param property The glTF property to load the extension from
  76441. * @param extensionName The name of the extension to load
  76442. * @param actionAsync The action to run
  76443. * @returns The promise returned by actionAsync or null if the extension does not exist
  76444. */
  76445. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  76446. /**
  76447. * Helper method called by a loader extension to load a glTF extra.
  76448. * @param context The context when loading the asset
  76449. * @param property The glTF property to load the extra from
  76450. * @param extensionName The name of the extension to load
  76451. * @param actionAsync The action to run
  76452. * @returns The promise returned by actionAsync or null if the extra does not exist
  76453. */
  76454. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  76455. /**
  76456. * Checks for presence of an extension.
  76457. * @param name The name of the extension to check
  76458. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  76459. */
  76460. isExtensionUsed(name: string): boolean;
  76461. /**
  76462. * Increments the indentation level and logs a message.
  76463. * @param message The message to log
  76464. */
  76465. logOpen(message: string): void;
  76466. /**
  76467. * Decrements the indentation level.
  76468. */
  76469. logClose(): void;
  76470. /**
  76471. * Logs a message
  76472. * @param message The message to log
  76473. */
  76474. log(message: string): void;
  76475. /**
  76476. * Starts a performance counter.
  76477. * @param counterName The name of the performance counter
  76478. */
  76479. startPerformanceCounter(counterName: string): void;
  76480. /**
  76481. * Ends a performance counter.
  76482. * @param counterName The name of the performance counter
  76483. */
  76484. endPerformanceCounter(counterName: string): void;
  76485. }
  76486. }
  76487. declare module BABYLON.GLTF2.Loader.Extensions {
  76488. /**
  76489. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  76490. */
  76491. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  76492. /**
  76493. * The name of this extension.
  76494. */
  76495. readonly name: string;
  76496. /**
  76497. * Defines whether this extension is enabled.
  76498. */
  76499. enabled: boolean;
  76500. private _loader;
  76501. private _lights?;
  76502. /** @hidden */
  76503. constructor(loader: GLTFLoader);
  76504. /** @hidden */
  76505. dispose(): void;
  76506. /** @hidden */
  76507. onLoading(): void;
  76508. /** @hidden */
  76509. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76510. private _loadLightAsync;
  76511. }
  76512. }
  76513. declare module BABYLON.GLTF2.Loader.Extensions {
  76514. /**
  76515. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  76516. */
  76517. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  76518. /**
  76519. * The name of this extension.
  76520. */
  76521. readonly name: string;
  76522. /**
  76523. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  76524. */
  76525. dracoCompression?: DracoCompression;
  76526. /**
  76527. * Defines whether this extension is enabled.
  76528. */
  76529. enabled: boolean;
  76530. private _loader;
  76531. /** @hidden */
  76532. constructor(loader: GLTFLoader);
  76533. /** @hidden */
  76534. dispose(): void;
  76535. /** @hidden */
  76536. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  76537. }
  76538. }
  76539. declare module BABYLON.GLTF2.Loader.Extensions {
  76540. /**
  76541. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  76542. */
  76543. export class KHR_lights implements IGLTFLoaderExtension {
  76544. /**
  76545. * The name of this extension.
  76546. */
  76547. readonly name: string;
  76548. /**
  76549. * Defines whether this extension is enabled.
  76550. */
  76551. enabled: boolean;
  76552. private _loader;
  76553. private _lights?;
  76554. /** @hidden */
  76555. constructor(loader: GLTFLoader);
  76556. /** @hidden */
  76557. dispose(): void;
  76558. /** @hidden */
  76559. onLoading(): void;
  76560. /** @hidden */
  76561. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76562. }
  76563. }
  76564. declare module BABYLON.GLTF2.Loader.Extensions {
  76565. /**
  76566. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  76567. */
  76568. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  76569. /**
  76570. * The name of this extension.
  76571. */
  76572. readonly name: string;
  76573. /**
  76574. * Defines whether this extension is enabled.
  76575. */
  76576. enabled: boolean;
  76577. /**
  76578. * Defines a number that determines the order the extensions are applied.
  76579. */
  76580. order: number;
  76581. private _loader;
  76582. /** @hidden */
  76583. constructor(loader: GLTFLoader);
  76584. /** @hidden */
  76585. dispose(): void;
  76586. /** @hidden */
  76587. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76588. private _loadSpecularGlossinessPropertiesAsync;
  76589. }
  76590. }
  76591. declare module BABYLON.GLTF2.Loader.Extensions {
  76592. /**
  76593. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  76594. */
  76595. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  76596. /**
  76597. * The name of this extension.
  76598. */
  76599. readonly name: string;
  76600. /**
  76601. * Defines whether this extension is enabled.
  76602. */
  76603. enabled: boolean;
  76604. /**
  76605. * Defines a number that determines the order the extensions are applied.
  76606. */
  76607. order: number;
  76608. private _loader;
  76609. /** @hidden */
  76610. constructor(loader: GLTFLoader);
  76611. /** @hidden */
  76612. dispose(): void;
  76613. /** @hidden */
  76614. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76615. private _loadUnlitPropertiesAsync;
  76616. }
  76617. }
  76618. declare module BABYLON.GLTF2.Loader.Extensions {
  76619. /**
  76620. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  76621. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  76622. * !!! Experimental Extension Subject to Changes !!!
  76623. */
  76624. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  76625. /**
  76626. * The name of this extension.
  76627. */
  76628. readonly name: string;
  76629. /**
  76630. * Defines whether this extension is enabled.
  76631. */
  76632. enabled: boolean;
  76633. /**
  76634. * Defines a number that determines the order the extensions are applied.
  76635. */
  76636. order: number;
  76637. private _loader;
  76638. /** @hidden */
  76639. constructor(loader: GLTFLoader);
  76640. /** @hidden */
  76641. dispose(): void;
  76642. /** @hidden */
  76643. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76644. private _loadClearCoatPropertiesAsync;
  76645. }
  76646. }
  76647. declare module BABYLON.GLTF2.Loader.Extensions {
  76648. /**
  76649. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  76650. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  76651. * !!! Experimental Extension Subject to Changes !!!
  76652. */
  76653. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  76654. /**
  76655. * The name of this extension.
  76656. */
  76657. readonly name: string;
  76658. /**
  76659. * Defines whether this extension is enabled.
  76660. */
  76661. enabled: boolean;
  76662. /**
  76663. * Defines a number that determines the order the extensions are applied.
  76664. */
  76665. order: number;
  76666. private _loader;
  76667. /** @hidden */
  76668. constructor(loader: GLTFLoader);
  76669. /** @hidden */
  76670. dispose(): void;
  76671. /** @hidden */
  76672. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76673. private _loadSheenPropertiesAsync;
  76674. }
  76675. }
  76676. declare module BABYLON.GLTF2.Loader.Extensions {
  76677. /**
  76678. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  76679. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  76680. * !!! Experimental Extension Subject to Changes !!!
  76681. */
  76682. export class KHR_materials_specular implements IGLTFLoaderExtension {
  76683. /**
  76684. * The name of this extension.
  76685. */
  76686. readonly name: string;
  76687. /**
  76688. * Defines whether this extension is enabled.
  76689. */
  76690. enabled: boolean;
  76691. /**
  76692. * Defines a number that determines the order the extensions are applied.
  76693. */
  76694. order: number;
  76695. private _loader;
  76696. /** @hidden */
  76697. constructor(loader: GLTFLoader);
  76698. /** @hidden */
  76699. dispose(): void;
  76700. /** @hidden */
  76701. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76702. private _loadSpecularPropertiesAsync;
  76703. }
  76704. }
  76705. declare module BABYLON.GLTF2.Loader.Extensions {
  76706. /**
  76707. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  76708. * [Playground Sample](//TODO)
  76709. * !!! Experimental Extension Subject to Changes !!!
  76710. */
  76711. export class KHR_mesh_instancing implements IGLTFLoaderExtension {
  76712. /**
  76713. * The name of this extension.
  76714. */
  76715. readonly name: string;
  76716. /**
  76717. * Defines whether this extension is enabled.
  76718. */
  76719. enabled: boolean;
  76720. private _loader;
  76721. /** @hidden */
  76722. constructor(loader: GLTFLoader);
  76723. /** @hidden */
  76724. dispose(): void;
  76725. /** @hidden */
  76726. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76727. }
  76728. }
  76729. declare module BABYLON.GLTF2.Loader.Extensions {
  76730. /**
  76731. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  76732. */
  76733. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  76734. /**
  76735. * The name of this extension.
  76736. */
  76737. readonly name: string;
  76738. /**
  76739. * Defines whether this extension is enabled.
  76740. */
  76741. enabled: boolean;
  76742. /** @hidden */
  76743. constructor(loader: GLTFLoader);
  76744. /** @hidden */
  76745. dispose(): void;
  76746. }
  76747. }
  76748. declare module BABYLON.GLTF2.Loader.Extensions {
  76749. /**
  76750. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  76751. * !!! Experimental Extension Subject to Changes !!!
  76752. */
  76753. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  76754. /** The name of this extension. */
  76755. readonly name: string;
  76756. /** Defines whether this extension is enabled. */
  76757. enabled: boolean;
  76758. private _loader;
  76759. /** @hidden */
  76760. constructor(loader: GLTFLoader);
  76761. /** @hidden */
  76762. dispose(): void;
  76763. /** @hidden */
  76764. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76765. }
  76766. }
  76767. declare module BABYLON.GLTF2.Loader.Extensions {
  76768. /**
  76769. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  76770. */
  76771. export class KHR_texture_transform implements IGLTFLoaderExtension {
  76772. /**
  76773. * The name of this extension.
  76774. */
  76775. readonly name: string;
  76776. /**
  76777. * Defines whether this extension is enabled.
  76778. */
  76779. enabled: boolean;
  76780. private _loader;
  76781. /** @hidden */
  76782. constructor(loader: GLTFLoader);
  76783. /** @hidden */
  76784. dispose(): void;
  76785. /** @hidden */
  76786. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76787. }
  76788. }
  76789. declare module BABYLON.GLTF2.Loader.Extensions {
  76790. /**
  76791. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  76792. */
  76793. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  76794. /**
  76795. * The name of this extension.
  76796. */
  76797. readonly name: string;
  76798. /**
  76799. * Defines whether this extension is enabled.
  76800. */
  76801. enabled: boolean;
  76802. private _loader;
  76803. private _clips;
  76804. private _emitters;
  76805. /** @hidden */
  76806. constructor(loader: GLTFLoader);
  76807. /** @hidden */
  76808. dispose(): void;
  76809. /** @hidden */
  76810. onLoading(): void;
  76811. /** @hidden */
  76812. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76813. /** @hidden */
  76814. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76815. /** @hidden */
  76816. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  76817. private _loadClipAsync;
  76818. private _loadEmitterAsync;
  76819. private _getEventAction;
  76820. private _loadAnimationEventAsync;
  76821. }
  76822. }
  76823. declare module BABYLON.GLTF2.Loader.Extensions {
  76824. /**
  76825. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  76826. */
  76827. export class MSFT_lod implements IGLTFLoaderExtension {
  76828. /**
  76829. * The name of this extension.
  76830. */
  76831. readonly name: string;
  76832. /**
  76833. * Defines whether this extension is enabled.
  76834. */
  76835. enabled: boolean;
  76836. /**
  76837. * Defines a number that determines the order the extensions are applied.
  76838. */
  76839. order: number;
  76840. /**
  76841. * Maximum number of LODs to load, starting from the lowest LOD.
  76842. */
  76843. maxLODsToLoad: number;
  76844. /**
  76845. * Observable raised when all node LODs of one level are loaded.
  76846. * The event data is the index of the loaded LOD starting from zero.
  76847. * Dispose the loader to cancel the loading of the next level of LODs.
  76848. */
  76849. onNodeLODsLoadedObservable: Observable<number>;
  76850. /**
  76851. * Observable raised when all material LODs of one level are loaded.
  76852. * The event data is the index of the loaded LOD starting from zero.
  76853. * Dispose the loader to cancel the loading of the next level of LODs.
  76854. */
  76855. onMaterialLODsLoadedObservable: Observable<number>;
  76856. private _loader;
  76857. private _nodeIndexLOD;
  76858. private _nodeSignalLODs;
  76859. private _nodePromiseLODs;
  76860. private _materialIndexLOD;
  76861. private _materialSignalLODs;
  76862. private _materialPromiseLODs;
  76863. private _indexLOD;
  76864. private _bufferLODs;
  76865. /** @hidden */
  76866. constructor(loader: GLTFLoader);
  76867. /** @hidden */
  76868. dispose(): void;
  76869. /** @hidden */
  76870. onReady(): void;
  76871. /** @hidden */
  76872. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76873. /** @hidden */
  76874. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76875. /** @hidden */
  76876. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  76877. /** @hidden */
  76878. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  76879. /** @hidden */
  76880. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  76881. private _loadBufferLOD;
  76882. /**
  76883. * Gets an array of LOD properties from lowest to highest.
  76884. */
  76885. private _getLODs;
  76886. private _disposeTransformNode;
  76887. private _disposeMaterials;
  76888. }
  76889. }
  76890. declare module BABYLON.GLTF2.Loader.Extensions {
  76891. /** @hidden */
  76892. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  76893. readonly name: string;
  76894. enabled: boolean;
  76895. private _loader;
  76896. constructor(loader: GLTFLoader);
  76897. dispose(): void;
  76898. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76899. }
  76900. }
  76901. declare module BABYLON.GLTF2.Loader.Extensions {
  76902. /** @hidden */
  76903. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  76904. readonly name: string;
  76905. enabled: boolean;
  76906. private _loader;
  76907. constructor(loader: GLTFLoader);
  76908. dispose(): void;
  76909. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76910. }
  76911. }
  76912. declare module BABYLON.GLTF2.Loader.Extensions {
  76913. /**
  76914. * Store glTF extras (if present) in BJS objects' metadata
  76915. */
  76916. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  76917. /**
  76918. * The name of this extension.
  76919. */
  76920. readonly name: string;
  76921. /**
  76922. * Defines whether this extension is enabled.
  76923. */
  76924. enabled: boolean;
  76925. private _loader;
  76926. private _assignExtras;
  76927. /** @hidden */
  76928. constructor(loader: GLTFLoader);
  76929. /** @hidden */
  76930. dispose(): void;
  76931. /** @hidden */
  76932. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76933. /** @hidden */
  76934. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  76935. /** @hidden */
  76936. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  76937. }
  76938. }
  76939. declare module BABYLON {
  76940. /**
  76941. * Class reading and parsing the MTL file bundled with the obj file.
  76942. */
  76943. export class MTLFileLoader {
  76944. /**
  76945. * Invert Y-Axis of referenced textures on load
  76946. */
  76947. static INVERT_TEXTURE_Y: boolean;
  76948. /**
  76949. * All material loaded from the mtl will be set here
  76950. */
  76951. materials: StandardMaterial[];
  76952. /**
  76953. * This function will read the mtl file and create each material described inside
  76954. * This function could be improve by adding :
  76955. * -some component missing (Ni, Tf...)
  76956. * -including the specific options available
  76957. *
  76958. * @param scene defines the scene the material will be created in
  76959. * @param data defines the mtl data to parse
  76960. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  76961. * @param forAssetContainer defines if the material should be registered in the scene
  76962. */
  76963. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  76964. /**
  76965. * Gets the texture for the material.
  76966. *
  76967. * If the material is imported from input file,
  76968. * We sanitize the url to ensure it takes the textre from aside the material.
  76969. *
  76970. * @param rootUrl The root url to load from
  76971. * @param value The value stored in the mtl
  76972. * @return The Texture
  76973. */
  76974. private static _getTexture;
  76975. }
  76976. }
  76977. declare module BABYLON {
  76978. /**
  76979. * Options for loading OBJ/MTL files
  76980. */
  76981. type MeshLoadOptions = {
  76982. /**
  76983. * Defines if UVs are optimized by default during load.
  76984. */
  76985. OptimizeWithUV: boolean;
  76986. /**
  76987. * Defines custom scaling of UV coordinates of loaded meshes.
  76988. */
  76989. UVScaling: Vector2;
  76990. /**
  76991. * Invert model on y-axis (does a model scaling inversion)
  76992. */
  76993. InvertY: boolean;
  76994. /**
  76995. * Invert Y-Axis of referenced textures on load
  76996. */
  76997. InvertTextureY: boolean;
  76998. /**
  76999. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  77000. */
  77001. ImportVertexColors: boolean;
  77002. /**
  77003. * Compute the normals for the model, even if normals are present in the file.
  77004. */
  77005. ComputeNormals: boolean;
  77006. /**
  77007. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  77008. */
  77009. SkipMaterials: boolean;
  77010. /**
  77011. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  77012. */
  77013. MaterialLoadingFailsSilently: boolean;
  77014. };
  77015. /**
  77016. * OBJ file type loader.
  77017. * This is a babylon scene loader plugin.
  77018. */
  77019. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  77020. /**
  77021. * Defines if UVs are optimized by default during load.
  77022. */
  77023. static OPTIMIZE_WITH_UV: boolean;
  77024. /**
  77025. * Invert model on y-axis (does a model scaling inversion)
  77026. */
  77027. static INVERT_Y: boolean;
  77028. /**
  77029. * Invert Y-Axis of referenced textures on load
  77030. */
  77031. static get INVERT_TEXTURE_Y(): boolean;
  77032. static set INVERT_TEXTURE_Y(value: boolean);
  77033. /**
  77034. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  77035. */
  77036. static IMPORT_VERTEX_COLORS: boolean;
  77037. /**
  77038. * Compute the normals for the model, even if normals are present in the file.
  77039. */
  77040. static COMPUTE_NORMALS: boolean;
  77041. /**
  77042. * Defines custom scaling of UV coordinates of loaded meshes.
  77043. */
  77044. static UV_SCALING: Vector2;
  77045. /**
  77046. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  77047. */
  77048. static SKIP_MATERIALS: boolean;
  77049. /**
  77050. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  77051. *
  77052. * Defaults to true for backwards compatibility.
  77053. */
  77054. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  77055. /**
  77056. * Defines the name of the plugin.
  77057. */
  77058. name: string;
  77059. /**
  77060. * Defines the extension the plugin is able to load.
  77061. */
  77062. extensions: string;
  77063. /** @hidden */
  77064. obj: RegExp;
  77065. /** @hidden */
  77066. group: RegExp;
  77067. /** @hidden */
  77068. mtllib: RegExp;
  77069. /** @hidden */
  77070. usemtl: RegExp;
  77071. /** @hidden */
  77072. smooth: RegExp;
  77073. /** @hidden */
  77074. vertexPattern: RegExp;
  77075. /** @hidden */
  77076. normalPattern: RegExp;
  77077. /** @hidden */
  77078. uvPattern: RegExp;
  77079. /** @hidden */
  77080. facePattern1: RegExp;
  77081. /** @hidden */
  77082. facePattern2: RegExp;
  77083. /** @hidden */
  77084. facePattern3: RegExp;
  77085. /** @hidden */
  77086. facePattern4: RegExp;
  77087. /** @hidden */
  77088. facePattern5: RegExp;
  77089. private _forAssetContainer;
  77090. private _meshLoadOptions;
  77091. /**
  77092. * Creates loader for .OBJ files
  77093. *
  77094. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  77095. */
  77096. constructor(meshLoadOptions?: MeshLoadOptions);
  77097. private static get currentMeshLoadOptions();
  77098. /**
  77099. * Calls synchronously the MTL file attached to this obj.
  77100. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  77101. * Without this function materials are not displayed in the first frame (but displayed after).
  77102. * In consequence it is impossible to get material information in your HTML file
  77103. *
  77104. * @param url The URL of the MTL file
  77105. * @param rootUrl
  77106. * @param onSuccess Callback function to be called when the MTL file is loaded
  77107. * @private
  77108. */
  77109. private _loadMTL;
  77110. /**
  77111. * Instantiates a OBJ file loader plugin.
  77112. * @returns the created plugin
  77113. */
  77114. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  77115. /**
  77116. * If the data string can be loaded directly.
  77117. *
  77118. * @param data string containing the file data
  77119. * @returns if the data can be loaded directly
  77120. */
  77121. canDirectLoad(data: string): boolean;
  77122. /**
  77123. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  77124. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  77125. * @param scene the scene the meshes should be added to
  77126. * @param data the OBJ data to load
  77127. * @param rootUrl root url to load from
  77128. * @param onProgress event that fires when loading progress has occured
  77129. * @param fileName Defines the name of the file to load
  77130. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  77131. */
  77132. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  77133. meshes: AbstractMesh[];
  77134. particleSystems: IParticleSystem[];
  77135. skeletons: Skeleton[];
  77136. animationGroups: AnimationGroup[];
  77137. }>;
  77138. /**
  77139. * Imports all objects from the loaded OBJ data and adds them to the scene
  77140. * @param scene the scene the objects should be added to
  77141. * @param data the OBJ data to load
  77142. * @param rootUrl root url to load from
  77143. * @param onProgress event that fires when loading progress has occured
  77144. * @param fileName Defines the name of the file to load
  77145. * @returns a promise which completes when objects have been loaded to the scene
  77146. */
  77147. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  77148. /**
  77149. * Load into an asset container.
  77150. * @param scene The scene to load into
  77151. * @param data The data to import
  77152. * @param rootUrl The root url for scene and resources
  77153. * @param onProgress The callback when the load progresses
  77154. * @param fileName Defines the name of the file to load
  77155. * @returns The loaded asset container
  77156. */
  77157. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  77158. /**
  77159. * Read the OBJ file and create an Array of meshes.
  77160. * Each mesh contains all information given by the OBJ and the MTL file.
  77161. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  77162. *
  77163. * @param meshesNames
  77164. * @param scene Scene The scene where are displayed the data
  77165. * @param data String The content of the obj file
  77166. * @param rootUrl String The path to the folder
  77167. * @returns Array<AbstractMesh>
  77168. * @private
  77169. */
  77170. private _parseSolid;
  77171. }
  77172. }
  77173. declare module BABYLON {
  77174. /**
  77175. * STL file type loader.
  77176. * This is a babylon scene loader plugin.
  77177. */
  77178. export class STLFileLoader implements ISceneLoaderPlugin {
  77179. /** @hidden */
  77180. solidPattern: RegExp;
  77181. /** @hidden */
  77182. facetsPattern: RegExp;
  77183. /** @hidden */
  77184. normalPattern: RegExp;
  77185. /** @hidden */
  77186. vertexPattern: RegExp;
  77187. /**
  77188. * Defines the name of the plugin.
  77189. */
  77190. name: string;
  77191. /**
  77192. * Defines the extensions the stl loader is able to load.
  77193. * force data to come in as an ArrayBuffer
  77194. * we'll convert to string if it looks like it's an ASCII .stl
  77195. */
  77196. extensions: ISceneLoaderPluginExtensions;
  77197. /**
  77198. * Import meshes into a scene.
  77199. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  77200. * @param scene The scene to import into
  77201. * @param data The data to import
  77202. * @param rootUrl The root url for scene and resources
  77203. * @param meshes The meshes array to import into
  77204. * @param particleSystems The particle systems array to import into
  77205. * @param skeletons The skeletons array to import into
  77206. * @param onError The callback when import fails
  77207. * @returns True if successful or false otherwise
  77208. */
  77209. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  77210. /**
  77211. * Load into a scene.
  77212. * @param scene The scene to load into
  77213. * @param data The data to import
  77214. * @param rootUrl The root url for scene and resources
  77215. * @param onError The callback when import fails
  77216. * @returns true if successful or false otherwise
  77217. */
  77218. load(scene: Scene, data: any, rootUrl: string): boolean;
  77219. /**
  77220. * Load into an asset container.
  77221. * @param scene The scene to load into
  77222. * @param data The data to import
  77223. * @param rootUrl The root url for scene and resources
  77224. * @param onError The callback when import fails
  77225. * @returns The loaded asset container
  77226. */
  77227. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  77228. private _isBinary;
  77229. private _parseBinary;
  77230. private _parseASCII;
  77231. }
  77232. }
  77233. declare module BABYLON {
  77234. /**
  77235. * Class for generating OBJ data from a Babylon scene.
  77236. */
  77237. export class OBJExport {
  77238. /**
  77239. * Exports the geometry of a Mesh array in .OBJ file format (text)
  77240. * @param mesh defines the list of meshes to serialize
  77241. * @param materials defines if materials should be exported
  77242. * @param matlibname defines the name of the associated mtl file
  77243. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  77244. * @returns the OBJ content
  77245. */
  77246. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  77247. /**
  77248. * Exports the material(s) of a mesh in .MTL file format (text)
  77249. * @param mesh defines the mesh to extract the material from
  77250. * @returns the mtl content
  77251. */
  77252. static MTL(mesh: Mesh): string;
  77253. }
  77254. }
  77255. declare module BABYLON {
  77256. /** @hidden */
  77257. export var __IGLTFExporterExtension: number;
  77258. /**
  77259. * Interface for extending the exporter
  77260. * @hidden
  77261. */
  77262. export interface IGLTFExporterExtension {
  77263. /**
  77264. * The name of this extension
  77265. */
  77266. readonly name: string;
  77267. /**
  77268. * Defines whether this extension is enabled
  77269. */
  77270. enabled: boolean;
  77271. /**
  77272. * Defines whether this extension is required
  77273. */
  77274. required: boolean;
  77275. }
  77276. }
  77277. declare module BABYLON.GLTF2.Exporter {
  77278. /** @hidden */
  77279. export var __IGLTFExporterExtensionV2: number;
  77280. /**
  77281. * Interface for a glTF exporter extension
  77282. * @hidden
  77283. */
  77284. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  77285. /**
  77286. * Define this method to modify the default behavior before exporting a texture
  77287. * @param context The context when loading the asset
  77288. * @param babylonTexture The Babylon.js texture
  77289. * @param mimeType The mime-type of the generated image
  77290. * @returns A promise that resolves with the exported texture
  77291. */
  77292. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  77293. /**
  77294. * Define this method to get notified when a texture info is created
  77295. * @param context The context when loading the asset
  77296. * @param textureInfo The glTF texture info
  77297. * @param babylonTexture The Babylon.js texture
  77298. */
  77299. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  77300. /**
  77301. * Define this method to modify the default behavior when exporting texture info
  77302. * @param context The context when loading the asset
  77303. * @param meshPrimitive glTF mesh primitive
  77304. * @param babylonSubMesh Babylon submesh
  77305. * @param binaryWriter glTF serializer binary writer instance
  77306. * @returns nullable IMeshPrimitive promise
  77307. */
  77308. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  77309. /**
  77310. * Define this method to modify the default behavior when exporting a node
  77311. * @param context The context when exporting the node
  77312. * @param node glTF node
  77313. * @param babylonNode BabylonJS node
  77314. * @returns nullable INode promise
  77315. */
  77316. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  77317. [key: number]: number;
  77318. }): Promise<Nullable<INode>>;
  77319. /**
  77320. * Define this method to modify the default behavior when exporting a material
  77321. * @param material glTF material
  77322. * @param babylonMaterial BabylonJS material
  77323. * @returns nullable IMaterial promise
  77324. */
  77325. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  77326. /**
  77327. * Define this method to return additional textures to export from a material
  77328. * @param material glTF material
  77329. * @param babylonMaterial BabylonJS material
  77330. * @returns List of textures
  77331. */
  77332. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  77333. /** Gets a boolean indicating that this extension was used */
  77334. wasUsed: boolean;
  77335. /** Gets a boolean indicating that this extension is required for the file to work */
  77336. required: boolean;
  77337. /**
  77338. * Called after the exporter state changes to EXPORTING
  77339. */
  77340. onExporting?(): void;
  77341. }
  77342. }
  77343. declare module BABYLON.GLTF2.Exporter {
  77344. /**
  77345. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  77346. * @hidden
  77347. */
  77348. export class _GLTFMaterialExporter {
  77349. /**
  77350. * Represents the dielectric specular values for R, G and B
  77351. */
  77352. private static readonly _DielectricSpecular;
  77353. /**
  77354. * Allows the maximum specular power to be defined for material calculations
  77355. */
  77356. private static readonly _MaxSpecularPower;
  77357. /**
  77358. * Mapping to store textures
  77359. */
  77360. private _textureMap;
  77361. /**
  77362. * Numeric tolerance value
  77363. */
  77364. private static readonly _Epsilon;
  77365. /**
  77366. * Reference to the glTF Exporter
  77367. */
  77368. private _exporter;
  77369. constructor(exporter: _Exporter);
  77370. /**
  77371. * Specifies if two colors are approximately equal in value
  77372. * @param color1 first color to compare to
  77373. * @param color2 second color to compare to
  77374. * @param epsilon threshold value
  77375. */
  77376. private static FuzzyEquals;
  77377. /**
  77378. * Gets the materials from a Babylon scene and converts them to glTF materials
  77379. * @param scene babylonjs scene
  77380. * @param mimeType texture mime type
  77381. * @param images array of images
  77382. * @param textures array of textures
  77383. * @param materials array of materials
  77384. * @param imageData mapping of texture names to base64 textures
  77385. * @param hasTextureCoords specifies if texture coordinates are present on the material
  77386. */
  77387. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  77388. /**
  77389. * Makes a copy of the glTF material without the texture parameters
  77390. * @param originalMaterial original glTF material
  77391. * @returns glTF material without texture parameters
  77392. */
  77393. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  77394. /**
  77395. * Specifies if the material has any texture parameters present
  77396. * @param material glTF Material
  77397. * @returns boolean specifying if texture parameters are present
  77398. */
  77399. _hasTexturesPresent(material: IMaterial): boolean;
  77400. /**
  77401. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  77402. * @param babylonStandardMaterial
  77403. * @returns glTF Metallic Roughness Material representation
  77404. */
  77405. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  77406. /**
  77407. * Computes the metallic factor
  77408. * @param diffuse diffused value
  77409. * @param specular specular value
  77410. * @param oneMinusSpecularStrength one minus the specular strength
  77411. * @returns metallic value
  77412. */
  77413. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  77414. /**
  77415. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  77416. * @param glTFMaterial glTF material
  77417. * @param babylonMaterial Babylon material
  77418. */
  77419. private static _SetAlphaMode;
  77420. /**
  77421. * Converts a Babylon Standard Material to a glTF Material
  77422. * @param babylonStandardMaterial BJS Standard Material
  77423. * @param mimeType mime type to use for the textures
  77424. * @param images array of glTF image interfaces
  77425. * @param textures array of glTF texture interfaces
  77426. * @param materials array of glTF material interfaces
  77427. * @param imageData map of image file name to data
  77428. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77429. */
  77430. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77431. private _finishMaterial;
  77432. /**
  77433. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  77434. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  77435. * @param mimeType mime type to use for the textures
  77436. * @param images array of glTF image interfaces
  77437. * @param textures array of glTF texture interfaces
  77438. * @param materials array of glTF material interfaces
  77439. * @param imageData map of image file name to data
  77440. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77441. */
  77442. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77443. /**
  77444. * Converts an image typed array buffer to a base64 image
  77445. * @param buffer typed array buffer
  77446. * @param width width of the image
  77447. * @param height height of the image
  77448. * @param mimeType mimetype of the image
  77449. * @returns base64 image string
  77450. */
  77451. private _createBase64FromCanvasAsync;
  77452. /**
  77453. * Generates a white texture based on the specified width and height
  77454. * @param width width of the texture in pixels
  77455. * @param height height of the texture in pixels
  77456. * @param scene babylonjs scene
  77457. * @returns white texture
  77458. */
  77459. private _createWhiteTexture;
  77460. /**
  77461. * 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
  77462. * @param texture1 first texture to resize
  77463. * @param texture2 second texture to resize
  77464. * @param scene babylonjs scene
  77465. * @returns resized textures or null
  77466. */
  77467. private _resizeTexturesToSameDimensions;
  77468. /**
  77469. * Converts an array of pixels to a Float32Array
  77470. * Throws an error if the pixel format is not supported
  77471. * @param pixels - array buffer containing pixel values
  77472. * @returns Float32 of pixels
  77473. */
  77474. private _convertPixelArrayToFloat32;
  77475. /**
  77476. * Convert Specular Glossiness Textures to Metallic Roughness
  77477. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  77478. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  77479. * @param diffuseTexture texture used to store diffuse information
  77480. * @param specularGlossinessTexture texture used to store specular and glossiness information
  77481. * @param factors specular glossiness material factors
  77482. * @param mimeType the mime type to use for the texture
  77483. * @returns pbr metallic roughness interface or null
  77484. */
  77485. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  77486. /**
  77487. * Converts specular glossiness material properties to metallic roughness
  77488. * @param specularGlossiness interface with specular glossiness material properties
  77489. * @returns interface with metallic roughness material properties
  77490. */
  77491. private _convertSpecularGlossinessToMetallicRoughness;
  77492. /**
  77493. * Calculates the surface reflectance, independent of lighting conditions
  77494. * @param color Color source to calculate brightness from
  77495. * @returns number representing the perceived brightness, or zero if color is undefined
  77496. */
  77497. private _getPerceivedBrightness;
  77498. /**
  77499. * Returns the maximum color component value
  77500. * @param color
  77501. * @returns maximum color component value, or zero if color is null or undefined
  77502. */
  77503. private _getMaxComponent;
  77504. /**
  77505. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  77506. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77507. * @param mimeType mime type to use for the textures
  77508. * @param images array of glTF image interfaces
  77509. * @param textures array of glTF texture interfaces
  77510. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  77511. * @param imageData map of image file name to data
  77512. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77513. * @returns glTF PBR Metallic Roughness factors
  77514. */
  77515. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  77516. private _getGLTFTextureSampler;
  77517. private _getGLTFTextureWrapMode;
  77518. private _getGLTFTextureWrapModesSampler;
  77519. /**
  77520. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  77521. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77522. * @param mimeType mime type to use for the textures
  77523. * @param images array of glTF image interfaces
  77524. * @param textures array of glTF texture interfaces
  77525. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  77526. * @param imageData map of image file name to data
  77527. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77528. * @returns glTF PBR Metallic Roughness factors
  77529. */
  77530. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  77531. /**
  77532. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  77533. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77534. * @param mimeType mime type to use for the textures
  77535. * @param images array of glTF image interfaces
  77536. * @param textures array of glTF texture interfaces
  77537. * @param materials array of glTF material interfaces
  77538. * @param imageData map of image file name to data
  77539. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77540. */
  77541. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77542. private setMetallicRoughnessPbrMaterial;
  77543. private getPixelsFromTexture;
  77544. /**
  77545. * Extracts a texture from a Babylon texture into file data and glTF data
  77546. * @param babylonTexture Babylon texture to extract
  77547. * @param mimeType Mime Type of the babylonTexture
  77548. * @return glTF texture info, or null if the texture format is not supported
  77549. */
  77550. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  77551. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  77552. /**
  77553. * Builds a texture from base64 string
  77554. * @param base64Texture base64 texture string
  77555. * @param baseTextureName Name to use for the texture
  77556. * @param mimeType image mime type for the texture
  77557. * @param images array of images
  77558. * @param textures array of textures
  77559. * @param imageData map of image data
  77560. * @returns glTF texture info, or null if the texture format is not supported
  77561. */
  77562. private _getTextureInfoFromBase64;
  77563. }
  77564. }
  77565. declare module BABYLON {
  77566. /**
  77567. * Class for holding and downloading glTF file data
  77568. */
  77569. export class GLTFData {
  77570. /**
  77571. * Object which contains the file name as the key and its data as the value
  77572. */
  77573. glTFFiles: {
  77574. [fileName: string]: string | Blob;
  77575. };
  77576. /**
  77577. * Initializes the glTF file object
  77578. */
  77579. constructor();
  77580. /**
  77581. * Downloads the glTF data as files based on their names and data
  77582. */
  77583. downloadFiles(): void;
  77584. }
  77585. }
  77586. declare module BABYLON {
  77587. /**
  77588. * Holds a collection of exporter options and parameters
  77589. */
  77590. export interface IExportOptions {
  77591. /**
  77592. * Function which indicates whether a babylon node should be exported or not
  77593. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  77594. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  77595. */
  77596. shouldExportNode?(node: Node): boolean;
  77597. /**
  77598. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  77599. * @param metadata source metadata to read from
  77600. * @returns the data to store to glTF node extras
  77601. */
  77602. metadataSelector?(metadata: any): any;
  77603. /**
  77604. * The sample rate to bake animation curves
  77605. */
  77606. animationSampleRate?: number;
  77607. /**
  77608. * Begin serialization without waiting for the scene to be ready
  77609. */
  77610. exportWithoutWaitingForScene?: boolean;
  77611. /**
  77612. * Indicates if coordinate system swapping root nodes should be included in export
  77613. */
  77614. includeCoordinateSystemConversionNodes?: boolean;
  77615. }
  77616. /**
  77617. * Class for generating glTF data from a Babylon scene.
  77618. */
  77619. export class GLTF2Export {
  77620. /**
  77621. * Exports the geometry of the scene to .gltf file format asynchronously
  77622. * @param scene Babylon scene with scene hierarchy information
  77623. * @param filePrefix File prefix to use when generating the glTF file
  77624. * @param options Exporter options
  77625. * @returns Returns an object with a .gltf file and associates texture names
  77626. * as keys and their data and paths as values
  77627. */
  77628. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  77629. private static _PreExportAsync;
  77630. private static _PostExportAsync;
  77631. /**
  77632. * Exports the geometry of the scene to .glb file format asychronously
  77633. * @param scene Babylon scene with scene hierarchy information
  77634. * @param filePrefix File prefix to use when generating glb file
  77635. * @param options Exporter options
  77636. * @returns Returns an object with a .glb filename as key and data as value
  77637. */
  77638. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  77639. }
  77640. }
  77641. declare module BABYLON.GLTF2.Exporter {
  77642. /**
  77643. * @hidden
  77644. */
  77645. export class _GLTFUtilities {
  77646. /**
  77647. * Creates a buffer view based on the supplied arguments
  77648. * @param bufferIndex index value of the specified buffer
  77649. * @param byteOffset byte offset value
  77650. * @param byteLength byte length of the bufferView
  77651. * @param byteStride byte distance between conequential elements
  77652. * @param name name of the buffer view
  77653. * @returns bufferView for glTF
  77654. */
  77655. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  77656. /**
  77657. * Creates an accessor based on the supplied arguments
  77658. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  77659. * @param name The name of the accessor
  77660. * @param type The type of the accessor
  77661. * @param componentType The datatype of components in the attribute
  77662. * @param count The number of attributes referenced by this accessor
  77663. * @param byteOffset The offset relative to the start of the bufferView in bytes
  77664. * @param min Minimum value of each component in this attribute
  77665. * @param max Maximum value of each component in this attribute
  77666. * @returns accessor for glTF
  77667. */
  77668. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  77669. /**
  77670. * Calculates the minimum and maximum values of an array of position floats
  77671. * @param positions Positions array of a mesh
  77672. * @param vertexStart Starting vertex offset to calculate min and max values
  77673. * @param vertexCount Number of vertices to check for min and max values
  77674. * @returns min number array and max number array
  77675. */
  77676. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  77677. min: number[];
  77678. max: number[];
  77679. };
  77680. /**
  77681. * Converts a new right-handed Vector3
  77682. * @param vector vector3 array
  77683. * @returns right-handed Vector3
  77684. */
  77685. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  77686. /**
  77687. * Converts a Vector3 to right-handed
  77688. * @param vector Vector3 to convert to right-handed
  77689. */
  77690. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  77691. /**
  77692. * Converts a three element number array to right-handed
  77693. * @param vector number array to convert to right-handed
  77694. */
  77695. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  77696. /**
  77697. * Converts a new right-handed Vector3
  77698. * @param vector vector3 array
  77699. * @returns right-handed Vector3
  77700. */
  77701. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  77702. /**
  77703. * Converts a Vector3 to right-handed
  77704. * @param vector Vector3 to convert to right-handed
  77705. */
  77706. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  77707. /**
  77708. * Converts a three element number array to right-handed
  77709. * @param vector number array to convert to right-handed
  77710. */
  77711. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  77712. /**
  77713. * Converts a Vector4 to right-handed
  77714. * @param vector Vector4 to convert to right-handed
  77715. */
  77716. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  77717. /**
  77718. * Converts a Vector4 to right-handed
  77719. * @param vector Vector4 to convert to right-handed
  77720. */
  77721. static _GetRightHandedArray4FromRef(vector: number[]): void;
  77722. /**
  77723. * Converts a Quaternion to right-handed
  77724. * @param quaternion Source quaternion to convert to right-handed
  77725. */
  77726. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  77727. /**
  77728. * Converts a Quaternion to right-handed
  77729. * @param quaternion Source quaternion to convert to right-handed
  77730. */
  77731. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  77732. static _NormalizeTangentFromRef(tangent: Vector4): void;
  77733. }
  77734. }
  77735. declare module BABYLON.GLTF2.Exporter {
  77736. /**
  77737. * Converts Babylon Scene into glTF 2.0.
  77738. * @hidden
  77739. */
  77740. export class _Exporter {
  77741. /**
  77742. * Stores the glTF to export
  77743. */
  77744. _glTF: IGLTF;
  77745. /**
  77746. * Stores all generated buffer views, which represents views into the main glTF buffer data
  77747. */
  77748. _bufferViews: IBufferView[];
  77749. /**
  77750. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  77751. */
  77752. _accessors: IAccessor[];
  77753. /**
  77754. * Stores all the generated nodes, which contains transform and/or mesh information per node
  77755. */
  77756. _nodes: INode[];
  77757. /**
  77758. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  77759. */
  77760. private _scenes;
  77761. /**
  77762. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  77763. */
  77764. private _meshes;
  77765. /**
  77766. * Stores all the generated material information, which represents the appearance of each primitive
  77767. */
  77768. _materials: IMaterial[];
  77769. _materialMap: {
  77770. [materialID: number]: number;
  77771. };
  77772. /**
  77773. * Stores all the generated texture information, which is referenced by glTF materials
  77774. */
  77775. _textures: ITexture[];
  77776. /**
  77777. * Stores all the generated image information, which is referenced by glTF textures
  77778. */
  77779. _images: IImage[];
  77780. /**
  77781. * Stores all the texture samplers
  77782. */
  77783. _samplers: ISampler[];
  77784. /**
  77785. * Stores all the generated animation samplers, which is referenced by glTF animations
  77786. */
  77787. /**
  77788. * Stores the animations for glTF models
  77789. */
  77790. private _animations;
  77791. /**
  77792. * Stores the total amount of bytes stored in the glTF buffer
  77793. */
  77794. private _totalByteLength;
  77795. /**
  77796. * Stores a reference to the Babylon scene containing the source geometry and material information
  77797. */
  77798. _babylonScene: Scene;
  77799. /**
  77800. * Stores a map of the image data, where the key is the file name and the value
  77801. * is the image data
  77802. */
  77803. _imageData: {
  77804. [fileName: string]: {
  77805. data: Uint8Array;
  77806. mimeType: ImageMimeType;
  77807. };
  77808. };
  77809. /**
  77810. * Stores a map of the unique id of a node to its index in the node array
  77811. */
  77812. _nodeMap: {
  77813. [key: number]: number;
  77814. };
  77815. /**
  77816. * Specifies if the source Babylon scene was left handed, and needed conversion.
  77817. */
  77818. _convertToRightHandedSystem: boolean;
  77819. /**
  77820. * Specifies if a Babylon node should be converted to right-handed on export
  77821. */
  77822. _convertToRightHandedSystemMap: {
  77823. [nodeId: number]: boolean;
  77824. };
  77825. _includeCoordinateSystemConversionNodes: boolean;
  77826. /**
  77827. * Baked animation sample rate
  77828. */
  77829. private _animationSampleRate;
  77830. private _options;
  77831. private _localEngine;
  77832. _glTFMaterialExporter: _GLTFMaterialExporter;
  77833. private _extensions;
  77834. private static _ExtensionNames;
  77835. private static _ExtensionFactories;
  77836. private _applyExtension;
  77837. private _applyExtensions;
  77838. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  77839. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  77840. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  77841. [key: number]: number;
  77842. }): Promise<Nullable<INode>>;
  77843. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  77844. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  77845. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  77846. private _forEachExtensions;
  77847. private _extensionsOnExporting;
  77848. /**
  77849. * Load glTF serializer extensions
  77850. */
  77851. private _loadExtensions;
  77852. /**
  77853. * Creates a glTF Exporter instance, which can accept optional exporter options
  77854. * @param babylonScene Babylon scene object
  77855. * @param options Options to modify the behavior of the exporter
  77856. */
  77857. constructor(babylonScene: Scene, options?: IExportOptions);
  77858. dispose(): void;
  77859. /**
  77860. * Registers a glTF exporter extension
  77861. * @param name Name of the extension to export
  77862. * @param factory The factory function that creates the exporter extension
  77863. */
  77864. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  77865. /**
  77866. * Un-registers an exporter extension
  77867. * @param name The name fo the exporter extension
  77868. * @returns A boolean indicating whether the extension has been un-registered
  77869. */
  77870. static UnregisterExtension(name: string): boolean;
  77871. /**
  77872. * Lazy load a local engine
  77873. */
  77874. _getLocalEngine(): Engine;
  77875. private reorderIndicesBasedOnPrimitiveMode;
  77876. /**
  77877. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  77878. * clock-wise during export to glTF
  77879. * @param submesh BabylonJS submesh
  77880. * @param primitiveMode Primitive mode of the mesh
  77881. * @param sideOrientation the winding order of the submesh
  77882. * @param vertexBufferKind The type of vertex attribute
  77883. * @param meshAttributeArray The vertex attribute data
  77884. * @param byteOffset The offset to the binary data
  77885. * @param binaryWriter The binary data for the glTF file
  77886. * @param convertToRightHandedSystem Converts the values to right-handed
  77887. */
  77888. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  77889. /**
  77890. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  77891. * clock-wise during export to glTF
  77892. * @param submesh BabylonJS submesh
  77893. * @param primitiveMode Primitive mode of the mesh
  77894. * @param sideOrientation the winding order of the submesh
  77895. * @param vertexBufferKind The type of vertex attribute
  77896. * @param meshAttributeArray The vertex attribute data
  77897. * @param byteOffset The offset to the binary data
  77898. * @param binaryWriter The binary data for the glTF file
  77899. * @param convertToRightHandedSystem Converts the values to right-handed
  77900. */
  77901. private reorderTriangleFillMode;
  77902. /**
  77903. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  77904. * clock-wise during export to glTF
  77905. * @param submesh BabylonJS submesh
  77906. * @param primitiveMode Primitive mode of the mesh
  77907. * @param sideOrientation the winding order of the submesh
  77908. * @param vertexBufferKind The type of vertex attribute
  77909. * @param meshAttributeArray The vertex attribute data
  77910. * @param byteOffset The offset to the binary data
  77911. * @param binaryWriter The binary data for the glTF file
  77912. * @param convertToRightHandedSystem Converts the values to right-handed
  77913. */
  77914. private reorderTriangleStripDrawMode;
  77915. /**
  77916. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  77917. * clock-wise during export to glTF
  77918. * @param submesh BabylonJS submesh
  77919. * @param primitiveMode Primitive mode of the mesh
  77920. * @param sideOrientation the winding order of the submesh
  77921. * @param vertexBufferKind The type of vertex attribute
  77922. * @param meshAttributeArray The vertex attribute data
  77923. * @param byteOffset The offset to the binary data
  77924. * @param binaryWriter The binary data for the glTF file
  77925. * @param convertToRightHandedSystem Converts the values to right-handed
  77926. */
  77927. private reorderTriangleFanMode;
  77928. /**
  77929. * Writes the vertex attribute data to binary
  77930. * @param vertices The vertices to write to the binary writer
  77931. * @param byteOffset The offset into the binary writer to overwrite binary data
  77932. * @param vertexAttributeKind The vertex attribute type
  77933. * @param meshAttributeArray The vertex attribute data
  77934. * @param binaryWriter The writer containing the binary data
  77935. * @param convertToRightHandedSystem Converts the values to right-handed
  77936. */
  77937. private writeVertexAttributeData;
  77938. /**
  77939. * Writes mesh attribute data to a data buffer
  77940. * Returns the bytelength of the data
  77941. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  77942. * @param meshAttributeArray Array containing the attribute data
  77943. * @param binaryWriter The buffer to write the binary data to
  77944. * @param indices Used to specify the order of the vertex data
  77945. * @param convertToRightHandedSystem Converts the values to right-handed
  77946. */
  77947. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  77948. /**
  77949. * Generates glTF json data
  77950. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  77951. * @param glTFPrefix Text to use when prefixing a glTF file
  77952. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  77953. * @returns json data as string
  77954. */
  77955. private generateJSON;
  77956. /**
  77957. * Generates data for .gltf and .bin files based on the glTF prefix string
  77958. * @param glTFPrefix Text to use when prefixing a glTF file
  77959. * @param dispose Dispose the exporter
  77960. * @returns GLTFData with glTF file data
  77961. */
  77962. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  77963. /**
  77964. * Creates a binary buffer for glTF
  77965. * @returns array buffer for binary data
  77966. */
  77967. private _generateBinaryAsync;
  77968. /**
  77969. * Pads the number to a multiple of 4
  77970. * @param num number to pad
  77971. * @returns padded number
  77972. */
  77973. private _getPadding;
  77974. /**
  77975. * @hidden
  77976. */
  77977. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  77978. /**
  77979. * Sets the TRS for each node
  77980. * @param node glTF Node for storing the transformation data
  77981. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  77982. * @param convertToRightHandedSystem Converts the values to right-handed
  77983. */
  77984. private setNodeTransformation;
  77985. private getVertexBufferFromMesh;
  77986. /**
  77987. * Creates a bufferview based on the vertices type for the Babylon mesh
  77988. * @param kind Indicates the type of vertices data
  77989. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  77990. * @param binaryWriter The buffer to write the bufferview data to
  77991. * @param convertToRightHandedSystem Converts the values to right-handed
  77992. */
  77993. private createBufferViewKind;
  77994. /**
  77995. * The primitive mode of the Babylon mesh
  77996. * @param babylonMesh The BabylonJS mesh
  77997. */
  77998. private getMeshPrimitiveMode;
  77999. /**
  78000. * Sets the primitive mode of the glTF mesh primitive
  78001. * @param meshPrimitive glTF mesh primitive
  78002. * @param primitiveMode The primitive mode
  78003. */
  78004. private setPrimitiveMode;
  78005. /**
  78006. * Sets the vertex attribute accessor based of the glTF mesh primitive
  78007. * @param meshPrimitive glTF mesh primitive
  78008. * @param attributeKind vertex attribute
  78009. * @returns boolean specifying if uv coordinates are present
  78010. */
  78011. private setAttributeKind;
  78012. /**
  78013. * Sets data for the primitive attributes of each submesh
  78014. * @param mesh glTF Mesh object to store the primitive attribute information
  78015. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  78016. * @param binaryWriter Buffer to write the attribute data to
  78017. * @param convertToRightHandedSystem Converts the values to right-handed
  78018. */
  78019. private setPrimitiveAttributesAsync;
  78020. /**
  78021. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  78022. * @param node The node to check
  78023. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  78024. */
  78025. private isBabylonCoordinateSystemConvertingNode;
  78026. /**
  78027. * Creates a glTF scene based on the array of meshes
  78028. * Returns the the total byte offset
  78029. * @param babylonScene Babylon scene to get the mesh data from
  78030. * @param binaryWriter Buffer to write binary data to
  78031. */
  78032. private createSceneAsync;
  78033. /**
  78034. * Creates a mapping of Node unique id to node index and handles animations
  78035. * @param babylonScene Babylon Scene
  78036. * @param nodes Babylon transform nodes
  78037. * @param binaryWriter Buffer to write binary data to
  78038. * @returns Node mapping of unique id to index
  78039. */
  78040. private createNodeMapAndAnimationsAsync;
  78041. /**
  78042. * Creates a glTF node from a Babylon mesh
  78043. * @param babylonMesh Source Babylon mesh
  78044. * @param binaryWriter Buffer for storing geometry data
  78045. * @param convertToRightHandedSystem Converts the values to right-handed
  78046. * @param nodeMap Node mapping of unique id to glTF node index
  78047. * @returns glTF node
  78048. */
  78049. private createNodeAsync;
  78050. }
  78051. /**
  78052. * @hidden
  78053. *
  78054. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  78055. */
  78056. export class _BinaryWriter {
  78057. /**
  78058. * Array buffer which stores all binary data
  78059. */
  78060. private _arrayBuffer;
  78061. /**
  78062. * View of the array buffer
  78063. */
  78064. private _dataView;
  78065. /**
  78066. * byte offset of data in array buffer
  78067. */
  78068. private _byteOffset;
  78069. /**
  78070. * Initialize binary writer with an initial byte length
  78071. * @param byteLength Initial byte length of the array buffer
  78072. */
  78073. constructor(byteLength: number);
  78074. /**
  78075. * Resize the array buffer to the specified byte length
  78076. * @param byteLength
  78077. */
  78078. private resizeBuffer;
  78079. /**
  78080. * Get an array buffer with the length of the byte offset
  78081. * @returns ArrayBuffer resized to the byte offset
  78082. */
  78083. getArrayBuffer(): ArrayBuffer;
  78084. /**
  78085. * Get the byte offset of the array buffer
  78086. * @returns byte offset
  78087. */
  78088. getByteOffset(): number;
  78089. /**
  78090. * Stores an UInt8 in the array buffer
  78091. * @param entry
  78092. * @param byteOffset If defined, specifies where to set the value as an offset.
  78093. */
  78094. setUInt8(entry: number, byteOffset?: number): void;
  78095. /**
  78096. * Gets an UInt32 in the array buffer
  78097. * @param entry
  78098. * @param byteOffset If defined, specifies where to set the value as an offset.
  78099. */
  78100. getUInt32(byteOffset: number): number;
  78101. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  78102. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  78103. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  78104. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  78105. /**
  78106. * Stores a Float32 in the array buffer
  78107. * @param entry
  78108. */
  78109. setFloat32(entry: number, byteOffset?: number): void;
  78110. /**
  78111. * Stores an UInt32 in the array buffer
  78112. * @param entry
  78113. * @param byteOffset If defined, specifies where to set the value as an offset.
  78114. */
  78115. setUInt32(entry: number, byteOffset?: number): void;
  78116. }
  78117. }
  78118. declare module BABYLON.GLTF2.Exporter {
  78119. /**
  78120. * @hidden
  78121. * Interface to store animation data.
  78122. */
  78123. export interface _IAnimationData {
  78124. /**
  78125. * Keyframe data.
  78126. */
  78127. inputs: number[];
  78128. /**
  78129. * Value data.
  78130. */
  78131. outputs: number[][];
  78132. /**
  78133. * Animation interpolation data.
  78134. */
  78135. samplerInterpolation: AnimationSamplerInterpolation;
  78136. /**
  78137. * Minimum keyframe value.
  78138. */
  78139. inputsMin: number;
  78140. /**
  78141. * Maximum keyframe value.
  78142. */
  78143. inputsMax: number;
  78144. }
  78145. /**
  78146. * @hidden
  78147. */
  78148. export interface _IAnimationInfo {
  78149. /**
  78150. * The target channel for the animation
  78151. */
  78152. animationChannelTargetPath: AnimationChannelTargetPath;
  78153. /**
  78154. * The glTF accessor type for the data.
  78155. */
  78156. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  78157. /**
  78158. * Specifies if quaternions should be used.
  78159. */
  78160. useQuaternion: boolean;
  78161. }
  78162. /**
  78163. * @hidden
  78164. * Utility class for generating glTF animation data from BabylonJS.
  78165. */
  78166. export class _GLTFAnimation {
  78167. /**
  78168. * @ignore
  78169. *
  78170. * Creates glTF channel animation from BabylonJS animation.
  78171. * @param babylonTransformNode - BabylonJS mesh.
  78172. * @param animation - animation.
  78173. * @param animationChannelTargetPath - The target animation channel.
  78174. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  78175. * @param useQuaternion - Specifies if quaternions are used.
  78176. * @returns nullable IAnimationData
  78177. */
  78178. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  78179. private static _DeduceAnimationInfo;
  78180. /**
  78181. * @ignore
  78182. * Create node animations from the transform node animations
  78183. * @param babylonNode
  78184. * @param runtimeGLTFAnimation
  78185. * @param idleGLTFAnimations
  78186. * @param nodeMap
  78187. * @param nodes
  78188. * @param binaryWriter
  78189. * @param bufferViews
  78190. * @param accessors
  78191. * @param convertToRightHandedSystem
  78192. * @param animationSampleRate
  78193. */
  78194. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  78195. [key: number]: number;
  78196. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  78197. /**
  78198. * @ignore
  78199. * Create node animations from the animation groups
  78200. * @param babylonScene
  78201. * @param glTFAnimations
  78202. * @param nodeMap
  78203. * @param nodes
  78204. * @param binaryWriter
  78205. * @param bufferViews
  78206. * @param accessors
  78207. * @param convertToRightHandedSystemMap
  78208. * @param animationSampleRate
  78209. */
  78210. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  78211. [key: number]: number;
  78212. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  78213. [nodeId: number]: boolean;
  78214. }, animationSampleRate: number): void;
  78215. private static AddAnimation;
  78216. /**
  78217. * Create a baked animation
  78218. * @param babylonTransformNode BabylonJS mesh
  78219. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  78220. * @param animationChannelTargetPath animation target channel
  78221. * @param minFrame minimum animation frame
  78222. * @param maxFrame maximum animation frame
  78223. * @param fps frames per second of the animation
  78224. * @param inputs input key frames of the animation
  78225. * @param outputs output key frame data of the animation
  78226. * @param convertToRightHandedSystem converts the values to right-handed
  78227. * @param useQuaternion specifies if quaternions should be used
  78228. */
  78229. private static _CreateBakedAnimation;
  78230. private static _ConvertFactorToVector3OrQuaternion;
  78231. private static _SetInterpolatedValue;
  78232. /**
  78233. * Creates linear animation from the animation key frames
  78234. * @param babylonTransformNode BabylonJS mesh
  78235. * @param animation BabylonJS animation
  78236. * @param animationChannelTargetPath The target animation channel
  78237. * @param frameDelta The difference between the last and first frame of the animation
  78238. * @param inputs Array to store the key frame times
  78239. * @param outputs Array to store the key frame data
  78240. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  78241. * @param useQuaternion Specifies if quaternions are used in the animation
  78242. */
  78243. private static _CreateLinearOrStepAnimation;
  78244. /**
  78245. * Creates cubic spline animation from the animation key frames
  78246. * @param babylonTransformNode BabylonJS mesh
  78247. * @param animation BabylonJS animation
  78248. * @param animationChannelTargetPath The target animation channel
  78249. * @param frameDelta The difference between the last and first frame of the animation
  78250. * @param inputs Array to store the key frame times
  78251. * @param outputs Array to store the key frame data
  78252. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  78253. * @param useQuaternion Specifies if quaternions are used in the animation
  78254. */
  78255. private static _CreateCubicSplineAnimation;
  78256. private static _GetBasePositionRotationOrScale;
  78257. /**
  78258. * Adds a key frame value
  78259. * @param keyFrame
  78260. * @param animation
  78261. * @param outputs
  78262. * @param animationChannelTargetPath
  78263. * @param basePositionRotationOrScale
  78264. * @param convertToRightHandedSystem
  78265. * @param useQuaternion
  78266. */
  78267. private static _AddKeyframeValue;
  78268. /**
  78269. * Determine the interpolation based on the key frames
  78270. * @param keyFrames
  78271. * @param animationChannelTargetPath
  78272. * @param useQuaternion
  78273. */
  78274. private static _DeduceInterpolation;
  78275. /**
  78276. * Adds an input tangent or output tangent to the output data
  78277. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  78278. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  78279. * @param outputs The animation data by keyframe
  78280. * @param animationChannelTargetPath The target animation channel
  78281. * @param interpolation The interpolation type
  78282. * @param keyFrame The key frame with the animation data
  78283. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  78284. * @param useQuaternion Specifies if quaternions are used
  78285. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  78286. */
  78287. private static AddSplineTangent;
  78288. /**
  78289. * Get the minimum and maximum key frames' frame values
  78290. * @param keyFrames animation key frames
  78291. * @returns the minimum and maximum key frame value
  78292. */
  78293. private static calculateMinMaxKeyFrames;
  78294. }
  78295. }
  78296. declare module BABYLON.GLTF2.Exporter {
  78297. /** @hidden */
  78298. export var textureTransformPixelShader: {
  78299. name: string;
  78300. shader: string;
  78301. };
  78302. }
  78303. declare module BABYLON.GLTF2.Exporter.Extensions {
  78304. /**
  78305. * @hidden
  78306. */
  78307. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  78308. private _recordedTextures;
  78309. /** Name of this extension */
  78310. readonly name: string;
  78311. /** Defines whether this extension is enabled */
  78312. enabled: boolean;
  78313. /** Defines whether this extension is required */
  78314. required: boolean;
  78315. /** Reference to the glTF exporter */
  78316. private _wasUsed;
  78317. constructor(exporter: _Exporter);
  78318. dispose(): void;
  78319. /** @hidden */
  78320. get wasUsed(): boolean;
  78321. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  78322. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  78323. /**
  78324. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  78325. * @param babylonTexture
  78326. * @param offset
  78327. * @param rotation
  78328. * @param scale
  78329. * @param scene
  78330. */
  78331. private _textureTransformTextureAsync;
  78332. }
  78333. }
  78334. declare module BABYLON.GLTF2.Exporter.Extensions {
  78335. /**
  78336. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  78337. */
  78338. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  78339. /** The name of this extension. */
  78340. readonly name: string;
  78341. /** Defines whether this extension is enabled. */
  78342. enabled: boolean;
  78343. /** Defines whether this extension is required */
  78344. required: boolean;
  78345. /** Reference to the glTF exporter */
  78346. private _exporter;
  78347. private _lights;
  78348. /** @hidden */
  78349. constructor(exporter: _Exporter);
  78350. /** @hidden */
  78351. dispose(): void;
  78352. /** @hidden */
  78353. get wasUsed(): boolean;
  78354. /** @hidden */
  78355. onExporting(): void;
  78356. /**
  78357. * Define this method to modify the default behavior when exporting a node
  78358. * @param context The context when exporting the node
  78359. * @param node glTF node
  78360. * @param babylonNode BabylonJS node
  78361. * @param nodeMap Node mapping of unique id to glTF node index
  78362. * @returns nullable INode promise
  78363. */
  78364. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  78365. [key: number]: number;
  78366. }): Promise<Nullable<INode>>;
  78367. }
  78368. }
  78369. declare module BABYLON.GLTF2.Exporter.Extensions {
  78370. /**
  78371. * @hidden
  78372. */
  78373. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  78374. /** Name of this extension */
  78375. readonly name: string;
  78376. /** Defines whether this extension is enabled */
  78377. enabled: boolean;
  78378. /** Defines whether this extension is required */
  78379. required: boolean;
  78380. /** Reference to the glTF exporter */
  78381. private _textureInfos;
  78382. private _exportedTextures;
  78383. private _wasUsed;
  78384. constructor(exporter: _Exporter);
  78385. dispose(): void;
  78386. /** @hidden */
  78387. get wasUsed(): boolean;
  78388. private _getTextureIndex;
  78389. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  78390. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  78391. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  78392. }
  78393. }
  78394. declare module BABYLON {
  78395. /**
  78396. * Class for generating STL data from a Babylon scene.
  78397. */
  78398. export class STLExport {
  78399. /**
  78400. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  78401. * @param meshes list defines the mesh to serialize
  78402. * @param download triggers the automatic download of the file.
  78403. * @param fileName changes the downloads fileName.
  78404. * @param binary changes the STL to a binary type.
  78405. * @param isLittleEndian toggle for binary type exporter.
  78406. * @returns the STL as UTF8 string
  78407. */
  78408. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  78409. }
  78410. }
  78411. declare module "babylonjs-gltf2interface" {
  78412. export = BABYLON.GLTF2;
  78413. }
  78414. /**
  78415. * Module for glTF 2.0 Interface
  78416. */
  78417. declare module BABYLON.GLTF2 {
  78418. /**
  78419. * The datatype of the components in the attribute
  78420. */
  78421. const enum AccessorComponentType {
  78422. /**
  78423. * Byte
  78424. */
  78425. BYTE = 5120,
  78426. /**
  78427. * Unsigned Byte
  78428. */
  78429. UNSIGNED_BYTE = 5121,
  78430. /**
  78431. * Short
  78432. */
  78433. SHORT = 5122,
  78434. /**
  78435. * Unsigned Short
  78436. */
  78437. UNSIGNED_SHORT = 5123,
  78438. /**
  78439. * Unsigned Int
  78440. */
  78441. UNSIGNED_INT = 5125,
  78442. /**
  78443. * Float
  78444. */
  78445. FLOAT = 5126,
  78446. }
  78447. /**
  78448. * Specifies if the attirbute is a scalar, vector, or matrix
  78449. */
  78450. const enum AccessorType {
  78451. /**
  78452. * Scalar
  78453. */
  78454. SCALAR = "SCALAR",
  78455. /**
  78456. * Vector2
  78457. */
  78458. VEC2 = "VEC2",
  78459. /**
  78460. * Vector3
  78461. */
  78462. VEC3 = "VEC3",
  78463. /**
  78464. * Vector4
  78465. */
  78466. VEC4 = "VEC4",
  78467. /**
  78468. * Matrix2x2
  78469. */
  78470. MAT2 = "MAT2",
  78471. /**
  78472. * Matrix3x3
  78473. */
  78474. MAT3 = "MAT3",
  78475. /**
  78476. * Matrix4x4
  78477. */
  78478. MAT4 = "MAT4",
  78479. }
  78480. /**
  78481. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  78482. */
  78483. const enum AnimationChannelTargetPath {
  78484. /**
  78485. * Translation
  78486. */
  78487. TRANSLATION = "translation",
  78488. /**
  78489. * Rotation
  78490. */
  78491. ROTATION = "rotation",
  78492. /**
  78493. * Scale
  78494. */
  78495. SCALE = "scale",
  78496. /**
  78497. * Weights
  78498. */
  78499. WEIGHTS = "weights",
  78500. }
  78501. /**
  78502. * Interpolation algorithm
  78503. */
  78504. const enum AnimationSamplerInterpolation {
  78505. /**
  78506. * The animated values are linearly interpolated between keyframes
  78507. */
  78508. LINEAR = "LINEAR",
  78509. /**
  78510. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  78511. */
  78512. STEP = "STEP",
  78513. /**
  78514. * The animation's interpolation is computed using a cubic spline with specified tangents
  78515. */
  78516. CUBICSPLINE = "CUBICSPLINE",
  78517. }
  78518. /**
  78519. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  78520. */
  78521. const enum CameraType {
  78522. /**
  78523. * A perspective camera containing properties to create a perspective projection matrix
  78524. */
  78525. PERSPECTIVE = "perspective",
  78526. /**
  78527. * An orthographic camera containing properties to create an orthographic projection matrix
  78528. */
  78529. ORTHOGRAPHIC = "orthographic",
  78530. }
  78531. /**
  78532. * The mime-type of the image
  78533. */
  78534. const enum ImageMimeType {
  78535. /**
  78536. * JPEG Mime-type
  78537. */
  78538. JPEG = "image/jpeg",
  78539. /**
  78540. * PNG Mime-type
  78541. */
  78542. PNG = "image/png",
  78543. }
  78544. /**
  78545. * The alpha rendering mode of the material
  78546. */
  78547. const enum MaterialAlphaMode {
  78548. /**
  78549. * The alpha value is ignored and the rendered output is fully opaque
  78550. */
  78551. OPAQUE = "OPAQUE",
  78552. /**
  78553. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  78554. */
  78555. MASK = "MASK",
  78556. /**
  78557. * 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)
  78558. */
  78559. BLEND = "BLEND",
  78560. }
  78561. /**
  78562. * The type of the primitives to render
  78563. */
  78564. const enum MeshPrimitiveMode {
  78565. /**
  78566. * Points
  78567. */
  78568. POINTS = 0,
  78569. /**
  78570. * Lines
  78571. */
  78572. LINES = 1,
  78573. /**
  78574. * Line Loop
  78575. */
  78576. LINE_LOOP = 2,
  78577. /**
  78578. * Line Strip
  78579. */
  78580. LINE_STRIP = 3,
  78581. /**
  78582. * Triangles
  78583. */
  78584. TRIANGLES = 4,
  78585. /**
  78586. * Triangle Strip
  78587. */
  78588. TRIANGLE_STRIP = 5,
  78589. /**
  78590. * Triangle Fan
  78591. */
  78592. TRIANGLE_FAN = 6,
  78593. }
  78594. /**
  78595. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  78596. */
  78597. const enum TextureMagFilter {
  78598. /**
  78599. * Nearest
  78600. */
  78601. NEAREST = 9728,
  78602. /**
  78603. * Linear
  78604. */
  78605. LINEAR = 9729,
  78606. }
  78607. /**
  78608. * Minification filter. All valid values correspond to WebGL enums
  78609. */
  78610. const enum TextureMinFilter {
  78611. /**
  78612. * Nearest
  78613. */
  78614. NEAREST = 9728,
  78615. /**
  78616. * Linear
  78617. */
  78618. LINEAR = 9729,
  78619. /**
  78620. * Nearest Mip-Map Nearest
  78621. */
  78622. NEAREST_MIPMAP_NEAREST = 9984,
  78623. /**
  78624. * Linear Mipmap Nearest
  78625. */
  78626. LINEAR_MIPMAP_NEAREST = 9985,
  78627. /**
  78628. * Nearest Mipmap Linear
  78629. */
  78630. NEAREST_MIPMAP_LINEAR = 9986,
  78631. /**
  78632. * Linear Mipmap Linear
  78633. */
  78634. LINEAR_MIPMAP_LINEAR = 9987,
  78635. }
  78636. /**
  78637. * S (U) wrapping mode. All valid values correspond to WebGL enums
  78638. */
  78639. const enum TextureWrapMode {
  78640. /**
  78641. * Clamp to Edge
  78642. */
  78643. CLAMP_TO_EDGE = 33071,
  78644. /**
  78645. * Mirrored Repeat
  78646. */
  78647. MIRRORED_REPEAT = 33648,
  78648. /**
  78649. * Repeat
  78650. */
  78651. REPEAT = 10497,
  78652. }
  78653. /**
  78654. * glTF Property
  78655. */
  78656. interface IProperty {
  78657. /**
  78658. * Dictionary object with extension-specific objects
  78659. */
  78660. extensions?: {
  78661. [key: string]: any;
  78662. };
  78663. /**
  78664. * Application-Specific data
  78665. */
  78666. extras?: any;
  78667. }
  78668. /**
  78669. * glTF Child of Root Property
  78670. */
  78671. interface IChildRootProperty extends IProperty {
  78672. /**
  78673. * The user-defined name of this object
  78674. */
  78675. name?: string;
  78676. }
  78677. /**
  78678. * Indices of those attributes that deviate from their initialization value
  78679. */
  78680. interface IAccessorSparseIndices extends IProperty {
  78681. /**
  78682. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  78683. */
  78684. bufferView: number;
  78685. /**
  78686. * The offset relative to the start of the bufferView in bytes. Must be aligned
  78687. */
  78688. byteOffset?: number;
  78689. /**
  78690. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  78691. */
  78692. componentType: AccessorComponentType;
  78693. }
  78694. /**
  78695. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  78696. */
  78697. interface IAccessorSparseValues extends IProperty {
  78698. /**
  78699. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  78700. */
  78701. bufferView: number;
  78702. /**
  78703. * The offset relative to the start of the bufferView in bytes. Must be aligned
  78704. */
  78705. byteOffset?: number;
  78706. }
  78707. /**
  78708. * Sparse storage of attributes that deviate from their initialization value
  78709. */
  78710. interface IAccessorSparse extends IProperty {
  78711. /**
  78712. * The number of attributes encoded in this sparse accessor
  78713. */
  78714. count: number;
  78715. /**
  78716. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  78717. */
  78718. indices: IAccessorSparseIndices;
  78719. /**
  78720. * 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
  78721. */
  78722. values: IAccessorSparseValues;
  78723. }
  78724. /**
  78725. * 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
  78726. */
  78727. interface IAccessor extends IChildRootProperty {
  78728. /**
  78729. * The index of the bufferview
  78730. */
  78731. bufferView?: number;
  78732. /**
  78733. * The offset relative to the start of the bufferView in bytes
  78734. */
  78735. byteOffset?: number;
  78736. /**
  78737. * The datatype of components in the attribute
  78738. */
  78739. componentType: AccessorComponentType;
  78740. /**
  78741. * Specifies whether integer data values should be normalized
  78742. */
  78743. normalized?: boolean;
  78744. /**
  78745. * The number of attributes referenced by this accessor
  78746. */
  78747. count: number;
  78748. /**
  78749. * Specifies if the attribute is a scalar, vector, or matrix
  78750. */
  78751. type: AccessorType;
  78752. /**
  78753. * Maximum value of each component in this attribute
  78754. */
  78755. max?: number[];
  78756. /**
  78757. * Minimum value of each component in this attribute
  78758. */
  78759. min?: number[];
  78760. /**
  78761. * Sparse storage of attributes that deviate from their initialization value
  78762. */
  78763. sparse?: IAccessorSparse;
  78764. }
  78765. /**
  78766. * Targets an animation's sampler at a node's property
  78767. */
  78768. interface IAnimationChannel extends IProperty {
  78769. /**
  78770. * The index of a sampler in this animation used to compute the value for the target
  78771. */
  78772. sampler: number;
  78773. /**
  78774. * The index of the node and TRS property to target
  78775. */
  78776. target: IAnimationChannelTarget;
  78777. }
  78778. /**
  78779. * The index of the node and TRS property that an animation channel targets
  78780. */
  78781. interface IAnimationChannelTarget extends IProperty {
  78782. /**
  78783. * The index of the node to target
  78784. */
  78785. node: number;
  78786. /**
  78787. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  78788. */
  78789. path: AnimationChannelTargetPath;
  78790. }
  78791. /**
  78792. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  78793. */
  78794. interface IAnimationSampler extends IProperty {
  78795. /**
  78796. * The index of an accessor containing keyframe input values, e.g., time
  78797. */
  78798. input: number;
  78799. /**
  78800. * Interpolation algorithm
  78801. */
  78802. interpolation?: AnimationSamplerInterpolation;
  78803. /**
  78804. * The index of an accessor, containing keyframe output values
  78805. */
  78806. output: number;
  78807. }
  78808. /**
  78809. * A keyframe animation
  78810. */
  78811. interface IAnimation extends IChildRootProperty {
  78812. /**
  78813. * An array of channels, each of which targets an animation's sampler at a node's property
  78814. */
  78815. channels: IAnimationChannel[];
  78816. /**
  78817. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  78818. */
  78819. samplers: IAnimationSampler[];
  78820. }
  78821. /**
  78822. * Metadata about the glTF asset
  78823. */
  78824. interface IAsset extends IChildRootProperty {
  78825. /**
  78826. * A copyright message suitable for display to credit the content creator
  78827. */
  78828. copyright?: string;
  78829. /**
  78830. * Tool that generated this glTF model. Useful for debugging
  78831. */
  78832. generator?: string;
  78833. /**
  78834. * The glTF version that this asset targets
  78835. */
  78836. version: string;
  78837. /**
  78838. * The minimum glTF version that this asset targets
  78839. */
  78840. minVersion?: string;
  78841. }
  78842. /**
  78843. * A buffer points to binary geometry, animation, or skins
  78844. */
  78845. interface IBuffer extends IChildRootProperty {
  78846. /**
  78847. * 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
  78848. */
  78849. uri?: string;
  78850. /**
  78851. * The length of the buffer in bytes
  78852. */
  78853. byteLength: number;
  78854. }
  78855. /**
  78856. * A view into a buffer generally representing a subset of the buffer
  78857. */
  78858. interface IBufferView extends IChildRootProperty {
  78859. /**
  78860. * The index of the buffer
  78861. */
  78862. buffer: number;
  78863. /**
  78864. * The offset into the buffer in bytes
  78865. */
  78866. byteOffset?: number;
  78867. /**
  78868. * The lenth of the bufferView in bytes
  78869. */
  78870. byteLength: number;
  78871. /**
  78872. * The stride, in bytes
  78873. */
  78874. byteStride?: number;
  78875. }
  78876. /**
  78877. * An orthographic camera containing properties to create an orthographic projection matrix
  78878. */
  78879. interface ICameraOrthographic extends IProperty {
  78880. /**
  78881. * The floating-point horizontal magnification of the view. Must not be zero
  78882. */
  78883. xmag: number;
  78884. /**
  78885. * The floating-point vertical magnification of the view. Must not be zero
  78886. */
  78887. ymag: number;
  78888. /**
  78889. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  78890. */
  78891. zfar: number;
  78892. /**
  78893. * The floating-point distance to the near clipping plane
  78894. */
  78895. znear: number;
  78896. }
  78897. /**
  78898. * A perspective camera containing properties to create a perspective projection matrix
  78899. */
  78900. interface ICameraPerspective extends IProperty {
  78901. /**
  78902. * The floating-point aspect ratio of the field of view
  78903. */
  78904. aspectRatio?: number;
  78905. /**
  78906. * The floating-point vertical field of view in radians
  78907. */
  78908. yfov: number;
  78909. /**
  78910. * The floating-point distance to the far clipping plane
  78911. */
  78912. zfar?: number;
  78913. /**
  78914. * The floating-point distance to the near clipping plane
  78915. */
  78916. znear: number;
  78917. }
  78918. /**
  78919. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  78920. */
  78921. interface ICamera extends IChildRootProperty {
  78922. /**
  78923. * An orthographic camera containing properties to create an orthographic projection matrix
  78924. */
  78925. orthographic?: ICameraOrthographic;
  78926. /**
  78927. * A perspective camera containing properties to create a perspective projection matrix
  78928. */
  78929. perspective?: ICameraPerspective;
  78930. /**
  78931. * Specifies if the camera uses a perspective or orthographic projection
  78932. */
  78933. type: CameraType;
  78934. }
  78935. /**
  78936. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  78937. */
  78938. interface IImage extends IChildRootProperty {
  78939. /**
  78940. * 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
  78941. */
  78942. uri?: string;
  78943. /**
  78944. * The image's MIME type
  78945. */
  78946. mimeType?: ImageMimeType;
  78947. /**
  78948. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  78949. */
  78950. bufferView?: number;
  78951. }
  78952. /**
  78953. * Material Normal Texture Info
  78954. */
  78955. interface IMaterialNormalTextureInfo extends ITextureInfo {
  78956. /**
  78957. * The scalar multiplier applied to each normal vector of the normal texture
  78958. */
  78959. scale?: number;
  78960. }
  78961. /**
  78962. * Material Occlusion Texture Info
  78963. */
  78964. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  78965. /**
  78966. * A scalar multiplier controlling the amount of occlusion applied
  78967. */
  78968. strength?: number;
  78969. }
  78970. /**
  78971. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  78972. */
  78973. interface IMaterialPbrMetallicRoughness {
  78974. /**
  78975. * The material's base color factor
  78976. */
  78977. baseColorFactor?: number[];
  78978. /**
  78979. * The base color texture
  78980. */
  78981. baseColorTexture?: ITextureInfo;
  78982. /**
  78983. * The metalness of the material
  78984. */
  78985. metallicFactor?: number;
  78986. /**
  78987. * The roughness of the material
  78988. */
  78989. roughnessFactor?: number;
  78990. /**
  78991. * The metallic-roughness texture
  78992. */
  78993. metallicRoughnessTexture?: ITextureInfo;
  78994. }
  78995. /**
  78996. * The material appearance of a primitive
  78997. */
  78998. interface IMaterial extends IChildRootProperty {
  78999. /**
  79000. * 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
  79001. */
  79002. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  79003. /**
  79004. * The normal map texture
  79005. */
  79006. normalTexture?: IMaterialNormalTextureInfo;
  79007. /**
  79008. * The occlusion map texture
  79009. */
  79010. occlusionTexture?: IMaterialOcclusionTextureInfo;
  79011. /**
  79012. * The emissive map texture
  79013. */
  79014. emissiveTexture?: ITextureInfo;
  79015. /**
  79016. * 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
  79017. */
  79018. emissiveFactor?: number[];
  79019. /**
  79020. * The alpha rendering mode of the material
  79021. */
  79022. alphaMode?: MaterialAlphaMode;
  79023. /**
  79024. * The alpha cutoff value of the material
  79025. */
  79026. alphaCutoff?: number;
  79027. /**
  79028. * Specifies whether the material is double sided
  79029. */
  79030. doubleSided?: boolean;
  79031. }
  79032. /**
  79033. * Geometry to be rendered with the given material
  79034. */
  79035. interface IMeshPrimitive extends IProperty {
  79036. /**
  79037. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  79038. */
  79039. attributes: {
  79040. [name: string]: number;
  79041. };
  79042. /**
  79043. * The index of the accessor that contains the indices
  79044. */
  79045. indices?: number;
  79046. /**
  79047. * The index of the material to apply to this primitive when rendering
  79048. */
  79049. material?: number;
  79050. /**
  79051. * The type of primitives to render. All valid values correspond to WebGL enums
  79052. */
  79053. mode?: MeshPrimitiveMode;
  79054. /**
  79055. * 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
  79056. */
  79057. targets?: {
  79058. [name: string]: number;
  79059. }[];
  79060. }
  79061. /**
  79062. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  79063. */
  79064. interface IMesh extends IChildRootProperty {
  79065. /**
  79066. * An array of primitives, each defining geometry to be rendered with a material
  79067. */
  79068. primitives: IMeshPrimitive[];
  79069. /**
  79070. * Array of weights to be applied to the Morph Targets
  79071. */
  79072. weights?: number[];
  79073. }
  79074. /**
  79075. * A node in the node hierarchy
  79076. */
  79077. interface INode extends IChildRootProperty {
  79078. /**
  79079. * The index of the camera referenced by this node
  79080. */
  79081. camera?: number;
  79082. /**
  79083. * The indices of this node's children
  79084. */
  79085. children?: number[];
  79086. /**
  79087. * The index of the skin referenced by this node
  79088. */
  79089. skin?: number;
  79090. /**
  79091. * A floating-point 4x4 transformation matrix stored in column-major order
  79092. */
  79093. matrix?: number[];
  79094. /**
  79095. * The index of the mesh in this node
  79096. */
  79097. mesh?: number;
  79098. /**
  79099. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  79100. */
  79101. rotation?: number[];
  79102. /**
  79103. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  79104. */
  79105. scale?: number[];
  79106. /**
  79107. * The node's translation along the x, y, and z axes
  79108. */
  79109. translation?: number[];
  79110. /**
  79111. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  79112. */
  79113. weights?: number[];
  79114. }
  79115. /**
  79116. * Texture sampler properties for filtering and wrapping modes
  79117. */
  79118. interface ISampler extends IChildRootProperty {
  79119. /**
  79120. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  79121. */
  79122. magFilter?: TextureMagFilter;
  79123. /**
  79124. * Minification filter. All valid values correspond to WebGL enums
  79125. */
  79126. minFilter?: TextureMinFilter;
  79127. /**
  79128. * S (U) wrapping mode. All valid values correspond to WebGL enums
  79129. */
  79130. wrapS?: TextureWrapMode;
  79131. /**
  79132. * T (V) wrapping mode. All valid values correspond to WebGL enums
  79133. */
  79134. wrapT?: TextureWrapMode;
  79135. }
  79136. /**
  79137. * The root nodes of a scene
  79138. */
  79139. interface IScene extends IChildRootProperty {
  79140. /**
  79141. * The indices of each root node
  79142. */
  79143. nodes: number[];
  79144. }
  79145. /**
  79146. * Joints and matrices defining a skin
  79147. */
  79148. interface ISkin extends IChildRootProperty {
  79149. /**
  79150. * 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
  79151. */
  79152. inverseBindMatrices?: number;
  79153. /**
  79154. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  79155. */
  79156. skeleton?: number;
  79157. /**
  79158. * 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)
  79159. */
  79160. joints: number[];
  79161. }
  79162. /**
  79163. * A texture and its sampler
  79164. */
  79165. interface ITexture extends IChildRootProperty {
  79166. /**
  79167. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  79168. */
  79169. sampler?: number;
  79170. /**
  79171. * The index of the image used by this texture
  79172. */
  79173. source: number;
  79174. }
  79175. /**
  79176. * Reference to a texture
  79177. */
  79178. interface ITextureInfo extends IProperty {
  79179. /**
  79180. * The index of the texture
  79181. */
  79182. index: number;
  79183. /**
  79184. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  79185. */
  79186. texCoord?: number;
  79187. }
  79188. /**
  79189. * The root object for a glTF asset
  79190. */
  79191. interface IGLTF extends IProperty {
  79192. /**
  79193. * An array of accessors. An accessor is a typed view into a bufferView
  79194. */
  79195. accessors?: IAccessor[];
  79196. /**
  79197. * An array of keyframe animations
  79198. */
  79199. animations?: IAnimation[];
  79200. /**
  79201. * Metadata about the glTF asset
  79202. */
  79203. asset: IAsset;
  79204. /**
  79205. * An array of buffers. A buffer points to binary geometry, animation, or skins
  79206. */
  79207. buffers?: IBuffer[];
  79208. /**
  79209. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  79210. */
  79211. bufferViews?: IBufferView[];
  79212. /**
  79213. * An array of cameras
  79214. */
  79215. cameras?: ICamera[];
  79216. /**
  79217. * Names of glTF extensions used somewhere in this asset
  79218. */
  79219. extensionsUsed?: string[];
  79220. /**
  79221. * Names of glTF extensions required to properly load this asset
  79222. */
  79223. extensionsRequired?: string[];
  79224. /**
  79225. * An array of images. An image defines data used to create a texture
  79226. */
  79227. images?: IImage[];
  79228. /**
  79229. * An array of materials. A material defines the appearance of a primitive
  79230. */
  79231. materials?: IMaterial[];
  79232. /**
  79233. * An array of meshes. A mesh is a set of primitives to be rendered
  79234. */
  79235. meshes?: IMesh[];
  79236. /**
  79237. * An array of nodes
  79238. */
  79239. nodes?: INode[];
  79240. /**
  79241. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  79242. */
  79243. samplers?: ISampler[];
  79244. /**
  79245. * The index of the default scene
  79246. */
  79247. scene?: number;
  79248. /**
  79249. * An array of scenes
  79250. */
  79251. scenes?: IScene[];
  79252. /**
  79253. * An array of skins. A skin is defined by joints and matrices
  79254. */
  79255. skins?: ISkin[];
  79256. /**
  79257. * An array of textures
  79258. */
  79259. textures?: ITexture[];
  79260. }
  79261. /**
  79262. * The glTF validation results
  79263. * @ignore
  79264. */
  79265. interface IGLTFValidationResults {
  79266. info: {
  79267. generator: string;
  79268. hasAnimations: boolean;
  79269. hasDefaultScene: boolean;
  79270. hasMaterials: boolean;
  79271. hasMorphTargets: boolean;
  79272. hasSkins: boolean;
  79273. hasTextures: boolean;
  79274. maxAttributesUsed: number;
  79275. primitivesCount: number
  79276. };
  79277. issues: {
  79278. messages: Array<string>;
  79279. numErrors: number;
  79280. numHints: number;
  79281. numInfos: number;
  79282. numWarnings: number;
  79283. truncated: boolean
  79284. };
  79285. mimeType: string;
  79286. uri: string;
  79287. validatedAt: string;
  79288. validatorVersion: string;
  79289. }
  79290. /**
  79291. * The glTF validation options
  79292. */
  79293. interface IGLTFValidationOptions {
  79294. /** Uri to use */
  79295. uri?: string;
  79296. /** Function used to load external resources */
  79297. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  79298. /** Boolean indicating that we need to validate accessor data */
  79299. validateAccessorData?: boolean;
  79300. /** max number of issues allowed */
  79301. maxIssues?: number;
  79302. /** Ignored issues */
  79303. ignoredIssues?: Array<string>;
  79304. /** Value to override severy settings */
  79305. severityOverrides?: Object;
  79306. }
  79307. /**
  79308. * The glTF validator object
  79309. * @ignore
  79310. */
  79311. interface IGLTFValidator {
  79312. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  79313. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  79314. }
  79315. }
  79316. declare module BABYLON {
  79317. /** @hidden */
  79318. export var cellPixelShader: {
  79319. name: string;
  79320. shader: string;
  79321. };
  79322. }
  79323. declare module BABYLON {
  79324. /** @hidden */
  79325. export var cellVertexShader: {
  79326. name: string;
  79327. shader: string;
  79328. };
  79329. }
  79330. declare module BABYLON {
  79331. export class CellMaterial extends BABYLON.PushMaterial {
  79332. private _diffuseTexture;
  79333. diffuseTexture: BABYLON.BaseTexture;
  79334. diffuseColor: BABYLON.Color3;
  79335. _computeHighLevel: boolean;
  79336. computeHighLevel: boolean;
  79337. private _disableLighting;
  79338. disableLighting: boolean;
  79339. private _maxSimultaneousLights;
  79340. maxSimultaneousLights: number;
  79341. private _renderId;
  79342. constructor(name: string, scene: BABYLON.Scene);
  79343. needAlphaBlending(): boolean;
  79344. needAlphaTesting(): boolean;
  79345. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79346. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79347. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79348. getAnimatables(): BABYLON.IAnimatable[];
  79349. getActiveTextures(): BABYLON.BaseTexture[];
  79350. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79351. dispose(forceDisposeEffect?: boolean): void;
  79352. getClassName(): string;
  79353. clone(name: string): CellMaterial;
  79354. serialize(): any;
  79355. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  79356. }
  79357. }
  79358. declare module BABYLON {
  79359. export class CustomShaderStructure {
  79360. FragmentStore: string;
  79361. VertexStore: string;
  79362. constructor();
  79363. }
  79364. export class ShaderSpecialParts {
  79365. constructor();
  79366. Fragment_Begin: string;
  79367. Fragment_Definitions: string;
  79368. Fragment_MainBegin: string;
  79369. Fragment_Custom_Diffuse: string;
  79370. Fragment_Before_Lights: string;
  79371. Fragment_Before_Fog: string;
  79372. Fragment_Custom_Alpha: string;
  79373. Fragment_Before_FragColor: string;
  79374. Vertex_Begin: string;
  79375. Vertex_Definitions: string;
  79376. Vertex_MainBegin: string;
  79377. Vertex_Before_PositionUpdated: string;
  79378. Vertex_Before_NormalUpdated: string;
  79379. Vertex_MainEnd: string;
  79380. }
  79381. export class CustomMaterial extends BABYLON.StandardMaterial {
  79382. static ShaderIndexer: number;
  79383. CustomParts: ShaderSpecialParts;
  79384. _isCreatedShader: boolean;
  79385. _createdShaderName: string;
  79386. _customUniform: string[];
  79387. _newUniforms: string[];
  79388. _newUniformInstances: any[];
  79389. _newSamplerInstances: BABYLON.Texture[];
  79390. _customAttributes: string[];
  79391. FragmentShader: string;
  79392. VertexShader: string;
  79393. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  79394. ReviewUniform(name: string, arr: string[]): string[];
  79395. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines, attributes?: string[]): string;
  79396. constructor(name: string, scene: BABYLON.Scene);
  79397. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  79398. AddAttribute(name: string): CustomMaterial;
  79399. Fragment_Begin(shaderPart: string): CustomMaterial;
  79400. Fragment_Definitions(shaderPart: string): CustomMaterial;
  79401. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  79402. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  79403. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  79404. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  79405. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  79406. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  79407. Vertex_Begin(shaderPart: string): CustomMaterial;
  79408. Vertex_Definitions(shaderPart: string): CustomMaterial;
  79409. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  79410. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  79411. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  79412. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  79413. }
  79414. }
  79415. declare module BABYLON {
  79416. export class ShaderAlebdoParts {
  79417. constructor();
  79418. Fragment_Begin: string;
  79419. Fragment_Definitions: string;
  79420. Fragment_MainBegin: string;
  79421. Fragment_Custom_Albedo: string;
  79422. Fragment_Before_Lights: string;
  79423. Fragment_Custom_MetallicRoughness: string;
  79424. Fragment_Custom_MicroSurface: string;
  79425. Fragment_Before_Fog: string;
  79426. Fragment_Custom_Alpha: string;
  79427. Fragment_Before_FragColor: string;
  79428. Vertex_Begin: string;
  79429. Vertex_Definitions: string;
  79430. Vertex_MainBegin: string;
  79431. Vertex_Before_PositionUpdated: string;
  79432. Vertex_Before_NormalUpdated: string;
  79433. Vertex_MainEnd: string;
  79434. }
  79435. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  79436. static ShaderIndexer: number;
  79437. CustomParts: ShaderAlebdoParts;
  79438. _isCreatedShader: boolean;
  79439. _createdShaderName: string;
  79440. _customUniform: string[];
  79441. _newUniforms: string[];
  79442. _newUniformInstances: any[];
  79443. _newSamplerInstances: BABYLON.Texture[];
  79444. _customAttributes: string[];
  79445. FragmentShader: string;
  79446. VertexShader: string;
  79447. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  79448. ReviewUniform(name: string, arr: string[]): string[];
  79449. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines, attributes?: string[]): string;
  79450. constructor(name: string, scene: BABYLON.Scene);
  79451. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  79452. AddAttribute(name: string): PBRCustomMaterial;
  79453. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  79454. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  79455. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  79456. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  79457. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  79458. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  79459. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  79460. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  79461. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  79462. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  79463. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  79464. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  79465. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  79466. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  79467. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  79468. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  79469. }
  79470. }
  79471. declare module BABYLON {
  79472. /** @hidden */
  79473. export var firePixelShader: {
  79474. name: string;
  79475. shader: string;
  79476. };
  79477. }
  79478. declare module BABYLON {
  79479. /** @hidden */
  79480. export var fireVertexShader: {
  79481. name: string;
  79482. shader: string;
  79483. };
  79484. }
  79485. declare module BABYLON {
  79486. export class FireMaterial extends BABYLON.PushMaterial {
  79487. private _diffuseTexture;
  79488. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79489. private _distortionTexture;
  79490. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79491. private _opacityTexture;
  79492. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79493. diffuseColor: BABYLON.Color3;
  79494. speed: number;
  79495. private _scaledDiffuse;
  79496. private _renderId;
  79497. private _lastTime;
  79498. constructor(name: string, scene: BABYLON.Scene);
  79499. needAlphaBlending(): boolean;
  79500. needAlphaTesting(): boolean;
  79501. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79502. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79503. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79504. getAnimatables(): BABYLON.IAnimatable[];
  79505. getActiveTextures(): BABYLON.BaseTexture[];
  79506. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79507. getClassName(): string;
  79508. dispose(forceDisposeEffect?: boolean): void;
  79509. clone(name: string): FireMaterial;
  79510. serialize(): any;
  79511. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  79512. }
  79513. }
  79514. declare module BABYLON {
  79515. /** @hidden */
  79516. export var furPixelShader: {
  79517. name: string;
  79518. shader: string;
  79519. };
  79520. }
  79521. declare module BABYLON {
  79522. /** @hidden */
  79523. export var furVertexShader: {
  79524. name: string;
  79525. shader: string;
  79526. };
  79527. }
  79528. declare module BABYLON {
  79529. export class FurMaterial extends BABYLON.PushMaterial {
  79530. private _diffuseTexture;
  79531. diffuseTexture: BABYLON.BaseTexture;
  79532. private _heightTexture;
  79533. heightTexture: BABYLON.BaseTexture;
  79534. diffuseColor: BABYLON.Color3;
  79535. furLength: number;
  79536. furAngle: number;
  79537. furColor: BABYLON.Color3;
  79538. furOffset: number;
  79539. furSpacing: number;
  79540. furGravity: BABYLON.Vector3;
  79541. furSpeed: number;
  79542. furDensity: number;
  79543. furOcclusion: number;
  79544. furTexture: BABYLON.DynamicTexture;
  79545. private _disableLighting;
  79546. disableLighting: boolean;
  79547. private _maxSimultaneousLights;
  79548. maxSimultaneousLights: number;
  79549. highLevelFur: boolean;
  79550. _meshes: BABYLON.AbstractMesh[];
  79551. private _renderId;
  79552. private _furTime;
  79553. constructor(name: string, scene: BABYLON.Scene);
  79554. get furTime(): number;
  79555. set furTime(furTime: number);
  79556. needAlphaBlending(): boolean;
  79557. needAlphaTesting(): boolean;
  79558. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79559. updateFur(): void;
  79560. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79561. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79562. getAnimatables(): BABYLON.IAnimatable[];
  79563. getActiveTextures(): BABYLON.BaseTexture[];
  79564. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79565. dispose(forceDisposeEffect?: boolean): void;
  79566. clone(name: string): FurMaterial;
  79567. serialize(): any;
  79568. getClassName(): string;
  79569. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  79570. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  79571. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  79572. }
  79573. }
  79574. declare module BABYLON {
  79575. /** @hidden */
  79576. export var gradientPixelShader: {
  79577. name: string;
  79578. shader: string;
  79579. };
  79580. }
  79581. declare module BABYLON {
  79582. /** @hidden */
  79583. export var gradientVertexShader: {
  79584. name: string;
  79585. shader: string;
  79586. };
  79587. }
  79588. declare module BABYLON {
  79589. export class GradientMaterial extends BABYLON.PushMaterial {
  79590. private _maxSimultaneousLights;
  79591. maxSimultaneousLights: number;
  79592. topColor: BABYLON.Color3;
  79593. topColorAlpha: number;
  79594. bottomColor: BABYLON.Color3;
  79595. bottomColorAlpha: number;
  79596. offset: number;
  79597. scale: number;
  79598. smoothness: number;
  79599. private _disableLighting;
  79600. disableLighting: boolean;
  79601. private _renderId;
  79602. constructor(name: string, scene: BABYLON.Scene);
  79603. needAlphaBlending(): boolean;
  79604. needAlphaTesting(): boolean;
  79605. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79606. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79607. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79608. getAnimatables(): BABYLON.IAnimatable[];
  79609. dispose(forceDisposeEffect?: boolean): void;
  79610. clone(name: string): GradientMaterial;
  79611. serialize(): any;
  79612. getClassName(): string;
  79613. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  79614. }
  79615. }
  79616. declare module BABYLON {
  79617. /** @hidden */
  79618. export var gridPixelShader: {
  79619. name: string;
  79620. shader: string;
  79621. };
  79622. }
  79623. declare module BABYLON {
  79624. /** @hidden */
  79625. export var gridVertexShader: {
  79626. name: string;
  79627. shader: string;
  79628. };
  79629. }
  79630. declare module BABYLON {
  79631. /**
  79632. * The grid materials allows you to wrap any shape with a grid.
  79633. * Colors are customizable.
  79634. */
  79635. export class GridMaterial extends BABYLON.PushMaterial {
  79636. /**
  79637. * Main color of the grid (e.g. between lines)
  79638. */
  79639. mainColor: BABYLON.Color3;
  79640. /**
  79641. * Color of the grid lines.
  79642. */
  79643. lineColor: BABYLON.Color3;
  79644. /**
  79645. * The scale of the grid compared to unit.
  79646. */
  79647. gridRatio: number;
  79648. /**
  79649. * Allows setting an offset for the grid lines.
  79650. */
  79651. gridOffset: BABYLON.Vector3;
  79652. /**
  79653. * The frequency of thicker lines.
  79654. */
  79655. majorUnitFrequency: number;
  79656. /**
  79657. * The visibility of minor units in the grid.
  79658. */
  79659. minorUnitVisibility: number;
  79660. /**
  79661. * The grid opacity outside of the lines.
  79662. */
  79663. opacity: number;
  79664. /**
  79665. * Determine RBG output is premultiplied by alpha value.
  79666. */
  79667. preMultiplyAlpha: boolean;
  79668. private _opacityTexture;
  79669. opacityTexture: BABYLON.BaseTexture;
  79670. private _gridControl;
  79671. private _renderId;
  79672. /**
  79673. * constructor
  79674. * @param name The name given to the material in order to identify it afterwards.
  79675. * @param scene The scene the material is used in.
  79676. */
  79677. constructor(name: string, scene: BABYLON.Scene);
  79678. /**
  79679. * Returns wehter or not the grid requires alpha blending.
  79680. */
  79681. needAlphaBlending(): boolean;
  79682. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  79683. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79684. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79685. /**
  79686. * Dispose the material and its associated resources.
  79687. * @param forceDisposeEffect will also dispose the used effect when true
  79688. */
  79689. dispose(forceDisposeEffect?: boolean): void;
  79690. clone(name: string): GridMaterial;
  79691. serialize(): any;
  79692. getClassName(): string;
  79693. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  79694. }
  79695. }
  79696. declare module BABYLON {
  79697. /** @hidden */
  79698. export var lavaPixelShader: {
  79699. name: string;
  79700. shader: string;
  79701. };
  79702. }
  79703. declare module BABYLON {
  79704. /** @hidden */
  79705. export var lavaVertexShader: {
  79706. name: string;
  79707. shader: string;
  79708. };
  79709. }
  79710. declare module BABYLON {
  79711. export class LavaMaterial extends BABYLON.PushMaterial {
  79712. private _diffuseTexture;
  79713. diffuseTexture: BABYLON.BaseTexture;
  79714. noiseTexture: BABYLON.BaseTexture;
  79715. fogColor: BABYLON.Color3;
  79716. speed: number;
  79717. movingSpeed: number;
  79718. lowFrequencySpeed: number;
  79719. fogDensity: number;
  79720. private _lastTime;
  79721. diffuseColor: BABYLON.Color3;
  79722. private _disableLighting;
  79723. disableLighting: boolean;
  79724. private _unlit;
  79725. unlit: boolean;
  79726. private _maxSimultaneousLights;
  79727. maxSimultaneousLights: number;
  79728. private _scaledDiffuse;
  79729. private _renderId;
  79730. constructor(name: string, scene: BABYLON.Scene);
  79731. needAlphaBlending(): boolean;
  79732. needAlphaTesting(): boolean;
  79733. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79734. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79735. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79736. getAnimatables(): BABYLON.IAnimatable[];
  79737. getActiveTextures(): BABYLON.BaseTexture[];
  79738. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79739. dispose(forceDisposeEffect?: boolean): void;
  79740. clone(name: string): LavaMaterial;
  79741. serialize(): any;
  79742. getClassName(): string;
  79743. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  79744. }
  79745. }
  79746. declare module BABYLON {
  79747. /** @hidden */
  79748. export var mixPixelShader: {
  79749. name: string;
  79750. shader: string;
  79751. };
  79752. }
  79753. declare module BABYLON {
  79754. /** @hidden */
  79755. export var mixVertexShader: {
  79756. name: string;
  79757. shader: string;
  79758. };
  79759. }
  79760. declare module BABYLON {
  79761. export class MixMaterial extends BABYLON.PushMaterial {
  79762. /**
  79763. * Mix textures
  79764. */
  79765. private _mixTexture1;
  79766. mixTexture1: BABYLON.BaseTexture;
  79767. private _mixTexture2;
  79768. mixTexture2: BABYLON.BaseTexture;
  79769. /**
  79770. * Diffuse textures
  79771. */
  79772. private _diffuseTexture1;
  79773. diffuseTexture1: BABYLON.Texture;
  79774. private _diffuseTexture2;
  79775. diffuseTexture2: BABYLON.Texture;
  79776. private _diffuseTexture3;
  79777. diffuseTexture3: BABYLON.Texture;
  79778. private _diffuseTexture4;
  79779. diffuseTexture4: BABYLON.Texture;
  79780. private _diffuseTexture5;
  79781. diffuseTexture5: BABYLON.Texture;
  79782. private _diffuseTexture6;
  79783. diffuseTexture6: BABYLON.Texture;
  79784. private _diffuseTexture7;
  79785. diffuseTexture7: BABYLON.Texture;
  79786. private _diffuseTexture8;
  79787. diffuseTexture8: BABYLON.Texture;
  79788. /**
  79789. * Uniforms
  79790. */
  79791. diffuseColor: BABYLON.Color3;
  79792. specularColor: BABYLON.Color3;
  79793. specularPower: number;
  79794. private _disableLighting;
  79795. disableLighting: boolean;
  79796. private _maxSimultaneousLights;
  79797. maxSimultaneousLights: number;
  79798. private _renderId;
  79799. constructor(name: string, scene: BABYLON.Scene);
  79800. needAlphaBlending(): boolean;
  79801. needAlphaTesting(): boolean;
  79802. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79803. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79804. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79805. getAnimatables(): BABYLON.IAnimatable[];
  79806. getActiveTextures(): BABYLON.BaseTexture[];
  79807. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79808. dispose(forceDisposeEffect?: boolean): void;
  79809. clone(name: string): MixMaterial;
  79810. serialize(): any;
  79811. getClassName(): string;
  79812. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  79813. }
  79814. }
  79815. declare module BABYLON {
  79816. /** @hidden */
  79817. export var normalPixelShader: {
  79818. name: string;
  79819. shader: string;
  79820. };
  79821. }
  79822. declare module BABYLON {
  79823. /** @hidden */
  79824. export var normalVertexShader: {
  79825. name: string;
  79826. shader: string;
  79827. };
  79828. }
  79829. declare module BABYLON {
  79830. export class NormalMaterial extends BABYLON.PushMaterial {
  79831. private _diffuseTexture;
  79832. diffuseTexture: BABYLON.BaseTexture;
  79833. diffuseColor: BABYLON.Color3;
  79834. private _disableLighting;
  79835. disableLighting: boolean;
  79836. private _maxSimultaneousLights;
  79837. maxSimultaneousLights: number;
  79838. private _renderId;
  79839. constructor(name: string, scene: BABYLON.Scene);
  79840. needAlphaBlending(): boolean;
  79841. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  79842. needAlphaTesting(): boolean;
  79843. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79844. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79845. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79846. getAnimatables(): BABYLON.IAnimatable[];
  79847. getActiveTextures(): BABYLON.BaseTexture[];
  79848. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79849. dispose(forceDisposeEffect?: boolean): void;
  79850. clone(name: string): NormalMaterial;
  79851. serialize(): any;
  79852. getClassName(): string;
  79853. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  79854. }
  79855. }
  79856. declare module BABYLON {
  79857. /** @hidden */
  79858. export var shadowOnlyPixelShader: {
  79859. name: string;
  79860. shader: string;
  79861. };
  79862. }
  79863. declare module BABYLON {
  79864. /** @hidden */
  79865. export var shadowOnlyVertexShader: {
  79866. name: string;
  79867. shader: string;
  79868. };
  79869. }
  79870. declare module BABYLON {
  79871. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  79872. private _renderId;
  79873. private _activeLight;
  79874. constructor(name: string, scene: BABYLON.Scene);
  79875. shadowColor: BABYLON.Color3;
  79876. needAlphaBlending(): boolean;
  79877. needAlphaTesting(): boolean;
  79878. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79879. get activeLight(): BABYLON.IShadowLight;
  79880. set activeLight(light: BABYLON.IShadowLight);
  79881. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79882. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79883. clone(name: string): ShadowOnlyMaterial;
  79884. serialize(): any;
  79885. getClassName(): string;
  79886. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  79887. }
  79888. }
  79889. declare module BABYLON {
  79890. /** @hidden */
  79891. export var simplePixelShader: {
  79892. name: string;
  79893. shader: string;
  79894. };
  79895. }
  79896. declare module BABYLON {
  79897. /** @hidden */
  79898. export var simpleVertexShader: {
  79899. name: string;
  79900. shader: string;
  79901. };
  79902. }
  79903. declare module BABYLON {
  79904. export class SimpleMaterial extends BABYLON.PushMaterial {
  79905. private _diffuseTexture;
  79906. diffuseTexture: BABYLON.BaseTexture;
  79907. diffuseColor: BABYLON.Color3;
  79908. private _disableLighting;
  79909. disableLighting: boolean;
  79910. private _maxSimultaneousLights;
  79911. maxSimultaneousLights: number;
  79912. private _renderId;
  79913. constructor(name: string, scene: BABYLON.Scene);
  79914. needAlphaBlending(): boolean;
  79915. needAlphaTesting(): boolean;
  79916. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79917. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79918. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79919. getAnimatables(): BABYLON.IAnimatable[];
  79920. getActiveTextures(): BABYLON.BaseTexture[];
  79921. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79922. dispose(forceDisposeEffect?: boolean): void;
  79923. clone(name: string): SimpleMaterial;
  79924. serialize(): any;
  79925. getClassName(): string;
  79926. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  79927. }
  79928. }
  79929. declare module BABYLON {
  79930. /** @hidden */
  79931. export var skyPixelShader: {
  79932. name: string;
  79933. shader: string;
  79934. };
  79935. }
  79936. declare module BABYLON {
  79937. /** @hidden */
  79938. export var skyVertexShader: {
  79939. name: string;
  79940. shader: string;
  79941. };
  79942. }
  79943. declare module BABYLON {
  79944. /**
  79945. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  79946. * @see https://doc.babylonjs.com/extensions/sky
  79947. */
  79948. export class SkyMaterial extends BABYLON.PushMaterial {
  79949. /**
  79950. * Defines the overall luminance of sky in interval ]0, 1[.
  79951. */
  79952. luminance: number;
  79953. /**
  79954. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  79955. */
  79956. turbidity: number;
  79957. /**
  79958. * Defines the sky appearance (light intensity).
  79959. */
  79960. rayleigh: number;
  79961. /**
  79962. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  79963. */
  79964. mieCoefficient: number;
  79965. /**
  79966. * Defines the amount of haze particles following the Mie scattering theory.
  79967. */
  79968. mieDirectionalG: number;
  79969. /**
  79970. * Defines the distance of the sun according to the active scene camera.
  79971. */
  79972. distance: number;
  79973. /**
  79974. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  79975. * "inclined".
  79976. */
  79977. inclination: number;
  79978. /**
  79979. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  79980. * an object direction and a reference direction.
  79981. */
  79982. azimuth: number;
  79983. /**
  79984. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  79985. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  79986. */
  79987. sunPosition: BABYLON.Vector3;
  79988. /**
  79989. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  79990. * .sunPosition property.
  79991. */
  79992. useSunPosition: boolean;
  79993. /**
  79994. * Defines an offset vector used to get a horizon offset.
  79995. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  79996. */
  79997. cameraOffset: BABYLON.Vector3;
  79998. private _cameraPosition;
  79999. private _renderId;
  80000. /**
  80001. * Instantiates a new sky material.
  80002. * This material allows to create dynamic and texture free
  80003. * effects for skyboxes by taking care of the atmosphere state.
  80004. * @see https://doc.babylonjs.com/extensions/sky
  80005. * @param name Define the name of the material in the scene
  80006. * @param scene Define the scene the material belong to
  80007. */
  80008. constructor(name: string, scene: BABYLON.Scene);
  80009. /**
  80010. * Specifies if the material will require alpha blending
  80011. * @returns a boolean specifying if alpha blending is needed
  80012. */
  80013. needAlphaBlending(): boolean;
  80014. /**
  80015. * Specifies if this material should be rendered in alpha test mode
  80016. * @returns false as the sky material doesn't need alpha testing.
  80017. */
  80018. needAlphaTesting(): boolean;
  80019. /**
  80020. * Get the texture used for alpha test purpose.
  80021. * @returns null as the sky material has no texture.
  80022. */
  80023. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80024. /**
  80025. * Get if the submesh is ready to be used and all its information available.
  80026. * Child classes can use it to update shaders
  80027. * @param mesh defines the mesh to check
  80028. * @param subMesh defines which submesh to check
  80029. * @param useInstances specifies that instances should be used
  80030. * @returns a boolean indicating that the submesh is ready or not
  80031. */
  80032. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80033. /**
  80034. * Binds the submesh to this material by preparing the effect and shader to draw
  80035. * @param world defines the world transformation matrix
  80036. * @param mesh defines the mesh containing the submesh
  80037. * @param subMesh defines the submesh to bind the material to
  80038. */
  80039. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80040. /**
  80041. * Get the list of animatables in the material.
  80042. * @returns the list of animatables object used in the material
  80043. */
  80044. getAnimatables(): BABYLON.IAnimatable[];
  80045. /**
  80046. * Disposes the material
  80047. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  80048. */
  80049. dispose(forceDisposeEffect?: boolean): void;
  80050. /**
  80051. * Makes a duplicate of the material, and gives it a new name
  80052. * @param name defines the new name for the duplicated material
  80053. * @returns the cloned material
  80054. */
  80055. clone(name: string): SkyMaterial;
  80056. /**
  80057. * Serializes this material in a JSON representation
  80058. * @returns the serialized material object
  80059. */
  80060. serialize(): any;
  80061. /**
  80062. * Gets the current class name of the material e.g. "SkyMaterial"
  80063. * Mainly use in serialization.
  80064. * @returns the class name
  80065. */
  80066. getClassName(): string;
  80067. /**
  80068. * Creates a sky material from parsed material data
  80069. * @param source defines the JSON representation of the material
  80070. * @param scene defines the hosting scene
  80071. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  80072. * @returns a new sky material
  80073. */
  80074. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  80075. }
  80076. }
  80077. declare module BABYLON {
  80078. /** @hidden */
  80079. export var terrainPixelShader: {
  80080. name: string;
  80081. shader: string;
  80082. };
  80083. }
  80084. declare module BABYLON {
  80085. /** @hidden */
  80086. export var terrainVertexShader: {
  80087. name: string;
  80088. shader: string;
  80089. };
  80090. }
  80091. declare module BABYLON {
  80092. export class TerrainMaterial extends BABYLON.PushMaterial {
  80093. private _mixTexture;
  80094. mixTexture: BABYLON.BaseTexture;
  80095. private _diffuseTexture1;
  80096. diffuseTexture1: BABYLON.Texture;
  80097. private _diffuseTexture2;
  80098. diffuseTexture2: BABYLON.Texture;
  80099. private _diffuseTexture3;
  80100. diffuseTexture3: BABYLON.Texture;
  80101. private _bumpTexture1;
  80102. bumpTexture1: BABYLON.Texture;
  80103. private _bumpTexture2;
  80104. bumpTexture2: BABYLON.Texture;
  80105. private _bumpTexture3;
  80106. bumpTexture3: BABYLON.Texture;
  80107. diffuseColor: BABYLON.Color3;
  80108. specularColor: BABYLON.Color3;
  80109. specularPower: number;
  80110. private _disableLighting;
  80111. disableLighting: boolean;
  80112. private _maxSimultaneousLights;
  80113. maxSimultaneousLights: number;
  80114. private _renderId;
  80115. constructor(name: string, scene: BABYLON.Scene);
  80116. needAlphaBlending(): boolean;
  80117. needAlphaTesting(): boolean;
  80118. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80119. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80120. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80121. getAnimatables(): BABYLON.IAnimatable[];
  80122. getActiveTextures(): BABYLON.BaseTexture[];
  80123. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80124. dispose(forceDisposeEffect?: boolean): void;
  80125. clone(name: string): TerrainMaterial;
  80126. serialize(): any;
  80127. getClassName(): string;
  80128. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  80129. }
  80130. }
  80131. declare module BABYLON {
  80132. /** @hidden */
  80133. export var triplanarPixelShader: {
  80134. name: string;
  80135. shader: string;
  80136. };
  80137. }
  80138. declare module BABYLON {
  80139. /** @hidden */
  80140. export var triplanarVertexShader: {
  80141. name: string;
  80142. shader: string;
  80143. };
  80144. }
  80145. declare module BABYLON {
  80146. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  80147. mixTexture: BABYLON.BaseTexture;
  80148. private _diffuseTextureX;
  80149. diffuseTextureX: BABYLON.BaseTexture;
  80150. private _diffuseTextureY;
  80151. diffuseTextureY: BABYLON.BaseTexture;
  80152. private _diffuseTextureZ;
  80153. diffuseTextureZ: BABYLON.BaseTexture;
  80154. private _normalTextureX;
  80155. normalTextureX: BABYLON.BaseTexture;
  80156. private _normalTextureY;
  80157. normalTextureY: BABYLON.BaseTexture;
  80158. private _normalTextureZ;
  80159. normalTextureZ: BABYLON.BaseTexture;
  80160. tileSize: number;
  80161. diffuseColor: BABYLON.Color3;
  80162. specularColor: BABYLON.Color3;
  80163. specularPower: number;
  80164. private _disableLighting;
  80165. disableLighting: boolean;
  80166. private _maxSimultaneousLights;
  80167. maxSimultaneousLights: number;
  80168. private _renderId;
  80169. constructor(name: string, scene: BABYLON.Scene);
  80170. needAlphaBlending(): boolean;
  80171. needAlphaTesting(): boolean;
  80172. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80173. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80174. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80175. getAnimatables(): BABYLON.IAnimatable[];
  80176. getActiveTextures(): BABYLON.BaseTexture[];
  80177. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80178. dispose(forceDisposeEffect?: boolean): void;
  80179. clone(name: string): TriPlanarMaterial;
  80180. serialize(): any;
  80181. getClassName(): string;
  80182. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  80183. }
  80184. }
  80185. declare module BABYLON {
  80186. /** @hidden */
  80187. export var waterPixelShader: {
  80188. name: string;
  80189. shader: string;
  80190. };
  80191. }
  80192. declare module BABYLON {
  80193. /** @hidden */
  80194. export var waterVertexShader: {
  80195. name: string;
  80196. shader: string;
  80197. };
  80198. }
  80199. declare module BABYLON {
  80200. export class WaterMaterial extends BABYLON.PushMaterial {
  80201. renderTargetSize: BABYLON.Vector2;
  80202. private _bumpTexture;
  80203. bumpTexture: BABYLON.BaseTexture;
  80204. diffuseColor: BABYLON.Color3;
  80205. specularColor: BABYLON.Color3;
  80206. specularPower: number;
  80207. private _disableLighting;
  80208. disableLighting: boolean;
  80209. private _maxSimultaneousLights;
  80210. maxSimultaneousLights: number;
  80211. /**
  80212. * @param {number}: Represents the wind force
  80213. */
  80214. windForce: number;
  80215. /**
  80216. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  80217. */
  80218. windDirection: BABYLON.Vector2;
  80219. /**
  80220. * @param {number}: Wave height, represents the height of the waves
  80221. */
  80222. waveHeight: number;
  80223. /**
  80224. * @param {number}: Bump height, represents the bump height related to the bump map
  80225. */
  80226. bumpHeight: number;
  80227. /**
  80228. * @param {boolean}: Add a smaller moving bump to less steady waves.
  80229. */
  80230. private _bumpSuperimpose;
  80231. bumpSuperimpose: boolean;
  80232. /**
  80233. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  80234. */
  80235. private _fresnelSeparate;
  80236. fresnelSeparate: boolean;
  80237. /**
  80238. * @param {boolean}: bump Waves modify the reflection.
  80239. */
  80240. private _bumpAffectsReflection;
  80241. bumpAffectsReflection: boolean;
  80242. /**
  80243. * @param {number}: The water color blended with the refraction (near)
  80244. */
  80245. waterColor: BABYLON.Color3;
  80246. /**
  80247. * @param {number}: The blend factor related to the water color
  80248. */
  80249. colorBlendFactor: number;
  80250. /**
  80251. * @param {number}: The water color blended with the reflection (far)
  80252. */
  80253. waterColor2: BABYLON.Color3;
  80254. /**
  80255. * @param {number}: The blend factor related to the water color (reflection, far)
  80256. */
  80257. colorBlendFactor2: number;
  80258. /**
  80259. * @param {number}: Represents the maximum length of a wave
  80260. */
  80261. waveLength: number;
  80262. /**
  80263. * @param {number}: Defines the waves speed
  80264. */
  80265. waveSpeed: number;
  80266. /**
  80267. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  80268. * will avoid calculating useless pixels in the pixel shader of the water material.
  80269. */
  80270. disableClipPlane: boolean;
  80271. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  80272. private _mesh;
  80273. private _refractionRTT;
  80274. private _reflectionRTT;
  80275. private _reflectionTransform;
  80276. private _lastTime;
  80277. private _lastDeltaTime;
  80278. private _renderId;
  80279. private _useLogarithmicDepth;
  80280. private _waitingRenderList;
  80281. private _imageProcessingConfiguration;
  80282. private _imageProcessingObserver;
  80283. /**
  80284. * Gets a boolean indicating that current material needs to register RTT
  80285. */
  80286. get hasRenderTargetTextures(): boolean;
  80287. /**
  80288. * Constructor
  80289. */
  80290. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  80291. get useLogarithmicDepth(): boolean;
  80292. set useLogarithmicDepth(value: boolean);
  80293. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  80294. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  80295. addToRenderList(node: any): void;
  80296. enableRenderTargets(enable: boolean): void;
  80297. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  80298. get renderTargetsEnabled(): boolean;
  80299. needAlphaBlending(): boolean;
  80300. needAlphaTesting(): boolean;
  80301. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80302. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80303. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80304. private _createRenderTargets;
  80305. getAnimatables(): BABYLON.IAnimatable[];
  80306. getActiveTextures(): BABYLON.BaseTexture[];
  80307. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80308. dispose(forceDisposeEffect?: boolean): void;
  80309. clone(name: string): WaterMaterial;
  80310. serialize(): any;
  80311. getClassName(): string;
  80312. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  80313. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  80314. }
  80315. }
  80316. declare module BABYLON {
  80317. /** @hidden */
  80318. export var asciiartPixelShader: {
  80319. name: string;
  80320. shader: string;
  80321. };
  80322. }
  80323. declare module BABYLON {
  80324. /**
  80325. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  80326. *
  80327. * It basically takes care rendering the font front the given font size to a texture.
  80328. * This is used later on in the postprocess.
  80329. */
  80330. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  80331. private _font;
  80332. private _text;
  80333. private _charSize;
  80334. /**
  80335. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  80336. */
  80337. get charSize(): number;
  80338. /**
  80339. * Create a new instance of the Ascii Art FontTexture class
  80340. * @param name the name of the texture
  80341. * @param font the font to use, use the W3C CSS notation
  80342. * @param text the caracter set to use in the rendering.
  80343. * @param scene the scene that owns the texture
  80344. */
  80345. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  80346. /**
  80347. * Gets the max char width of a font.
  80348. * @param font the font to use, use the W3C CSS notation
  80349. * @return the max char width
  80350. */
  80351. private getFontWidth;
  80352. /**
  80353. * Gets the max char height of a font.
  80354. * @param font the font to use, use the W3C CSS notation
  80355. * @return the max char height
  80356. */
  80357. private getFontHeight;
  80358. /**
  80359. * Clones the current AsciiArtTexture.
  80360. * @return the clone of the texture.
  80361. */
  80362. clone(): AsciiArtFontTexture;
  80363. /**
  80364. * Parses a json object representing the texture and returns an instance of it.
  80365. * @param source the source JSON representation
  80366. * @param scene the scene to create the texture for
  80367. * @return the parsed texture
  80368. */
  80369. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  80370. }
  80371. /**
  80372. * Option available in the Ascii Art Post Process.
  80373. */
  80374. export interface IAsciiArtPostProcessOptions {
  80375. /**
  80376. * The font to use following the w3c font definition.
  80377. */
  80378. font?: string;
  80379. /**
  80380. * The character set to use in the postprocess.
  80381. */
  80382. characterSet?: string;
  80383. /**
  80384. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  80385. * This number is defined between 0 and 1;
  80386. */
  80387. mixToTile?: number;
  80388. /**
  80389. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  80390. * This number is defined between 0 and 1;
  80391. */
  80392. mixToNormal?: number;
  80393. }
  80394. /**
  80395. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  80396. *
  80397. * Simmply add it to your scene and let the nerd that lives in you have fun.
  80398. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  80399. */
  80400. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  80401. /**
  80402. * The font texture used to render the char in the post process.
  80403. */
  80404. private _asciiArtFontTexture;
  80405. /**
  80406. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  80407. * This number is defined between 0 and 1;
  80408. */
  80409. mixToTile: number;
  80410. /**
  80411. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  80412. * This number is defined between 0 and 1;
  80413. */
  80414. mixToNormal: number;
  80415. /**
  80416. * Instantiates a new Ascii Art Post Process.
  80417. * @param name the name to give to the postprocess
  80418. * @camera the camera to apply the post process to.
  80419. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  80420. */
  80421. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  80422. }
  80423. }
  80424. declare module BABYLON {
  80425. /** @hidden */
  80426. export var digitalrainPixelShader: {
  80427. name: string;
  80428. shader: string;
  80429. };
  80430. }
  80431. declare module BABYLON {
  80432. /**
  80433. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  80434. *
  80435. * It basically takes care rendering the font front the given font size to a texture.
  80436. * This is used later on in the postprocess.
  80437. */
  80438. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  80439. private _font;
  80440. private _text;
  80441. private _charSize;
  80442. /**
  80443. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  80444. */
  80445. get charSize(): number;
  80446. /**
  80447. * Create a new instance of the Digital Rain FontTexture class
  80448. * @param name the name of the texture
  80449. * @param font the font to use, use the W3C CSS notation
  80450. * @param text the caracter set to use in the rendering.
  80451. * @param scene the scene that owns the texture
  80452. */
  80453. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  80454. /**
  80455. * Gets the max char width of a font.
  80456. * @param font the font to use, use the W3C CSS notation
  80457. * @return the max char width
  80458. */
  80459. private getFontWidth;
  80460. /**
  80461. * Gets the max char height of a font.
  80462. * @param font the font to use, use the W3C CSS notation
  80463. * @return the max char height
  80464. */
  80465. private getFontHeight;
  80466. /**
  80467. * Clones the current DigitalRainFontTexture.
  80468. * @return the clone of the texture.
  80469. */
  80470. clone(): DigitalRainFontTexture;
  80471. /**
  80472. * Parses a json object representing the texture and returns an instance of it.
  80473. * @param source the source JSON representation
  80474. * @param scene the scene to create the texture for
  80475. * @return the parsed texture
  80476. */
  80477. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  80478. }
  80479. /**
  80480. * Option available in the Digital Rain Post Process.
  80481. */
  80482. export interface IDigitalRainPostProcessOptions {
  80483. /**
  80484. * The font to use following the w3c font definition.
  80485. */
  80486. font?: string;
  80487. /**
  80488. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  80489. * This number is defined between 0 and 1;
  80490. */
  80491. mixToTile?: number;
  80492. /**
  80493. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  80494. * This number is defined between 0 and 1;
  80495. */
  80496. mixToNormal?: number;
  80497. }
  80498. /**
  80499. * DigitalRainPostProcess helps rendering everithing in digital rain.
  80500. *
  80501. * Simmply add it to your scene and let the nerd that lives in you have fun.
  80502. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  80503. */
  80504. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  80505. /**
  80506. * The font texture used to render the char in the post process.
  80507. */
  80508. private _digitalRainFontTexture;
  80509. /**
  80510. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  80511. * This number is defined between 0 and 1;
  80512. */
  80513. mixToTile: number;
  80514. /**
  80515. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  80516. * This number is defined between 0 and 1;
  80517. */
  80518. mixToNormal: number;
  80519. /**
  80520. * Instantiates a new Digital Rain Post Process.
  80521. * @param name the name to give to the postprocess
  80522. * @camera the camera to apply the post process to.
  80523. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  80524. */
  80525. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  80526. }
  80527. }
  80528. declare module BABYLON {
  80529. /** @hidden */
  80530. export var brickProceduralTexturePixelShader: {
  80531. name: string;
  80532. shader: string;
  80533. };
  80534. }
  80535. declare module BABYLON {
  80536. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  80537. private _numberOfBricksHeight;
  80538. private _numberOfBricksWidth;
  80539. private _jointColor;
  80540. private _brickColor;
  80541. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80542. updateShaderUniforms(): void;
  80543. get numberOfBricksHeight(): number;
  80544. set numberOfBricksHeight(value: number);
  80545. get numberOfBricksWidth(): number;
  80546. set numberOfBricksWidth(value: number);
  80547. get jointColor(): BABYLON.Color3;
  80548. set jointColor(value: BABYLON.Color3);
  80549. get brickColor(): BABYLON.Color3;
  80550. set brickColor(value: BABYLON.Color3);
  80551. /**
  80552. * Serializes this brick procedural texture
  80553. * @returns a serialized brick procedural texture object
  80554. */
  80555. serialize(): any;
  80556. /**
  80557. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  80558. * @param parsedTexture defines parsed texture data
  80559. * @param scene defines the current scene
  80560. * @param rootUrl defines the root URL containing brick procedural texture information
  80561. * @returns a parsed Brick Procedural BABYLON.Texture
  80562. */
  80563. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  80564. }
  80565. }
  80566. declare module BABYLON {
  80567. /** @hidden */
  80568. export var cloudProceduralTexturePixelShader: {
  80569. name: string;
  80570. shader: string;
  80571. };
  80572. }
  80573. declare module BABYLON {
  80574. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  80575. private _skyColor;
  80576. private _cloudColor;
  80577. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80578. updateShaderUniforms(): void;
  80579. get skyColor(): BABYLON.Color4;
  80580. set skyColor(value: BABYLON.Color4);
  80581. get cloudColor(): BABYLON.Color4;
  80582. set cloudColor(value: BABYLON.Color4);
  80583. /**
  80584. * Serializes this cloud procedural texture
  80585. * @returns a serialized cloud procedural texture object
  80586. */
  80587. serialize(): any;
  80588. /**
  80589. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  80590. * @param parsedTexture defines parsed texture data
  80591. * @param scene defines the current scene
  80592. * @param rootUrl defines the root URL containing cloud procedural texture information
  80593. * @returns a parsed Cloud Procedural BABYLON.Texture
  80594. */
  80595. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  80596. }
  80597. }
  80598. declare module BABYLON {
  80599. /** @hidden */
  80600. export var fireProceduralTexturePixelShader: {
  80601. name: string;
  80602. shader: string;
  80603. };
  80604. }
  80605. declare module BABYLON {
  80606. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  80607. private _time;
  80608. private _speed;
  80609. private _autoGenerateTime;
  80610. private _fireColors;
  80611. private _alphaThreshold;
  80612. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80613. updateShaderUniforms(): void;
  80614. render(useCameraPostProcess?: boolean): void;
  80615. static get PurpleFireColors(): BABYLON.Color3[];
  80616. static get GreenFireColors(): BABYLON.Color3[];
  80617. static get RedFireColors(): BABYLON.Color3[];
  80618. static get BlueFireColors(): BABYLON.Color3[];
  80619. get autoGenerateTime(): boolean;
  80620. set autoGenerateTime(value: boolean);
  80621. get fireColors(): BABYLON.Color3[];
  80622. set fireColors(value: BABYLON.Color3[]);
  80623. get time(): number;
  80624. set time(value: number);
  80625. get speed(): BABYLON.Vector2;
  80626. set speed(value: BABYLON.Vector2);
  80627. get alphaThreshold(): number;
  80628. set alphaThreshold(value: number);
  80629. /**
  80630. * Serializes this fire procedural texture
  80631. * @returns a serialized fire procedural texture object
  80632. */
  80633. serialize(): any;
  80634. /**
  80635. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  80636. * @param parsedTexture defines parsed texture data
  80637. * @param scene defines the current scene
  80638. * @param rootUrl defines the root URL containing fire procedural texture information
  80639. * @returns a parsed Fire Procedural BABYLON.Texture
  80640. */
  80641. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  80642. }
  80643. }
  80644. declare module BABYLON {
  80645. /** @hidden */
  80646. export var grassProceduralTexturePixelShader: {
  80647. name: string;
  80648. shader: string;
  80649. };
  80650. }
  80651. declare module BABYLON {
  80652. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  80653. private _grassColors;
  80654. private _groundColor;
  80655. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80656. updateShaderUniforms(): void;
  80657. get grassColors(): BABYLON.Color3[];
  80658. set grassColors(value: BABYLON.Color3[]);
  80659. get groundColor(): BABYLON.Color3;
  80660. set groundColor(value: BABYLON.Color3);
  80661. /**
  80662. * Serializes this grass procedural texture
  80663. * @returns a serialized grass procedural texture object
  80664. */
  80665. serialize(): any;
  80666. /**
  80667. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  80668. * @param parsedTexture defines parsed texture data
  80669. * @param scene defines the current scene
  80670. * @param rootUrl defines the root URL containing grass procedural texture information
  80671. * @returns a parsed Grass Procedural BABYLON.Texture
  80672. */
  80673. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  80674. }
  80675. }
  80676. declare module BABYLON {
  80677. /** @hidden */
  80678. export var marbleProceduralTexturePixelShader: {
  80679. name: string;
  80680. shader: string;
  80681. };
  80682. }
  80683. declare module BABYLON {
  80684. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  80685. private _numberOfTilesHeight;
  80686. private _numberOfTilesWidth;
  80687. private _amplitude;
  80688. private _jointColor;
  80689. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80690. updateShaderUniforms(): void;
  80691. get numberOfTilesHeight(): number;
  80692. set numberOfTilesHeight(value: number);
  80693. get amplitude(): number;
  80694. set amplitude(value: number);
  80695. get numberOfTilesWidth(): number;
  80696. set numberOfTilesWidth(value: number);
  80697. get jointColor(): BABYLON.Color3;
  80698. set jointColor(value: BABYLON.Color3);
  80699. /**
  80700. * Serializes this marble procedural texture
  80701. * @returns a serialized marble procedural texture object
  80702. */
  80703. serialize(): any;
  80704. /**
  80705. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  80706. * @param parsedTexture defines parsed texture data
  80707. * @param scene defines the current scene
  80708. * @param rootUrl defines the root URL containing marble procedural texture information
  80709. * @returns a parsed Marble Procedural BABYLON.Texture
  80710. */
  80711. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  80712. }
  80713. }
  80714. declare module BABYLON {
  80715. /** @hidden */
  80716. export var normalMapProceduralTexturePixelShader: {
  80717. name: string;
  80718. shader: string;
  80719. };
  80720. }
  80721. declare module BABYLON {
  80722. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  80723. private _baseTexture;
  80724. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80725. updateShaderUniforms(): void;
  80726. render(useCameraPostProcess?: boolean): void;
  80727. resize(size: any, generateMipMaps: any): void;
  80728. get baseTexture(): BABYLON.Texture;
  80729. set baseTexture(texture: BABYLON.Texture);
  80730. /**
  80731. * Serializes this normal map procedural texture
  80732. * @returns a serialized normal map procedural texture object
  80733. */
  80734. serialize(): any;
  80735. /**
  80736. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  80737. * @param parsedTexture defines parsed texture data
  80738. * @param scene defines the current scene
  80739. * @param rootUrl defines the root URL containing normal map procedural texture information
  80740. * @returns a parsed Normal Map Procedural BABYLON.Texture
  80741. */
  80742. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  80743. }
  80744. }
  80745. declare module BABYLON {
  80746. /** @hidden */
  80747. export var perlinNoiseProceduralTexturePixelShader: {
  80748. name: string;
  80749. shader: string;
  80750. };
  80751. }
  80752. declare module BABYLON {
  80753. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  80754. time: number;
  80755. timeScale: number;
  80756. translationSpeed: number;
  80757. private _currentTranslation;
  80758. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80759. updateShaderUniforms(): void;
  80760. render(useCameraPostProcess?: boolean): void;
  80761. resize(size: any, generateMipMaps: any): void;
  80762. /**
  80763. * Serializes this perlin noise procedural texture
  80764. * @returns a serialized perlin noise procedural texture object
  80765. */
  80766. serialize(): any;
  80767. /**
  80768. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  80769. * @param parsedTexture defines parsed texture data
  80770. * @param scene defines the current scene
  80771. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  80772. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  80773. */
  80774. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  80775. }
  80776. }
  80777. declare module BABYLON {
  80778. /** @hidden */
  80779. export var roadProceduralTexturePixelShader: {
  80780. name: string;
  80781. shader: string;
  80782. };
  80783. }
  80784. declare module BABYLON {
  80785. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  80786. private _roadColor;
  80787. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80788. updateShaderUniforms(): void;
  80789. get roadColor(): BABYLON.Color3;
  80790. set roadColor(value: BABYLON.Color3);
  80791. /**
  80792. * Serializes this road procedural texture
  80793. * @returns a serialized road procedural texture object
  80794. */
  80795. serialize(): any;
  80796. /**
  80797. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  80798. * @param parsedTexture defines parsed texture data
  80799. * @param scene defines the current scene
  80800. * @param rootUrl defines the root URL containing road procedural texture information
  80801. * @returns a parsed Road Procedural BABYLON.Texture
  80802. */
  80803. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  80804. }
  80805. }
  80806. declare module BABYLON {
  80807. /** @hidden */
  80808. export var starfieldProceduralTexturePixelShader: {
  80809. name: string;
  80810. shader: string;
  80811. };
  80812. }
  80813. declare module BABYLON {
  80814. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  80815. private _time;
  80816. private _alpha;
  80817. private _beta;
  80818. private _zoom;
  80819. private _formuparam;
  80820. private _stepsize;
  80821. private _tile;
  80822. private _brightness;
  80823. private _darkmatter;
  80824. private _distfading;
  80825. private _saturation;
  80826. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80827. updateShaderUniforms(): void;
  80828. get time(): number;
  80829. set time(value: number);
  80830. get alpha(): number;
  80831. set alpha(value: number);
  80832. get beta(): number;
  80833. set beta(value: number);
  80834. get formuparam(): number;
  80835. set formuparam(value: number);
  80836. get stepsize(): number;
  80837. set stepsize(value: number);
  80838. get zoom(): number;
  80839. set zoom(value: number);
  80840. get tile(): number;
  80841. set tile(value: number);
  80842. get brightness(): number;
  80843. set brightness(value: number);
  80844. get darkmatter(): number;
  80845. set darkmatter(value: number);
  80846. get distfading(): number;
  80847. set distfading(value: number);
  80848. get saturation(): number;
  80849. set saturation(value: number);
  80850. /**
  80851. * Serializes this starfield procedural texture
  80852. * @returns a serialized starfield procedural texture object
  80853. */
  80854. serialize(): any;
  80855. /**
  80856. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  80857. * @param parsedTexture defines parsed texture data
  80858. * @param scene defines the current scene
  80859. * @param rootUrl defines the root URL containing startfield procedural texture information
  80860. * @returns a parsed Starfield Procedural BABYLON.Texture
  80861. */
  80862. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  80863. }
  80864. }
  80865. declare module BABYLON {
  80866. /** @hidden */
  80867. export var woodProceduralTexturePixelShader: {
  80868. name: string;
  80869. shader: string;
  80870. };
  80871. }
  80872. declare module BABYLON {
  80873. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  80874. private _ampScale;
  80875. private _woodColor;
  80876. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80877. updateShaderUniforms(): void;
  80878. get ampScale(): number;
  80879. set ampScale(value: number);
  80880. get woodColor(): BABYLON.Color3;
  80881. set woodColor(value: BABYLON.Color3);
  80882. /**
  80883. * Serializes this wood procedural texture
  80884. * @returns a serialized wood procedural texture object
  80885. */
  80886. serialize(): any;
  80887. /**
  80888. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  80889. * @param parsedTexture defines parsed texture data
  80890. * @param scene defines the current scene
  80891. * @param rootUrl defines the root URL containing wood procedural texture information
  80892. * @returns a parsed Wood Procedural BABYLON.Texture
  80893. */
  80894. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  80895. }
  80896. }